diff --git a/TypeScript/app/gilded-rose.ts b/TypeScript/app/gilded-rose.ts index db58d678..a00c5641 100644 --- a/TypeScript/app/gilded-rose.ts +++ b/TypeScript/app/gilded-rose.ts @@ -1,3 +1,5 @@ +import CNST from "./util/constants"; + export class Item { name: string; sellIn: number; @@ -19,46 +21,47 @@ export class GildedRose { updateQuality() { for (let i = 0; i < this.items.length; i++) { - if (this.items[i].name != 'Aged Brie' && this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert') { + if ([CNST.AGED_BRIE, CNST.BCST_TAF].includes(this.items[i].name)) { if (this.items[i].quality > 0) { - if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') { - this.items[i].quality = this.items[i].quality - 1 + if (this.items[i].name != CNST.SULFURAS) { + this.items[i].quality = this.items[i].quality - 1; } } } else { if (this.items[i].quality < 50) { - this.items[i].quality = this.items[i].quality + 1 - if (this.items[i].name == 'Backstage passes to a TAFKAL80ETC concert') { + this.items[i].quality = this.items[i].quality + 1; + if (this.items[i].name == CNST.BCST_TAF) { if (this.items[i].sellIn < 11) { if (this.items[i].quality < 50) { - this.items[i].quality = this.items[i].quality + 1 + this.items[i].quality = this.items[i].quality + 1; } } if (this.items[i].sellIn < 6) { if (this.items[i].quality < 50) { - this.items[i].quality = this.items[i].quality + 1 + this.items[i].quality = this.items[i].quality + 1; } } } } } - if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') { + if (this.items[i].name != CNST.SULFURAS) { this.items[i].sellIn = this.items[i].sellIn - 1; } if (this.items[i].sellIn < 0) { - if (this.items[i].name != 'Aged Brie') { - if (this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert') { + if (this.items[i].name != CNST.AGED_BRIE) { + if (this.items[i].name != CNST.BCST_TAF) { if (this.items[i].quality > 0) { - if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') { - this.items[i].quality = this.items[i].quality - 1 + if (this.items[i].name != CNST.SULFURAS) { + this.items[i].quality = this.items[i].quality - 1; } } } else { - this.items[i].quality = this.items[i].quality - this.items[i].quality + this.items[i].quality = + this.items[i].quality - this.items[i].quality; } } else { if (this.items[i].quality < 50) { - this.items[i].quality = this.items[i].quality + 1 + this.items[i].quality = this.items[i].quality + 1; } } } diff --git a/TypeScript/app/util/constants.ts b/TypeScript/app/util/constants.ts new file mode 100644 index 00000000..f844fc22 --- /dev/null +++ b/TypeScript/app/util/constants.ts @@ -0,0 +1,6 @@ +const AGED_BRIE = "Aged Brie"; +const BCST_TAF = "Backstage passes to a TAFKAL80ETC concert"; +const SULFURAS = "Sulfuras, Hand of Ragnaros"; +const SULFURAS_HAND = "Sulfuras, Hand of Ragnaros"; + +export default { AGED_BRIE, BCST_TAF, SULFURAS, SULFURAS_HAND };