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