Extract the first item case: "Sulfuras"

This commit is contained in:
Maarten Parmentier 2023-06-27 19:47:49 +02:00
parent f0204a4b1e
commit 6d4bc3f8af

View File

@ -4,14 +4,16 @@ class GildedRose
@items = items @items = items
end end
def update_quality() def update_quality
@items.each do |item| @items.each do |item|
case item.name
when 'Sulfuras, Hand of Ragnaros'
update_sulfuras_quality(item)
else
if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert" if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert"
if item.quality > 0 if item.quality > 0
if item.name != "Sulfuras, Hand of Ragnaros"
item.quality = item.quality - 1 item.quality = item.quality - 1
end end
end
else else
if item.quality < 50 if item.quality < 50
item.quality = item.quality + 1 item.quality = item.quality + 1
@ -29,17 +31,13 @@ class GildedRose
end end
end end
end end
if item.name != "Sulfuras, Hand of Ragnaros"
item.sell_in = item.sell_in - 1 item.sell_in = item.sell_in - 1
end
if item.sell_in < 0 if item.sell_in < 0
if item.name != "Aged Brie" if item.name != "Aged Brie"
if item.name != "Backstage passes to a TAFKAL80ETC concert" if item.name != "Backstage passes to a TAFKAL80ETC concert"
if item.quality > 0 if item.quality > 0
if item.name != "Sulfuras, Hand of Ragnaros"
item.quality = item.quality - 1 item.quality = item.quality - 1
end end
end
else else
item.quality = item.quality - item.quality item.quality = item.quality - item.quality
end end
@ -51,6 +49,9 @@ class GildedRose
end end
end end
end end
end
def update_sulfuras_quality(item); end
end end
class Item class Item