refactoring first pass

This commit is contained in:
OKinane 2023-03-11 15:08:31 +01:00
parent 498786b31e
commit d2bf4e2f7e

View File

@ -14,76 +14,69 @@ namespace GildedRoseKata
{
for (var i = 0; i < Items.Count; i++)
{
if (Items[i].Name != "Aged Brie" && Items[i].Name != "Backstage passes to a TAFKAL80ETC concert")
if (Items[i].Name == "Sulfuras, Hand of Ragnaros")
{
if (Items[i].Quality > 0)
continue;
}
Items[i].SellIn = Items[i].SellIn - 1;
if (Items[i].Name == "Aged Brie")
{
IncreaseQualityByOne(i);
if (Items[i].SellIn < 0)
{
if (Items[i].Name != "Sulfuras, Hand of Ragnaros")
{
Items[i].Quality = Items[i].Quality - 1;
}
IncreaseQualityByOne(i);
}
}
else if (Items[i].Name == "Backstage passes to a TAFKAL80ETC concert")
{
IncreaseBackstageQuality(i);
if (Items[i].SellIn < 0)
{
Items[i].Quality = 0;
}
}
else
{
if (Items[i].Quality < 50)
DecreaseQualityByOne(i);
if (Items[i].SellIn < 0)
{
Items[i].Quality = Items[i].Quality + 1;
if (Items[i].Name == "Backstage passes to a TAFKAL80ETC concert")
{
if (Items[i].SellIn < 11)
{
if (Items[i].Quality < 50)
{
Items[i].Quality = Items[i].Quality + 1;
}
}
if (Items[i].SellIn < 6)
{
if (Items[i].Quality < 50)
{
Items[i].Quality = Items[i].Quality + 1;
}
}
}
}
}
if (Items[i].Name != "Sulfuras, Hand of Ragnaros")
{
Items[i].SellIn = Items[i].SellIn - 1;
}
if (Items[i].SellIn < 0)
{
if (Items[i].Name != "Aged Brie")
{
if (Items[i].Name != "Backstage passes to a TAFKAL80ETC concert")
{
if (Items[i].Quality > 0)
{
if (Items[i].Name != "Sulfuras, Hand of Ragnaros")
{
Items[i].Quality = Items[i].Quality - 1;
}
}
}
else
{
Items[i].Quality = Items[i].Quality - Items[i].Quality;
}
}
else
{
if (Items[i].Quality < 50)
{
Items[i].Quality = Items[i].Quality + 1;
}
DecreaseQualityByOne(i);
}
}
}
}
private void IncreaseBackstageQuality(int i)
{
IncreaseQualityByOne(i);
if (Items[i].SellIn < 10)
{
IncreaseQualityByOne(i);
}
if (Items[i].SellIn < 5)
{
IncreaseQualityByOne(i);
}
}
private void DecreaseQualityByOne(int i)
{
if (Items[i].Quality > 0)
{
Items[i].Quality = Items[i].Quality - 1;
}
}
private void IncreaseQualityByOne(int i)
{
if (Items[i].Quality < 50)
{
Items[i].Quality = Items[i].Quality + 1;
}
}
}
}