Conjured cake now works. Check with client if need it to work for /Conjured .*/

This commit is contained in:
joenelson@maggie 2023-04-04 22:58:47 +01:00
parent 31ba62bf31
commit bcf614e2a0
2 changed files with 33 additions and 0 deletions

View File

@ -37,6 +37,15 @@ class GildedRose
quality: self.regular_quality_limit(next_quality)
}
end,
"Conjured Mana Cake" => Proc.new do |sell_in:, quality:|
next_sell_in = sell_in -1
{
sell_in: next_sell_in,
quality: self.regular_quality_limit(
quality + (next_sell_in < 0 ? -4 : -2)
)
}
end,
}
def self.regular_quality_limit(unsanitized_quality)

View File

@ -122,6 +122,30 @@ describe GildedRose do
expect(items[0].sell_in).to eq 1 # does not change
expect(items[0].quality).to eq 80 # always 80
end
it "degrades conjured cake quickly" do
items = [Item.new("Conjured Mana Cake", 2, 9)]
updater = GildedRose.new(items)
updater.update_quality()
expect(items[0].sell_in).to eq 1
expect(items[0].quality).to eq 7 # degrades twice as fast
updater.update_quality()
expect(items[0].sell_in).to eq 0
expect(items[0].quality).to eq 5 # still above zero
updater.update_quality()
expect(items[0].sell_in).to eq -1
expect(items[0].quality).to eq 1 # still above zero
updater.update_quality()
expect(items[0].sell_in).to eq -2
expect(items[0].quality).to eq 0 # does not go below zero
end
end
end