mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 06:21:29 +00:00
Extract backstage pass logic
This commit is contained in:
parent
9eb17f67da
commit
11042aa5de
@ -12,39 +12,43 @@ class Shop {
|
||||
}
|
||||
|
||||
_updateItemQuality(item) {
|
||||
if (item.name != 'Aged Brie' && item.name != 'Backstage passes to a TAFKAL80ETC concert') {
|
||||
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
||||
item.quality = item.quality - 1;
|
||||
}
|
||||
if (item.name == 'Backstage passes to a TAFKAL80ETC concert') {
|
||||
this._updateQualityBackstagePass(item)
|
||||
} else {
|
||||
item.quality = item.quality + 1;
|
||||
if (item.name == 'Backstage passes to a TAFKAL80ETC concert') {
|
||||
if (item.sellIn < 11) {
|
||||
item.quality = item.quality + 1;
|
||||
}
|
||||
if (item.sellIn < 6) {
|
||||
item.quality = item.quality + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
this._updateSellIn(item)
|
||||
if (item.sellIn < 0) {
|
||||
if (item.name != 'Aged Brie') {
|
||||
if (item.name != 'Backstage passes to a TAFKAL80ETC concert') {
|
||||
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
||||
item.quality = item.quality - 1;
|
||||
}
|
||||
} else {
|
||||
item.quality = item.quality - item.quality;
|
||||
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
||||
item.quality = item.quality - 1;
|
||||
}
|
||||
} else {
|
||||
item.quality = item.quality + 1;
|
||||
}
|
||||
this._updateSellIn(item)
|
||||
if (item.sellIn < 0) {
|
||||
if (item.name != 'Aged Brie') {
|
||||
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
||||
item.quality = item.quality - 1;
|
||||
}
|
||||
} else {
|
||||
item.quality = item.quality + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
this._checkMaxQuality(item);
|
||||
this._checkMinQuality(item);
|
||||
}
|
||||
|
||||
_updateQualityBackstagePass(item) {
|
||||
if (item.sellIn <= 0) {
|
||||
item.quality = 0;
|
||||
} else if (item.sellIn < 6) {
|
||||
item.quality += 3;
|
||||
} else if (item.sellIn < 11) {
|
||||
item.quality += 2;
|
||||
} else {
|
||||
item.quality += 1;
|
||||
}
|
||||
}
|
||||
|
||||
_updateSellIn(item) {
|
||||
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
||||
item.sellIn = item.sellIn - 1;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user