mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 22:41:30 +00:00
Update gilded_rose.rb
- Added new item category "Conjured" - refactor update qwality function
This commit is contained in:
parent
e43a1a270f
commit
f6454c0eb9
@ -6,44 +6,43 @@ 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"
|
|
||||||
|
if item.name != "Aged Brie" && item.name != "Backstage passes to a TAFKAL80ETC concert"
|
||||||
if item.quality > 0
|
if item.quality > 0
|
||||||
if item.name != "Sulfuras, Hand of Ragnaros"
|
if item.name != "Sulfuras, Hand of Ragnaros"
|
||||||
item.quality = item.quality - 1
|
item.quality = item.quality - 1
|
||||||
end
|
if item.name == "Conjured"
|
||||||
end
|
if item.quality > 0
|
||||||
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
|
|
||||||
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
|
item.quality = item.quality - 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
|
||||||
item.quality = item.quality - item.quality
|
|
||||||
end
|
end
|
||||||
else
|
|
||||||
|
end
|
||||||
|
else
|
||||||
|
handle_qwality(item)
|
||||||
|
end
|
||||||
|
|
||||||
|
if item.name != "Sulfuras, Hand of Ragnaros"
|
||||||
|
item.sell_in = item.sell_in - 1
|
||||||
|
end
|
||||||
|
|
||||||
|
update_sell_in(item)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def handle_qwality(item)
|
||||||
|
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
|
if item.quality < 50
|
||||||
item.quality = item.quality + 1
|
item.quality = item.quality + 1
|
||||||
end
|
end
|
||||||
@ -51,8 +50,29 @@ class GildedRose
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_sell_in(item)
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
class Item
|
class Item
|
||||||
attr_accessor :name, :sell_in, :quality
|
attr_accessor :name, :sell_in, :quality
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user