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
57 changes: 31 additions & 26 deletions app/gilded-rose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,51 +17,56 @@ export class GildedRose {
this.items = items;
}


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) {
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
this.items[i].quality = this.items[i].quality - 1
}
}

let itemName = this.items[i].name;
let itemQuality = this.items[i].quality;
let itemSell_in = this.items[i].sellIn;

if (itemName != 'Aged Brie' && itemName != 'Backstage passes to a TAFKAL80ETC concert' && itemName != 'Sulfuras, Hand of Ragnaros') {
itemQuality = itemQuality == 0? 0: itemQuality-1 ;

} else {
if (this.items[i].quality < 50) {
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) {
if (this.items[i].quality < 50) {
this.items[i].quality = this.items[i].quality + 1
if (itemQuality < 50) {
itemQuality += 1
if (itemName == 'Backstage passes to a TAFKAL80ETC concert') {
if (itemSell_in< 11) {
if (itemQuality < 50) {
itemQuality += 1;
}
}
if (this.items[i].sellIn < 6) {
if (this.items[i].quality < 50) {
this.items[i].quality = this.items[i].quality + 1
if (itemSell_in< 6) {
if (itemQuality < 50) {
itemQuality += 1 ;
}
}
}
}
}
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
this.items[i].sellIn = this.items[i].sellIn - 1;
if (itemName != 'Sulfuras, Hand of Ragnaros') {
itemSell_in -= 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) {
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
this.items[i].quality = this.items[i].quality - 1
if (itemSell_in < 0) {
if (itemName != 'Aged Brie') {
if (itemName != 'Backstage passes to a TAFKAL80ETC concert') {
if (itemQuality> 0) {
if (itemName != 'Sulfuras, Hand of Ragnaros') {
itemQuality -= 1;
}
}
} else {
this.items[i].quality = this.items[i].quality - this.items[i].quality
itemQuality = 0;
}
} else {
if (this.items[i].quality < 50) {
this.items[i].quality = this.items[i].quality + 1
if (itemQuality < 50) {
itemQuality += 1
}
}
}
this.items[i].quality = itemQuality;
this.items[i].sellIn = itemSell_in;
}

return this.items;
Expand Down
Loading