Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 47 additions & 2 deletions app/gilded-rose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class GildedRose {
this.items = items;
}

updateQuality() {
/*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 (this.items[i].quality > 0) {
Expand Down Expand Up @@ -65,5 +65,50 @@ export class GildedRose {
}

return this.items;
}*/

updateQuality() {
for (let i = 0; i < this.items.length; i++) {
//first we will tacke the Sulfuras special item, as is not modified in any way
if(this.items[i].name == 'Sulfuras, Hand of Ragnaros') {
continue;

} else if (this.items[i].name == 'Aged Brie' || this.items[i].name == 'Backstage passes to a TAFKAL80ETC concert'){
//modify items that increase in quality
if(this.items[i].name == 'Aged Brie')
this.items[i].quality = Math.min(50, this.items[i].quality + 1);
else {
if(this.items[i].sellIn > 10)
this.items[i].quality ++;

else if (this.items[i].sellIn > 5 && this.items[i].sellIn <= 10)
this.items[i].quality = Math.min(50, this.items[i].quality + 2);

else if (this.items[i]. sellIn > 0 && this.items[i].sellIn <= 5)
this.items[i].quality = Math.min(50, this.items[i].quality + 3);

else
this.items[i].quality = 0;
}
this.items[i].sellIn --;

} else if (this.items[i].name.includes("Conjured")) {
//modify items that are conjured
if(this.items[i].sellIn > 0)
this.items[i].quality = Math.max(0, this.items[i].quality - 2);
else
this.items[i].quality = Math.max(0, this.items[i].quality - 4);
this.items[i].sellIn --;

} else {
//modify normal items
if(this.items[i].sellIn > 0)
this.items[i].quality = Math.max(0, this.items[i].quality - 1);
else
this.items[i].quality = Math.max(0, this.items[i].quality - 2);
this.items[i].sellIn --;
}
}
}
return this.items;
}
}
Loading