mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-19 16:31:30 +00:00
Extract updateSellIn
This commit is contained in:
parent
ea88b3db9c
commit
03379118c6
@ -21,9 +21,7 @@ export class GildedRose {
|
|||||||
this.items.forEach((item, i) => {
|
this.items.forEach((item, i) => {
|
||||||
item.quality = updateItemQuality(item)
|
item.quality = updateItemQuality(item)
|
||||||
|
|
||||||
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
updateSellIn(item)
|
||||||
item.sellIn = item.sellIn - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
item.quality = sellInBelow0(item)
|
item.quality = sellInBelow0(item)
|
||||||
})
|
})
|
||||||
@ -32,6 +30,11 @@ export class GildedRose {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateSellIn(item: Item) {
|
||||||
|
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
||||||
|
item.sellIn = item.sellIn - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updateItemQuality({name, quality, sellIn, ...rest}: Item): number {
|
function updateItemQuality({name, quality, sellIn, ...rest}: Item): number {
|
||||||
if (name === 'Sulfuras, Hand of Ragnaros') {
|
if (name === 'Sulfuras, Hand of Ragnaros') {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user