Fix ruby version

This commit is contained in:
Chris "The Chris" Iriondo 2020-11-11 15:17:54 -07:00
parent 0f2437eeeb
commit a95750265b
2 changed files with 36 additions and 41 deletions

1
ruby/.ruby-version Normal file
View File

@ -0,0 +1 @@
2.5.7

View File

@ -1,54 +1,48 @@
class GildedRose
def initialize(items)
@items = items
end
def update_quality()
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
end
next if item.name == 'Sulfuras, Hand of Ragnaros'
item.sell_in -= 1
quality_change = case item.name
when 'Backstage passes to a TAFKAL80ETC concert'
if item.sell_in.negative?
item.quality = 0
next
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
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
if item.sell_in >= 10
1
elsif item.sell_in >= 5
2
else
if item.quality < 50
item.quality = item.quality + 1
end
3
end
when 'Conjured Mana Cake'
item.sell_in < 0 ? 4 : 2
else
quality_degradation = item.sell_in < 0 ? 2 : 1
quality_degradation *= 2 if item.name.start_with?('Conjured')
quality_degradation
end
new_quality = if [
'Aged Brie',
'Backstage passes to a TAFKAL80ETC concert',
].include?(item.name)
item.quality + quality_change
else
item.quality - quality_change
end
item.quality = [[new_quality, 50].min, 0].max
end
end
end