From ef3085920e50e67f3dcf2576fa29cbd4884c6b23 Mon Sep 17 00:00:00 2001 From: Ben Hemann Date: Fri, 4 Jun 2021 16:58:20 -0500 Subject: [PATCH] added comments on gilded-rose.ts file --- TypeScript/app/gilded-rose.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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