mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
update tests and code for new conjured requirements
This commit is contained in:
parent
080b998176
commit
0d24f3ed98
@ -81,6 +81,20 @@ func UpdateQualityStandard(item *Item) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UpdateQualityConjured(item *Item) {
|
||||||
|
defer func() {
|
||||||
|
item.sellIn--
|
||||||
|
}()
|
||||||
|
|
||||||
|
if item.sellIn <= 0 {
|
||||||
|
item.quality = max(item.quality-4, 0)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
item.quality = max(item.quality-2, 0)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func UpdateQuality(items []*Item) {
|
func UpdateQuality(items []*Item) {
|
||||||
for i := 0; i < len(items); i++ {
|
for i := 0; i < len(items); i++ {
|
||||||
|
|
||||||
@ -90,6 +104,8 @@ func UpdateQuality(items []*Item) {
|
|||||||
UpdateQualityBrie(items[i])
|
UpdateQualityBrie(items[i])
|
||||||
case "Backstage passes to a TAFKAL80ETC concert":
|
case "Backstage passes to a TAFKAL80ETC concert":
|
||||||
UpdateQualityBackstagePasses(items[i])
|
UpdateQualityBackstagePasses(items[i])
|
||||||
|
case "Conjured Mana Cake":
|
||||||
|
UpdateQualityConjured(items[i])
|
||||||
default:
|
default:
|
||||||
UpdateQualityStandard(items[i])
|
UpdateQualityStandard(items[i])
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,7 +30,9 @@ func Test_Items(t *testing.T) {
|
|||||||
{&Item{"Backstage passes to a TAFKAL80ETC concert", 4, 4}, Expected{3, 7}},
|
{&Item{"Backstage passes to a TAFKAL80ETC concert", 4, 4}, Expected{3, 7}},
|
||||||
{&Item{"Backstage passes to a TAFKAL80ETC concert", 9, 4}, Expected{8, 6}},
|
{&Item{"Backstage passes to a TAFKAL80ETC concert", 9, 4}, Expected{8, 6}},
|
||||||
{&Item{"Sulfuras, Hand of Ragnaros", 0, 80}, Expected{0, 80}},
|
{&Item{"Sulfuras, Hand of Ragnaros", 0, 80}, Expected{0, 80}},
|
||||||
{&Item{"Conjured Mana Cake", 3, 6}, Expected{2, 5}},
|
{&Item{"Conjured Mana Cake", 3, 6}, Expected{2, 4}},
|
||||||
|
{&Item{"Conjured Mana Cake", 0, 8}, Expected{-1, 4}},
|
||||||
|
{&Item{"Conjured Mana Cake", 3, 0}, Expected{2, 0}},
|
||||||
{&Item{"Acme Dynamite", 3, 6}, Expected{2, 5}},
|
{&Item{"Acme Dynamite", 3, 6}, Expected{2, 5}},
|
||||||
{&Item{"Acme Dynamite", 0, 6}, Expected{-1, 4}},
|
{&Item{"Acme Dynamite", 0, 6}, Expected{-1, 4}},
|
||||||
{&Item{"Acme Dynamite", 0, 0}, Expected{-1, 0}},
|
{&Item{"Acme Dynamite", 0, 0}, Expected{-1, 0}},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user