mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
Extract the first item case: "Sulfuras"
This commit is contained in:
parent
f0204a4b1e
commit
6d4bc3f8af
@ -4,53 +4,54 @@ class GildedRose
|
|||||||
@items = items
|
@items = items
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_quality()
|
def update_quality
|
||||||
@items.each do |item|
|
@items.each do |item|
|
||||||
if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert"
|
case item.name
|
||||||
if item.quality > 0
|
when 'Sulfuras, Hand of Ragnaros'
|
||||||
if item.name != "Sulfuras, Hand of Ragnaros"
|
update_sulfuras_quality(item)
|
||||||
item.quality = item.quality - 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
if item.quality < 50
|
if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert"
|
||||||
item.quality = item.quality + 1
|
if item.quality > 0
|
||||||
if item.name == "Backstage passes to a TAFKAL80ETC concert"
|
item.quality = item.quality - 1
|
||||||
if item.sell_in < 11
|
|
||||||
if item.quality < 50
|
|
||||||
item.quality = item.quality + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if item.sell_in < 6
|
|
||||||
if item.quality < 50
|
|
||||||
item.quality = item.quality + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if item.name != "Sulfuras, Hand of Ragnaros"
|
|
||||||
item.sell_in = item.sell_in - 1
|
|
||||||
end
|
|
||||||
if item.sell_in < 0
|
|
||||||
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
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
item.quality = item.quality - item.quality
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if item.quality < 50
|
if item.quality < 50
|
||||||
item.quality = item.quality + 1
|
item.quality = item.quality + 1
|
||||||
|
if item.name == "Backstage passes to a TAFKAL80ETC concert"
|
||||||
|
if item.sell_in < 11
|
||||||
|
if item.quality < 50
|
||||||
|
item.quality = item.quality + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if item.sell_in < 6
|
||||||
|
if item.quality < 50
|
||||||
|
item.quality = item.quality + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
item.sell_in = item.sell_in - 1
|
||||||
|
if item.sell_in < 0
|
||||||
|
if item.name != "Aged Brie"
|
||||||
|
if item.name != "Backstage passes to a TAFKAL80ETC concert"
|
||||||
|
if item.quality > 0
|
||||||
|
item.quality = item.quality - 1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
item.quality = item.quality - item.quality
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if item.quality < 50
|
||||||
|
item.quality = item.quality + 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_sulfuras_quality(item); end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Item
|
class Item
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user