diff --git a/TypeScript/app/gilded-rose.ts b/TypeScript/app/gilded-rose.ts index 72ccdd01..0b097e6a 100644 --- a/TypeScript/app/gilded-rose.ts +++ b/TypeScript/app/gilded-rose.ts @@ -20,21 +20,7 @@ export class GildedRose { updateQuality() { this.items.forEach((item, i) => { if (item.name == 'Aged Brie' || item.name == 'Backstage passes to a TAFKAL80ETC concert') { - 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 - } - } - } - } + brieOrBackstageQuality(item); } else { if (item.quality > 0) { if (item.name != 'Sulfuras, Hand of Ragnaros') { @@ -49,6 +35,24 @@ export class GildedRose { }) 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; + } + } + } + } + } } }