feat: implement conjured items
"Conjured" items degrade in Quality twice as fast as normal items
This commit is contained in:
parent
b0713494a5
commit
023cf716b1
@ -45,9 +45,8 @@ namespace csharpcore
|
||||
|
||||
private static void UpdateConjuredCake(Item item)
|
||||
{
|
||||
// TODO
|
||||
// Decrease quality twice when sell date is passed
|
||||
var qualityDecrement = item.SellIn > 0 ? 1 : 2;
|
||||
// Decrease quality twice as fast as normal items
|
||||
var qualityDecrement = item.SellIn > 0 ? 2 : 4;
|
||||
item.Quality = Math.Max(item.Quality - qualityDecrement, 0);
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 14, 21
|
||||
Backstage passes to a TAFKAL80ETC concert, 9, 50
|
||||
Backstage passes to a TAFKAL80ETC concert, 4, 50
|
||||
Conjured Mana Cake, 2, 5
|
||||
Conjured Mana Cake, 2, 4
|
||||
|
||||
-------- day 2 --------
|
||||
name, sellIn, quality
|
||||
@ -33,7 +33,7 @@ Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 13, 22
|
||||
Backstage passes to a TAFKAL80ETC concert, 8, 50
|
||||
Backstage passes to a TAFKAL80ETC concert, 3, 50
|
||||
Conjured Mana Cake, 1, 4
|
||||
Conjured Mana Cake, 1, 2
|
||||
|
||||
-------- day 3 --------
|
||||
name, sellIn, quality
|
||||
@ -45,7 +45,7 @@ Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 12, 23
|
||||
Backstage passes to a TAFKAL80ETC concert, 7, 50
|
||||
Backstage passes to a TAFKAL80ETC concert, 2, 50
|
||||
Conjured Mana Cake, 0, 3
|
||||
Conjured Mana Cake, 0, 0
|
||||
|
||||
-------- day 4 --------
|
||||
name, sellIn, quality
|
||||
@ -57,7 +57,7 @@ Sulfuras, Hand of Ragnaros, -1, 80
|
||||
Backstage passes to a TAFKAL80ETC concert, 11, 24
|
||||
Backstage passes to a TAFKAL80ETC concert, 6, 50
|
||||
Backstage passes to a TAFKAL80ETC concert, 1, 50
|
||||
Conjured Mana Cake, -1, 1
|
||||
Conjured Mana Cake, -1, 0
|
||||
|
||||
-------- day 5 --------
|
||||
name, sellIn, quality
|
||||
|
@ -15,17 +15,20 @@ namespace csharpcore
|
||||
_rose =new GildedRose(_items);
|
||||
}
|
||||
|
||||
//[Fact]
|
||||
public void ShouldDecreaseInQuality()
|
||||
[Theory]
|
||||
[InlineData(3, 2, 1)]
|
||||
[InlineData(5, 1, 3)]
|
||||
[InlineData(5, 0, 1)]
|
||||
public void ShouldDecreaseInQualityTwiceAsFastAsNormalItems(int inQuality, int sellInDays, int expectedQuality)
|
||||
{
|
||||
var item = GenerateItem(3, 2);
|
||||
var item = GenerateItem(inQuality, sellInDays);
|
||||
_items.Add(item);
|
||||
|
||||
_rose.UpdateQuality();
|
||||
Assert.Equal(1, item.Quality);
|
||||
Assert.Equal(1, item.SellIn);
|
||||
Assert.Equal(sellInDays - 1, item.SellIn);
|
||||
Assert.Equal(expectedQuality, item.Quality);
|
||||
}
|
||||
|
||||
|
||||
public Item GenerateItem(int quality, int sellInDays)
|
||||
=> new Item {Name = "Conjured Mana Cake", Quality = quality, SellIn = sellInDays};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user