mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
Extract logic for aged brie
This commit is contained in:
parent
11042aa5de
commit
65f7a1f0db
@ -13,24 +13,18 @@ class Shop {
|
|||||||
|
|
||||||
_updateItemQuality(item) {
|
_updateItemQuality(item) {
|
||||||
if (item.name == 'Backstage passes to a TAFKAL80ETC concert') {
|
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 {
|
} else {
|
||||||
if (item.name != 'Aged Brie') {
|
|
||||||
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
||||||
item.quality = item.quality - 1;
|
item.quality = item.quality - 1;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
item.quality = item.quality + 1;
|
|
||||||
}
|
|
||||||
this._updateSellIn(item)
|
this._updateSellIn(item)
|
||||||
if (item.sellIn < 0) {
|
if (item.sellIn < 0) {
|
||||||
if (item.name != 'Aged Brie') {
|
|
||||||
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
||||||
item.quality = item.quality - 1;
|
item.quality = item.quality - 1;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
item.quality = item.quality + 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._checkMaxQuality(item);
|
this._checkMaxQuality(item);
|
||||||
@ -49,6 +43,14 @@ class Shop {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_updateQualityAgedBrie(item) {
|
||||||
|
if (item.sellIn < 0) {
|
||||||
|
item.quality += 2;
|
||||||
|
} else {
|
||||||
|
item.quality += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_updateSellIn(item) {
|
_updateSellIn(item) {
|
||||||
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
||||||
item.sellIn = item.sellIn - 1;
|
item.sellIn = item.sellIn - 1;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user