mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +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()
|
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"
|
when "Backstage passes to a TAFKAL80ETC concert"
|
||||||
item.quality = item.quality - 1
|
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
|
||||||
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
|
else
|
||||||
if item.quality < 50
|
item.sell_in -= 1
|
||||||
item.quality = item.quality + 1
|
if item.quality > 0
|
||||||
if item.name == "Backstage passes to a TAFKAL80ETC concert"
|
item.quality -= 1
|
||||||
if item.sell_in < 11
|
item.quality -= 1 if item.sell_in < 0
|
||||||
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
|
||||||
end
|
end
|
||||||
if item.name != "Sulfuras, Hand of Ragnaros"
|
if item.quality < 0
|
||||||
item.sell_in = item.sell_in - 1
|
item.quality = 0
|
||||||
end
|
end
|
||||||
if item.sell_in < 0
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user