added conjucted items handling and tests

This commit is contained in:
konradgadecki 2018-11-20 22:23:58 +01:00
parent 62fa51d8b5
commit 3946492a1e
2 changed files with 24 additions and 7 deletions

View File

@ -172,7 +172,12 @@ namespace csharp.UnitTests.Tests
} }
[Test] [Test]
[TestCase(-1, 20, 18)] [TestCase(-1, 20, 16)]
[TestCase(1, 20, 18)]
[TestCase(5, 50, 48)]
[TestCase(5, 55, 53)]
[TestCase(5, 1, 0)]
[TestCase(-5, 1, 0)]
public void UpdateQuality_ConjuredGetsOlder_ConjuredQualityDegradesTwoTimesFaster(int sellIn, int quality, public void UpdateQuality_ConjuredGetsOlder_ConjuredQualityDegradesTwoTimesFaster(int sellIn, int quality,
int expectedResult) int expectedResult)
{ {

View File

@ -11,6 +11,8 @@ namespace csharp
_items = items; _items = items;
} }
// V - "Conjured" items degrade in Quality twice as fast as normal items
//
public void UpdateQuality() public void UpdateQuality()
{ {
for (var i = 0; i < _items.Count; i++) for (var i = 0; i < _items.Count; i++)
@ -22,6 +24,11 @@ namespace csharp
if (_items[i].Name != "Sulfuras, Hand of Ragnaros") if (_items[i].Name != "Sulfuras, Hand of Ragnaros")
{ {
_items[i].Quality = _items[i].Quality - 1; _items[i].Quality = _items[i].Quality - 1;
if (_items[i].Name.StartsWith("Conjured") && _items[i].Quality > 0)
{
_items[i].Quality = _items[i].Quality - 1;
}
} }
} }
} }
@ -29,7 +36,7 @@ namespace csharp
{ {
if (_items[i].Quality < 50) if (_items[i].Quality < 50)
{ {
_items[i].Quality = _items[i].Quality + 1; _items[i].Quality++;
if (_items[i].Name == "Backstage passes to a TAFKAL80ETC concert") if (_items[i].Name == "Backstage passes to a TAFKAL80ETC concert")
{ {
@ -37,7 +44,7 @@ namespace csharp
{ {
if (_items[i].Quality < 50) if (_items[i].Quality < 50)
{ {
_items[i].Quality = _items[i].Quality + 1; _items[i].Quality++;
} }
} }
@ -45,7 +52,7 @@ namespace csharp
{ {
if (_items[i].Quality < 50) if (_items[i].Quality < 50)
{ {
_items[i].Quality = _items[i].Quality + 1; _items[i].Quality++;
} }
} }
} }
@ -69,6 +76,11 @@ namespace csharp
{ {
_items[i].Quality = _items[i].Quality - 1; _items[i].Quality = _items[i].Quality - 1;
} }
if (_items[i].Name.StartsWith("Conjured") && _items[i].Quality > 0)
{
_items[i].Quality = _items[i].Quality - 1;
}
} }
} }
else else