mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
Flatten conditionals in sellInBelow0
This commit is contained in:
parent
e734b35f3a
commit
2cd5a72201
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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]
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user