mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-17 23:41:27 +00:00
Lift side-effects
This commit is contained in:
parent
87617c7f25
commit
2bf8dbde29
@ -46,31 +46,31 @@ export class GildedRose {
|
|||||||
item.sellIn = item.sellIn - 1;
|
item.sellIn = item.sellIn - 1;
|
||||||
}
|
}
|
||||||
if (item.sellIn < 0) {
|
if (item.sellIn < 0) {
|
||||||
this.sellInBelow0(item);
|
item.quality = this.sellInBelow0(item)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return this.items;
|
return this.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
private sellInBelow0(item: Item) {
|
private sellInBelow0(item: Item): number {
|
||||||
if (item.name == 'Sulfuras, Hand of Ragnaros') return
|
if (item.name == 'Sulfuras, Hand of Ragnaros') return item.quality;
|
||||||
|
|
||||||
if (item.name == 'Aged Brie') {
|
if (item.name == 'Aged Brie') {
|
||||||
if (item.quality < 50) {
|
if (item.quality < 50) {
|
||||||
item.quality++
|
return item.quality + 1
|
||||||
}
|
}
|
||||||
return
|
return item.quality
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.name == 'Backstage passes to a TAFKAL80ETC concert') {
|
if (item.name == 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
item.quality = 0
|
return 0
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.quality > 0) {
|
if (item.quality > 0) {
|
||||||
item.quality--
|
return item.quality - 1
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return item.quality
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user