diff --git a/TypeScript/app/constants.ts b/TypeScript/app/constants.ts new file mode 100644 index 00000000..a14863a0 --- /dev/null +++ b/TypeScript/app/constants.ts @@ -0,0 +1,11 @@ + +/* + A const to hold the names of the items +*/ +const ItemNames = { + AGED_BRIE: "Aged Brie", + BACKSTAGE_PASSES: "Backstage passes to a TAFKAL80ETC concert", + SULFURAS: "Sulfuras, Hand of Ragnaros", +}; + +export { ItemNames }; diff --git a/TypeScript/app/gilded-rose.ts b/TypeScript/app/gilded-rose.ts index eefe023e..dcfb43ef 100644 --- a/TypeScript/app/gilded-rose.ts +++ b/TypeScript/app/gilded-rose.ts @@ -1,3 +1,6 @@ +import { ItemNames } from "./constants"; + + export class Item { name: string; sellIn: number; @@ -19,46 +22,49 @@ export class GildedRose { updateQuality() { for (const item of this.items) { - if (item.name != 'Aged Brie' && item.name != 'Backstage passes to a TAFKAL80ETC concert') { + if ( + item.name != ItemNames.AGED_BRIE && + item.name != ItemNames.BACKSTAGE_PASSES + ) { if (item.quality > 0) { - if (item.name != 'Sulfuras, Hand of Ragnaros') { - item.quality = item.quality - 1 + if (item.name != ItemNames.SULFURAS) { + item.quality = item.quality - 1; } } } else { if (item.quality < 50) { - item.quality = item.quality + 1 - if (item.name == 'Backstage passes to a TAFKAL80ETC concert') { + item.quality = item.quality + 1; + if (item.name == ItemNames.BACKSTAGE_PASSES) { if (item.sellIn < 11) { if (item.quality < 50) { - item.quality = item.quality + 1 + item.quality = item.quality + 1; } } if (item.sellIn < 6) { if (item.quality < 50) { - item.quality = item.quality + 1 + item.quality = item.quality + 1; } } } } } - if (item.name != 'Sulfuras, Hand of Ragnaros') { + if (item.name != ItemNames.SULFURAS) { item.sellIn = item.sellIn - 1; } if (item.sellIn < 0) { - if (item.name != 'Aged Brie') { - if (item.name != 'Backstage passes to a TAFKAL80ETC concert') { + if (item.name != ItemNames.AGED_BRIE) { + if (item.name != ItemNames.BACKSTAGE_PASSES) { if (item.quality > 0) { - if (item.name != 'Sulfuras, Hand of Ragnaros') { - item.quality = item.quality - 1 + if (item.name != ItemNames.SULFURAS) { + item.quality = item.quality - 1; } } } else { - item.quality = item.quality - item.quality + item.quality = item.quality - item.quality; } } else { if (item.quality < 50) { - item.quality = item.quality + 1 + item.quality = item.quality + 1; } } }