mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-18 07:51:29 +00:00
Build in feature for conjured items
This commit is contained in:
parent
c88bfb0b69
commit
a654464b75
@ -7,6 +7,7 @@ class GildedRose {
|
|||||||
public static final String AGED_BRIE = "Aged Brie";
|
public static final String AGED_BRIE = "Aged Brie";
|
||||||
public static final String SULFURAS_HAND_OF_RAGNAROS = "Sulfuras, Hand of Ragnaros";
|
public static final String SULFURAS_HAND_OF_RAGNAROS = "Sulfuras, Hand of Ragnaros";
|
||||||
public static final String BACKSTAGE_PASSES = "Backstage passes to a TAFKAL80ETC concert";
|
public static final String BACKSTAGE_PASSES = "Backstage passes to a TAFKAL80ETC concert";
|
||||||
|
public static final String CONJURED_MANA_CAKE = "Conjured Mana Cake";
|
||||||
|
|
||||||
Item[] items;
|
Item[] items;
|
||||||
|
|
||||||
@ -25,10 +26,7 @@ class GildedRose {
|
|||||||
int qualityOffset = determineEnhancingQualityOffset(item);
|
int qualityOffset = determineEnhancingQualityOffset(item);
|
||||||
item.quality = Integer.min(item.quality + qualityOffset, MAX_QUALITY);
|
item.quality = Integer.min(item.quality + qualityOffset, MAX_QUALITY);
|
||||||
} else {
|
} else {
|
||||||
int qualityOffset = 1;
|
int qualityOffset = determineDegradingQualityOffset(item);
|
||||||
if(item.sellIn <= 0) {
|
|
||||||
qualityOffset +=1;
|
|
||||||
}
|
|
||||||
item.quality = Integer.max(MIN_QUALITY, item.quality - qualityOffset);
|
item.quality = Integer.max(MIN_QUALITY, item.quality - qualityOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,6 +51,14 @@ class GildedRose {
|
|||||||
return name.equals(GildedRose.AGED_BRIE) || name.equals(BACKSTAGE_PASSES);
|
return name.equals(GildedRose.AGED_BRIE) || name.equals(BACKSTAGE_PASSES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean isConjuredItem(String name) {
|
||||||
|
return name.equals(CONJURED_MANA_CAKE);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param item
|
* @param item
|
||||||
* @return
|
* @return
|
||||||
@ -68,7 +74,22 @@ class GildedRose {
|
|||||||
qualityOffset += 1;
|
qualityOffset += 1;
|
||||||
}
|
}
|
||||||
} else if (isExpiredSale(item.sellIn)) {
|
} else if (isExpiredSale(item.sellIn)) {
|
||||||
qualityOffset += 1;
|
qualityOffset *= 2;
|
||||||
|
}
|
||||||
|
return qualityOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param item
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private int determineDegradingQualityOffset(Item item) {
|
||||||
|
int qualityOffset = 1;
|
||||||
|
if(item.sellIn <= 0) {
|
||||||
|
qualityOffset *=2;
|
||||||
|
}
|
||||||
|
if(isConjuredItem(item.name)) {
|
||||||
|
qualityOffset *= 2;
|
||||||
}
|
}
|
||||||
return qualityOffset;
|
return qualityOffset;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -130,15 +130,15 @@ class GildedRoseTest {
|
|||||||
// day one
|
// day one
|
||||||
gildedRose.updateQuality();
|
gildedRose.updateQuality();
|
||||||
assertEquals(2, conjuredItem.sellIn);
|
assertEquals(2, conjuredItem.sellIn);
|
||||||
// assertEquals(4, conjuredItem.quality); //TODO this is the feature to get working
|
assertEquals(4, conjuredItem.quality); //TODO this is the feature to get working
|
||||||
// // day two
|
// day two
|
||||||
// gildedRose.updateQuality();
|
gildedRose.updateQuality();
|
||||||
// assertEquals(1, conjuredItem.sellIn);
|
assertEquals(1, conjuredItem.sellIn);
|
||||||
// assertEquals(2, conjuredItem.quality); //TODO this is the feature to get working
|
assertEquals(2, conjuredItem.quality); //TODO this is the feature to get working
|
||||||
// // day three
|
// day three
|
||||||
// gildedRose.updateQuality();
|
gildedRose.updateQuality();
|
||||||
// assertEquals(0, conjuredItem.sellIn);
|
assertEquals(0, conjuredItem.sellIn);
|
||||||
// assertEquals(2, conjuredItem.quality); //TODO this is the feature to get working
|
assertEquals(0, conjuredItem.quality); //TODO this is the feature to get working
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user