diff --git a/TypeScript/app/gilded-rose.ts b/TypeScript/app/gilded-rose.ts index 8ca32149..06fa865f 100644 --- a/TypeScript/app/gilded-rose.ts +++ b/TypeScript/app/gilded-rose.ts @@ -1,3 +1,4 @@ +import { assert } from "console"; import { ItemNames, MAX_ITEM_QUALITY } from "./constants"; export class Item { @@ -20,47 +21,15 @@ export class GildedRose { } private updateAgedBrieItem(item: Item) { - if ( - item.name != ItemNames.AGED_BRIE && - item.name != ItemNames.BACKSTAGE_PASSES - ) { - if (item.quality > 0) { - if (item.name != ItemNames.SULFURAS) { - item.quality = item.quality - 1; - } - } - } else if (item.quality < MAX_ITEM_QUALITY) { + assert(item.name == ItemNames.AGED_BRIE); + if (item.quality < MAX_ITEM_QUALITY) { item.quality = item.quality + 1; - if (item.name == ItemNames.BACKSTAGE_PASSES) { - if (item.sellIn < 11) { - if (item.quality < MAX_ITEM_QUALITY) { - item.quality = item.quality + 1; - } - } - if (item.sellIn < 6) { - if (item.quality < MAX_ITEM_QUALITY) { - item.quality = item.quality + 1; - } - } - } } if (item.name != ItemNames.SULFURAS) { item.sellIn = item.sellIn - 1; } - if (item.sellIn < 0) { - if (item.name != ItemNames.AGED_BRIE) { - if (item.name != ItemNames.BACKSTAGE_PASSES) { - if (item.quality > 0) { - if (item.name != ItemNames.SULFURAS) { - item.quality = item.quality - 1; - } - } - } else { - item.quality = 0; - } - } else if (item.quality < MAX_ITEM_QUALITY) { - item.quality = item.quality + 1; - } + if (item.sellIn < 0 && item.quality < MAX_ITEM_QUALITY) { + item.quality = item.quality + 1; } }