mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 22:41:30 +00:00
refactor v1
This commit is contained in:
parent
a513926866
commit
10dc87ecc8
2
ruby/.bundle/config
Normal file
2
ruby/.bundle/config
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
BUNDLE_BIN: "bin"
|
||||
@ -6,50 +6,40 @@ class GildedRose
|
||||
|
||||
def update_quality()
|
||||
@items.each do |item|
|
||||
if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert"
|
||||
if item.quality > 0
|
||||
if item.name != "Sulfuras, Hand of Ragnaros"
|
||||
item.quality = item.quality - 1
|
||||
case item.name
|
||||
when "Sulfuras, Hand of Ragnaros"
|
||||
when "Backstage passes to a TAFKAL80ETC concert"
|
||||
item.quality += 1 if item.sell_in > 10
|
||||
item.quality += 2 if item.sell_in <= 10 and item.sell_in > 5
|
||||
item.quality += 3 if item.sell_in <= 5
|
||||
item.sell_in -= 1
|
||||
item.quality = 0 if item.sell_in < 0
|
||||
when "Aged Brie"
|
||||
item.sell_in -= 1
|
||||
if item.quality < 50
|
||||
if item.sell_in < 0
|
||||
item.quality += 2
|
||||
else
|
||||
item.quality += 1
|
||||
end
|
||||
end
|
||||
when /Conjured/
|
||||
item.sell_in -= 1
|
||||
if item.quality > 0
|
||||
item.quality -= 2
|
||||
item.quality -= 2 if item.sell_in < 0
|
||||
end
|
||||
else
|
||||
if item.quality < 50
|
||||
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
|
||||
item.sell_in -= 1
|
||||
if item.quality > 0
|
||||
item.quality -= 1
|
||||
item.quality -= 1 if item.sell_in < 0
|
||||
end
|
||||
end
|
||||
if item.name != "Sulfuras, Hand of Ragnaros"
|
||||
item.sell_in = item.sell_in - 1
|
||||
if item.quality < 0
|
||||
item.quality = 0
|
||||
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
|
||||
else
|
||||
if item.quality < 50
|
||||
item.quality = item.quality + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user