mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-18 07:51:29 +00:00
Extract brieOrBackstageQuality
This commit is contained in:
parent
7c81b6d242
commit
2fd34247dd
@ -20,21 +20,7 @@ export class GildedRose {
|
|||||||
updateQuality() {
|
updateQuality() {
|
||||||
this.items.forEach((item, i) => {
|
this.items.forEach((item, i) => {
|
||||||
if (item.name == 'Aged Brie' || item.name == 'Backstage passes to a TAFKAL80ETC concert') {
|
if (item.name == 'Aged Brie' || item.name == 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
if (item.quality < 50) {
|
brieOrBackstageQuality(item);
|
||||||
item.quality = item.quality + 1
|
|
||||||
if (item.name == 'Backstage passes to a TAFKAL80ETC concert') {
|
|
||||||
if (item.sellIn < 11) {
|
|
||||||
if (item.quality < 50) {
|
|
||||||
item.quality = item.quality + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (item.sellIn < 6) {
|
|
||||||
if (item.quality < 50) {
|
|
||||||
item.quality = item.quality + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (item.quality > 0) {
|
if (item.quality > 0) {
|
||||||
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
if (item.name != 'Sulfuras, Hand of Ragnaros') {
|
||||||
@ -49,6 +35,24 @@ export class GildedRose {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return this.items;
|
return this.items;
|
||||||
|
|
||||||
|
function brieOrBackstageQuality(item: Item) {
|
||||||
|
if (item.quality < 50) {
|
||||||
|
item.quality = item.quality + 1;
|
||||||
|
if (item.name == 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
|
if (item.sellIn < 11) {
|
||||||
|
if (item.quality < 50) {
|
||||||
|
item.quality = item.quality + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.sellIn < 6) {
|
||||||
|
if (item.quality < 50) {
|
||||||
|
item.quality = item.quality + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user