This commit is contained in:
Sandrine Mang'ong'o Malanga 2023-10-17 18:30:17 +03:00
parent e621073c02
commit 96893e0c79
3 changed files with 423 additions and 388 deletions

View File

@ -1,3 +1,5 @@
import { log } from "console";
export class Item {
name: string;
sellIn: number;
@ -19,51 +21,67 @@ export class GildedRose {
updateQuality() {
for (let i = 0; i < this.items.length; i++) {
// ITEM NAME CHECK
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') {
// Check if item name is not "Sulfuras, Hand of Ragnaros" & "Conjured Mana Cake"
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros' && this.items[i].name != 'Conjured Mana Cake') {
// Decrease item quality by 1
this.items[i].quality = this.items[i].quality - 1
}
}
} else {
// QUALITY CHECK
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 (this.items[i].sellIn < 6) {
if (this.items[i].quality < 50) {
this.items[i].quality = this.items[i].quality + 1
// Increase quality by 1 for 'Aged Brie'
if (this.items[i].name == 'Aged Brie') {
this.items[i].quality = this.items[i].quality + 1;
} else {
// If sellIn date for tickets is less than 11 & quality is less than 50 increase quality
if (this.items[i].name == 'Backstage passes to a TAFKAL80ETC concert') {
if (this.items[i].sellIn < 6) {
this.items[i].quality = this.items[i].quality + 3
} else if (this.items[i].sellIn < 11) {
this.items[i].quality = this.items[i].quality + 2
}
}
}
}
}
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) {
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
this.items[i].quality = this.items[i].quality - 1
// Check if item name is "Conjured Mana Cake"
if (this.items[i].name == 'Conjured Mana Cake') {
this.items[i].quality = this.items[i].quality - 2;
}
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) {
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
}
} else {
this.items[i].quality = this.items[i].quality - this.items[i].quality
}
} else {
if (this.items[i].quality < 50) {
this.items[i].quality = this.items[i].quality + 1
if (this.items[i].quality < 50) {
this.items[i].quality = this.items[i].quality + 1
}
}
}
}
}
}
console.log(this.items)
return this.items;
}
checkSellInDate() {
}
}

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@ const items = [
new Item("Sulfuras, Hand of Ragnaros", -1, 80),
new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20),
new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49),
new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49),
new Item("Backstage passes to a TAFKAL80ETC concert", 5, 30),
// this conjured item does not work properly yet
new Item("Conjured Mana Cake", 3, 6)];