mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-12 12:22:12 +00:00
59 lines
1.4 KiB
Go
59 lines
1.4 KiB
Go
package gildedrose
|
|
|
|
type Item struct {
|
|
Name string
|
|
SellIn, Quality int
|
|
}
|
|
|
|
func UpdateQuality(items []*Item) {
|
|
for i := 0; i < len(items); i++ {
|
|
|
|
if items[i].Name != "Aged Brie" && items[i].Name != "Backstage passes to a TAFKAL80ETC concert" {
|
|
if items[i].Quality > 0 {
|
|
if items[i].Name != "Sulfuras, Hand of Ragnaros" {
|
|
items[i].Quality = items[i].Quality - 1
|
|
}
|
|
}
|
|
} else {
|
|
if items[i].Quality < 50 {
|
|
items[i].Quality = items[i].Quality + 1
|
|
if items[i].Name == "Backstage passes to a TAFKAL80ETC concert" {
|
|
if items[i].SellIn < 11 {
|
|
if items[i].Quality < 50 {
|
|
items[i].Quality = items[i].Quality + 1
|
|
}
|
|
}
|
|
if items[i].SellIn < 6 {
|
|
if items[i].Quality < 50 {
|
|
items[i].Quality = items[i].Quality + 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if items[i].Name != "Sulfuras, Hand of Ragnaros" {
|
|
items[i].SellIn = items[i].SellIn - 1
|
|
}
|
|
|
|
if items[i].SellIn < 0 {
|
|
if items[i].Name != "Aged Brie" {
|
|
if items[i].Name != "Backstage passes to a TAFKAL80ETC concert" {
|
|
if items[i].Quality > 0 {
|
|
if items[i].Name != "Sulfuras, Hand of Ragnaros" {
|
|
items[i].Quality = items[i].Quality - 1
|
|
}
|
|
}
|
|
} else {
|
|
items[i].Quality = items[i].Quality - items[i].Quality
|
|
}
|
|
} else {
|
|
if items[i].Quality < 50 {
|
|
items[i].Quality = items[i].Quality + 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|