mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-17 23:41:27 +00:00
Updated NormalItemUpdateService
This commit is contained in:
parent
5c5a441914
commit
354c068f33
@ -16,56 +16,22 @@ func NewNormalItemUpdateService(logger lib.Logger) NormalItemUpdateService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this NormalItemUpdateService) UpdateQuality(item *models.Item) error {
|
func (this NormalItemUpdateService) UpdateQuality(item *models.Item) error {
|
||||||
|
decrement := 1
|
||||||
|
|
||||||
item.Mutex.Lock()
|
item.Mutex.Lock()
|
||||||
defer item.Mutex.Unlock()
|
defer item.Mutex.Unlock()
|
||||||
|
|
||||||
itemModel := item.Model
|
itemModel := item.Model
|
||||||
|
|
||||||
if itemModel.Name != "Aged Brie" && itemModel.Name != "Backstage passes to a TAFKAL80ETC concert" {
|
if itemModel.SellIn <= 0 {
|
||||||
if itemModel.Quality > 0 {
|
decrement *= 2
|
||||||
if itemModel.Name != "Sulfuras, Hand of Ragnaros" {
|
}
|
||||||
itemModel.Quality = itemModel.Quality - 1
|
if (itemModel.Quality - decrement) < 0 {
|
||||||
}
|
itemModel.Quality = 0
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if itemModel.Quality < 50 {
|
itemModel.Quality -= decrement
|
||||||
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.SellIn--
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user