Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omar/gilded rose refactor #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 26 additions & 33 deletions gilded_rose.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,42 @@ def initialize(items)

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 "Backstage passes to a TAFKAL80ETC concert"
if item.quality < 50
item.quality += 1
if item.sell_in < 6 && item.quality < 50
item.quality += 2
elsif item.sell_in < 11 && item.quality < 50
item.quality += 1
end
end
else
if item.sell_in < 1
item.quality = 0
end
when "Aged Brie"
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
when "Sulfuras, Hand of Ragnaros"
when "Conjured Item"
if item.quality > 0
item.quality = item.quality - 2
if item.sell_in < 0 && item.quality > 0
item.quality = item.quality - 2
end
end
else
if item.quality > 0
item.quality = item.quality - 1
if item.sell_in < 0 && item.quality > 0
item.quality = item.quality - 1
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
else
if item.quality < 50
item.quality = item.quality + 1
end
end
end
end
end
end
Expand Down