mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-25 03:11:13 +00:00
Extract update item quality
This commit is contained in:
parent
a06e221197
commit
426d9ecd03
@ -19,8 +19,21 @@ export class GildedRose {
|
|||||||
|
|
||||||
updateQuality() {
|
updateQuality() {
|
||||||
this.items.forEach((item, i) => {
|
this.items.forEach((item, i) => {
|
||||||
|
this.updateItemQuality(item)
|
||||||
|
|
||||||
|
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
||||||
|
item.sellIn = item.sellIn - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
item.quality = sellInBelow0(item)
|
||||||
|
})
|
||||||
|
|
||||||
|
return this.items;
|
||||||
|
}
|
||||||
|
|
||||||
|
private updateItemQuality(item: Item) {
|
||||||
if (item.name === 'Sulfuras, Hand of Ragnaros') {
|
if (item.name === 'Sulfuras, Hand of Ragnaros') {
|
||||||
// Do Nothing
|
return
|
||||||
} else if (item.name == 'Aged Brie') {
|
} else if (item.name == 'Aged Brie') {
|
||||||
this.incrementQuality(item);
|
this.incrementQuality(item);
|
||||||
} else if (item.name == 'Backstage passes to a TAFKAL80ETC concert') {
|
} else if (item.name == 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
@ -30,15 +43,8 @@ export class GildedRose {
|
|||||||
} else if (item.quality > 0) {
|
} else if (item.quality > 0) {
|
||||||
item.quality = item.quality - 1
|
item.quality = item.quality - 1
|
||||||
}
|
}
|
||||||
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
|
||||||
item.sellIn = item.sellIn - 1;
|
|
||||||
}
|
}
|
||||||
item.quality = sellInBelow0(item)
|
|
||||||
})
|
|
||||||
|
|
||||||
return this.items;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private incrementQuality(item: Item) {
|
private incrementQuality(item: Item) {
|
||||||
if (item.quality < 50) {
|
if (item.quality < 50) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user