diff --git a/go/services/normal_item_update_service.go b/go/services/normal_item_update_service.go index b10430fc..d43712a6 100644 --- a/go/services/normal_item_update_service.go +++ b/go/services/normal_item_update_service.go @@ -16,56 +16,22 @@ func NewNormalItemUpdateService(logger lib.Logger) NormalItemUpdateService { } func (this NormalItemUpdateService) UpdateQuality(item *models.Item) error { + decrement := 1 + item.Mutex.Lock() defer item.Mutex.Unlock() itemModel := item.Model - if itemModel.Name != "Aged Brie" && itemModel.Name != "Backstage passes to a TAFKAL80ETC concert" { - if itemModel.Quality > 0 { - if itemModel.Name != "Sulfuras, Hand of Ragnaros" { - itemModel.Quality = itemModel.Quality - 1 - } - } + if itemModel.SellIn <= 0 { + decrement *= 2 + } + if (itemModel.Quality - decrement) < 0 { + itemModel.Quality = 0 } else { - if itemModel.Quality < 50 { - itemModel.Quality = itemModel.Quality + 1 - if itemModel.Name == "Backstage passes to a TAFKAL80ETC concert" { - if itemModel.SellIn < 11 { - if itemModel.Quality < 50 { - itemModel.Quality = itemModel.Quality + 1 - } - } - if itemModel.SellIn < 6 { - if itemModel.Quality < 50 { - itemModel.Quality = itemModel.Quality + 1 - } - } - } - } - } - - if itemModel.Name != "Sulfuras, Hand of Ragnaros" { - itemModel.SellIn = itemModel.SellIn - 1 - } - - if itemModel.SellIn < 0 { - if itemModel.Name != "Aged Brie" { - if itemModel.Name != "Backstage passes to a TAFKAL80ETC concert" { - if itemModel.Quality > 0 { - if itemModel.Name != "Sulfuras, Hand of Ragnaros" { - itemModel.Quality = itemModel.Quality - 1 - } - } - } else { - itemModel.Quality = itemModel.Quality - itemModel.Quality - } - } else { - if itemModel.Quality < 50 { - itemModel.Quality = itemModel.Quality + 1 - } - } + itemModel.Quality -= decrement } + itemModel.SellIn-- return nil }