From 2ba07cce2515e74b01cb45207f59cbe13268f2dd Mon Sep 17 00:00:00 2001 From: Bjorn Misseghers Date: Tue, 13 Apr 2021 11:27:27 +0200 Subject: [PATCH] Add Conjured mana cake implementation The quality of the cake decreases twice as fast as the default, so we pass these levels of quality decay to the quality behavior constructor --- .../java/com/gildedrose/behavior/ItemBehaviorPicker.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Java/src/main/java/com/gildedrose/behavior/ItemBehaviorPicker.java b/Java/src/main/java/com/gildedrose/behavior/ItemBehaviorPicker.java index 4baab216..8934f1d5 100644 --- a/Java/src/main/java/com/gildedrose/behavior/ItemBehaviorPicker.java +++ b/Java/src/main/java/com/gildedrose/behavior/ItemBehaviorPicker.java @@ -18,6 +18,7 @@ public class ItemBehaviorPicker { public static final String ITEM_AGED_BRIE = "Aged Brie"; public static final String ITEM_SULFURAS_HAND_OF_RAGNAROS = "Sulfuras, Hand of Ragnaros"; public static final String ITEM_BACKSTAGE_PASSES = "Backstage passes to a TAFKAL80ETC concert"; + public static final String ITEM_CONJURED_MANA_CAKE = "Conjured Mana Cake"; public static ItemBehavior forName(String name) { @@ -25,6 +26,7 @@ public class ItemBehaviorPicker { case ITEM_AGED_BRIE: return getAgedBrieItemBehavior(); case ITEM_SULFURAS_HAND_OF_RAGNAROS: return getSulfurusHandOfRagnarosItemBehavior(); case ITEM_BACKSTAGE_PASSES: return getBackstagePassesItemBehavior(); + case ITEM_CONJURED_MANA_CAKE: return getConjuredItemBehavior(); default: return getDefaultItemBehavior(); } } @@ -42,6 +44,10 @@ public class ItemBehaviorPicker { return ItemBehaviorImpl.of(StagedIncreasingQualityBehavior.withStages(stages, 1), DecreasingSellInBehavior.newInstance()); } + private static ItemBehavior getConjuredItemBehavior() { + return ItemBehaviorImpl.of(DecreasingQualityBehavior.newInstance(2, 4), DecreasingSellInBehavior.newInstance()); + } + private static ItemBehavior getDefaultItemBehavior() { return ItemBehaviorImpl.of(DecreasingQualityBehavior.newInstance(), DecreasingSellInBehavior.newInstance()); }