cleaned up updateBackstagePassesItem method

asserted ItemNames.BACKSTAGE_PASSES
This commit is contained in:
Chamoda Ranasinghe 2024-01-16 03:33:11 +07:00
parent 98b400604e
commit 7577596171
No known key found for this signature in database
GPG Key ID: DE81C3C335B7CED3

View File

@ -34,27 +34,15 @@ export class GildedRose {
} }
private updateBackstagePassesItem(item: Item) { private updateBackstagePassesItem(item: Item) {
if ( assert(item.name == ItemNames.BACKSTAGE_PASSES);
item.name != ItemNames.AGED_BRIE && if (item.quality < MAX_ITEM_QUALITY) {
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) {
item.quality = item.quality + 1; item.quality = item.quality + 1;
if (item.name == ItemNames.BACKSTAGE_PASSES) { if (item.name == ItemNames.BACKSTAGE_PASSES && item.sellIn < 11) {
if (item.sellIn < 11) { if (item.sellIn < 11 && item.quality < MAX_ITEM_QUALITY) {
if (item.quality < MAX_ITEM_QUALITY) { item.quality = item.quality + 1;
item.quality = item.quality + 1;
}
} }
if (item.sellIn < 6) { if (item.sellIn < 6 && item.quality < MAX_ITEM_QUALITY) {
if (item.quality < MAX_ITEM_QUALITY) { item.quality = item.quality + 1;
item.quality = item.quality + 1;
}
} }
} }
} }
@ -62,19 +50,7 @@ export class GildedRose {
item.sellIn = item.sellIn - 1; item.sellIn = item.sellIn - 1;
} }
if (item.sellIn < 0) { if (item.sellIn < 0) {
if (item.name != ItemNames.AGED_BRIE) { item.quality = 0;
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;
}
} }
} }