<duplicate_code> agrega metodo para decrementar calidad de item

This commit is contained in:
Felipe Gaete 2024-08-18 23:26:37 -04:00
parent 2a5586422c
commit 640daa2382

View File

@ -8,12 +8,16 @@ class GildedRose
item.name != "Sulfuras, Hand of Ragnaros" item.name != "Sulfuras, Hand of Ragnaros"
end end
def decrease_quality(item)
item.quality = item.quality - 1
end
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" and item.name != "Backstage passes to a TAFKAL80ETC concert"
if item.quality > 0 if item.quality > 0
if not_legendary?(item) if not_legendary?(item)
item.quality = item.quality - 1 decrease_quality(item)
end end
end end
else else
@ -41,7 +45,7 @@ class GildedRose
if item.name != "Backstage passes to a TAFKAL80ETC concert" if item.name != "Backstage passes to a TAFKAL80ETC concert"
if item.quality > 0 if item.quality > 0
if not_legendary?(item) if not_legendary?(item)
item.quality = item.quality - 1 decrease_quality(item)
end end
end end
else else