diff --git a/js-jest/package.json b/js-jest/package.json index 5c01eba7..038edadf 100644 --- a/js-jest/package.json +++ b/js-jest/package.json @@ -3,8 +3,8 @@ "version": "1.0.0", "description": "Gilded Rose kata in JavaScript with Jest", "engines": { - "node": ">=12.18.0", - "npm": ">=6.14.8" + "node": ">=10.16.0", + "npm": ">=6.14.5" }, "scripts": { "start": "babel-node ./test/texttest_fixture.js", diff --git a/js-jest/src/gilded_rose.js b/js-jest/src/gilded_rose.js index ea507a32..9ce8a4e5 100644 --- a/js-jest/src/gilded_rose.js +++ b/js-jest/src/gilded_rose.js @@ -1,6 +1,7 @@ const AGED_CHEESE = ['Aged Brie'] const CONCERT_PASS = ['Backstage passes to a TAFKAL80ETC concert'] const LEGENDARY_ITEMS = ['Sulfuras, Hand of Ragnaros'] +const CONJURED_ITEMS = ['Conjured Mana Cake'] /** * "(...) do not alter the Item class or Items property as those belong to the goblin in the corner @@ -142,6 +143,15 @@ export class LegendaryItem extends RegularItem { updateQuality () {} } +export class ConjuredItem extends RegularItem { + constructor (itemProps) { + super(itemProps) + + // "Conjured" items degrade in Quality twice as fast as normal items + this.depreciationRate = 2 + } +} + export class Shop { constructor (items = []) { /* @@ -225,11 +235,20 @@ export class ShopV2 extends Shop { // Special Items if (LEGENDARY_ITEMS.indexOf(name) !== -1) { ItemClass = LegendaryItem - } else if (AGED_CHEESE.indexOf(name) !== -1) { + } + + if (AGED_CHEESE.indexOf(name) !== -1) { ItemClass = AgedCheese - } else if (CONCERT_PASS.indexOf(name) !== -1) { + } + + if (CONCERT_PASS.indexOf(name) !== -1) { ItemClass = ConcertPass } + + if (CONJURED_ITEMS.indexOf(name) !== -1) { + ItemClass = ConjuredItem + } + return new ItemClass({ name, sellIn, quality }) })