added comments on gilded-rose.ts file

This commit is contained in:
Ben Hemann 2021-06-04 16:58:20 -05:00
parent 9e1b78ef70
commit ef3085920e

View File

@ -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<Item>;
@ -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