diff --git a/TypeScript/app/gilded-rose.ts b/TypeScript/app/gilded-rose.ts index 2e05d03f..6a71233b 100644 --- a/TypeScript/app/gilded-rose.ts +++ b/TypeScript/app/gilded-rose.ts @@ -10,7 +10,7 @@ export class Item { this.quality = quality; } } - +// class that creates an array where items will be stored export class GildedRose { items: Array; @@ -18,6 +18,7 @@ export class GildedRose { this.items = items; } + // Method for updating item quality 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') { @@ -31,10 +32,12 @@ export class GildedRose { this.items[i].quality = this.items[i].quality + 1 if (this.items[i].name == 'Backstage passes to a TAFKAL80ETC concert') { if (this.items[i].sellIn < 11) { + // quality goes up by 2 when days are 10 or less if (this.items[i].quality < 50) { this.items[i].quality = this.items[i].quality + 1 } } + // quality goes up by 3 when days are 5 of less if (this.items[i].sellIn < 6) { if (this.items[i].quality < 50) { this.items[i].quality = this.items[i].quality + 1 @@ -43,20 +46,25 @@ export class GildedRose { } } } + // checking for legendary to subtract sell by date if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') { 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].quality > 0) { + // move this if above line 57 if if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') { this.items[i].quality = this.items[i].quality - 1 } } + } else { this.items[i].quality = this.items[i].quality - this.items[i].quality } + // aged brie increases in quality here } else { if (this.items[i].quality < 50) { this.items[i].quality = this.items[i].quality + 1