Extract logic for aged brie

This commit is contained in:
Dan Holmes 2020-12-03 14:53:07 +00:00
parent 11042aa5de
commit 65f7a1f0db

View File

@ -13,23 +13,17 @@ class Shop {
_updateItemQuality(item) {
if (item.name == 'Backstage passes to a TAFKAL80ETC concert') {
this._updateQualityBackstagePass(item)
this._updateQualityBackstagePass(item);
} else if (item.name == 'Aged Brie') {
this._updateQualityAgedBrie(item);
} else {
if (item.name != 'Aged Brie') {
if (item.name != 'Sulfuras, Hand of Ragnaros') {
item.quality = item.quality - 1;
}
} else {
item.quality = item.quality + 1;
if (item.name != 'Sulfuras, Hand of Ragnaros') {
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;
if (item.name != 'Sulfuras, Hand of Ragnaros') {
item.quality = item.quality - 1;
}
}
}
@ -49,6 +43,14 @@ class Shop {
}
}
_updateQualityAgedBrie(item) {
if (item.sellIn < 0) {
item.quality += 2;
} else {
item.quality += 1;
}
}
_updateSellIn(item) {
if (item.name != 'Sulfuras, Hand of Ragnaros') {
item.sellIn = item.sellIn - 1;