From 9b2c97532e68ade941b4d7126c74b3304f3d1849 Mon Sep 17 00:00:00 2001 From: Sandrine Mang'ong'o Malanga Date: Wed, 18 Oct 2023 12:31:07 +0300 Subject: [PATCH] changes --- TypeScript/app/gilded-rose.ts | 28 +++++++++++++++------- TypeScript/test/golden-master-text-test.ts | 2 +- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/TypeScript/app/gilded-rose.ts b/TypeScript/app/gilded-rose.ts index ac028473..82ef130e 100644 --- a/TypeScript/app/gilded-rose.ts +++ b/TypeScript/app/gilded-rose.ts @@ -21,6 +21,21 @@ export class GildedRose { updateQuality() { for (let i = 0; i < this.items.length; i++) { + if (this.items[i].name == 'Elixir of the Mongoose'){ + this.items[i].sellIn = this.items[i].sellIn - 1; + } + + if (this.items[i].name == '+5 Dexterity Vest'){ + this.items[i].sellIn = this.items[i].sellIn -1; + } + // Check if item name is "Conjured Mana Cake" + if (this.items[i].name == 'Conjured Mana Cake') { + console.log('Conjured Mana Cake'); + + this.items[i].quality = this.items[i].quality - 2; + this.items[i].sellIn = this.items[i].sellIn - 1; + } + // 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) { @@ -45,13 +60,13 @@ export class GildedRose { } else if (this.items[i].sellIn < 11) { this.items[i].quality = this.items[i].quality + 2 } + if (this.items[i].quality > 50){ + this.items[i].quality = 50; + } } } } - // 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; } @@ -75,13 +90,10 @@ export class GildedRose { } } - console.log(this.items) + // console.log(this.items) return this.items; } - checkSellInDate() { - - } } diff --git a/TypeScript/test/golden-master-text-test.ts b/TypeScript/test/golden-master-text-test.ts index c7d5c90d..2259b975 100644 --- a/TypeScript/test/golden-master-text-test.ts +++ b/TypeScript/test/golden-master-text-test.ts @@ -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, 30), + new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), // this conjured item does not work properly yet new Item("Conjured Mana Cake", 3, 6)];