mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
Extract item checks
This commit is contained in:
parent
034fa890cf
commit
164bea88fb
@ -19,16 +19,28 @@ class Shop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_updateItemQuality(item) {
|
_updateItemQuality(item) {
|
||||||
if (item.name == 'Backstage passes to a TAFKAL80ETC concert') {
|
if (this._isBackstagePass(item)) {
|
||||||
this._updateQualityBackstagePass(item);
|
this._updateQualityBackstagePass(item);
|
||||||
} else if (item.name == 'Aged Brie') {
|
} else if (this._isAgedBrie(item)) {
|
||||||
this._updateQualityAgedBrie(item);
|
this._updateQualityAgedBrie(item);
|
||||||
} else if (item.name == 'Sulfuras, Hand of Ragnaros') {
|
} else if (this._isSulfuras(item)) {
|
||||||
} else {
|
} else {
|
||||||
this._updateQualityStandard(item)
|
this._updateQualityStandard(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_isBackstagePass(item) {
|
||||||
|
return item.name.toLowerCase().match(/backstage pass/);
|
||||||
|
}
|
||||||
|
|
||||||
|
_isAgedBrie(item) {
|
||||||
|
return item.name.toLowerCase().match(/aged brie/);
|
||||||
|
}
|
||||||
|
|
||||||
|
_isSulfuras(item) {
|
||||||
|
return item.name.toLowerCase().match(/sulfuras/);
|
||||||
|
}
|
||||||
|
|
||||||
_updateQualityStandard(item) {
|
_updateQualityStandard(item) {
|
||||||
if (item.sellIn <= 0) {
|
if (item.sellIn <= 0) {
|
||||||
item.quality -= 2;
|
item.quality -= 2;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user