mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-18 07:51:29 +00:00
Destructure item
This commit is contained in:
parent
e21ec0cc5b
commit
e667c5d091
@ -51,26 +51,26 @@ export class GildedRose {
|
|||||||
return this.items;
|
return this.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
private sellInBelow0(item: Item): number {
|
private sellInBelow0({quality, name, sellIn}: Item): number {
|
||||||
if (item.sellIn >= 0) return item.quality
|
if (sellIn >= 0) return quality
|
||||||
|
|
||||||
if (item.name == 'Sulfuras, Hand of Ragnaros') return item.quality;
|
if (name == 'Sulfuras, Hand of Ragnaros') return quality;
|
||||||
|
|
||||||
if (item.name == 'Aged Brie') {
|
if (name == 'Aged Brie') {
|
||||||
if (item.quality < 50) {
|
if (quality < 50) {
|
||||||
return item.quality + 1
|
return quality + 1
|
||||||
}
|
}
|
||||||
return item.quality
|
return quality
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.name == 'Backstage passes to a TAFKAL80ETC concert') {
|
if (name == 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.quality > 0) {
|
if (quality > 0) {
|
||||||
return item.quality - 1
|
return quality - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
return item.quality
|
return quality
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user