Flatten conditionals in sellInBelow0

This commit is contained in:
Jesper 2022-04-13 16:31:16 +02:00
parent e734b35f3a
commit 2cd5a72201
2 changed files with 15 additions and 12 deletions

View File

@ -54,20 +54,23 @@ export class GildedRose {
}
private sellInBelow0(item: Item) {
if (item.name != 'Aged Brie') {
if (item.name != 'Backstage passes to a TAFKAL80ETC concert') {
if (item.quality > 0) {
if (item.name != 'Sulfuras, Hand of Ragnaros') {
item.quality = item.quality - 1;
}
}
} else {
item.quality = item.quality - item.quality;
}
} else {
if (item.name == 'Sulfuras, Hand of Ragnaros') return
if (item.name == 'Aged Brie') {
if (item.quality < 50) {
item.quality = item.quality + 1;
}
return
}
if (item.name == 'Backstage passes to a TAFKAL80ETC concert') {
item.quality = item.quality - item.quality;
return
}
if (item.quality > 0) {
item.quality = item.quality - 1;
return
}
}
}

View File

@ -62,7 +62,7 @@ export class AcceptanceGildedRose {
}
test('acceptance tests', () => {
const names = ['Aged Brie', 'Backstage passes to a TAFKAL80ETC concert', 'Sulfuras, Hand of Ragnaros']
const names = ['Aged Brie', 'Backstage passes to a TAFKAL80ETC concert', 'Sulfuras, Hand of Ragnaros', 'Other']
const sellIns = [-1, 0, 1, 2, 5, 6, 7, 10, 11, 12, 13, 14, 15]
const qualities = [-1, 1, 2, 48, 49, 50, 51]