diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java index a3ea7fba4..4787b27d5 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/HornOfPlenty.java @@ -2,15 +2,21 @@ package com.shatteredpixel.shatteredpixeldungeon.items.artifacts; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Badges; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Statistics; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite; +import com.shatteredpixel.shatteredpixeldungeon.items.Item; +import com.shatteredpixel.shatteredpixeldungeon.items.food.Blandfruit; +import com.shatteredpixel.shatteredpixeldungeon.items.food.Food; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging; +import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag; import com.watabou.noosa.audio.Sample; import java.util.ArrayList; @@ -20,7 +26,7 @@ import java.util.ArrayList; */ public class HornOfPlenty extends Artifact { - //TODO: test for bugs, tune numbers. + //TODO: test for bugs, tune numbers, add sprite switching. { name = "Horn of Plenty"; @@ -37,6 +43,9 @@ public class HornOfPlenty extends Artifact { public static final String AC_EAT = "EAT"; public static final String AC_STORE = "STORE"; + protected String inventoryTitle = "Select a piece of food"; + protected WndBag.Mode mode = WndBag.Mode.FOOD; + private static final String TXT_STATUS = "%d/%d"; @Override @@ -51,6 +60,8 @@ public class HornOfPlenty extends Artifact { @Override public void execute( Hero hero, String action ) { + super.execute(hero, action); + if (action.equals(AC_EAT)){ ((Hunger)hero.buff( Hunger.class )).satisfy( energy*charge ); @@ -88,15 +99,9 @@ public class HornOfPlenty extends Artifact { image = ItemSpriteSheet.ARTIFACT_HORN; } else if (action.equals(AC_STORE)){ - //TODO: gamescreen to select food item to store. can store anything that is isntanceof Food. - /*currently thinking: - blandFruit = 1; - snack-tier = 5; - hungry-tier = 15; - starving-tier = 25; - */ - } else - super.execute(hero, action); + + GameScene.selectItem(itemSelector, mode, inventoryTitle); + } } @Override @@ -148,4 +153,24 @@ public class HornOfPlenty extends Artifact { } + protected static WndBag.Listener itemSelector = new WndBag.Listener() { + @Override + public void onSelect( Item item ) { + if (item != null && item instanceof Food) { + if (item instanceof Blandfruit && ((Blandfruit) item).potionAttrib == null){ + GLog.w("the horn rejects your unprepared blandfruit."); + } else { + curItem.level += ((Food)item).hornValue; + if (curItem.level >= 150){ + curItem.level = 150; + GLog.p("your horn has consumed all the food it can!"); + } else + GLog.p("the horn consumes your food offering and grows in strength!"); + item.detach(Dungeon.hero.belongings.backpack); + } + + } + } + }; + } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java index 9ff6170c0..7aaa7cecb 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java @@ -37,6 +37,7 @@ public class Blandfruit extends Food { stackable = false; image = ItemSpriteSheet.BLANDFRUIT; energy = (Hunger.STARVING - Hunger.HUNGRY)/2; + hornValue = 15; } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/ChargrilledMeat.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/ChargrilledMeat.java index b828f35c8..9d3c301dd 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/ChargrilledMeat.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/ChargrilledMeat.java @@ -26,6 +26,7 @@ public class ChargrilledMeat extends Food { name = "chargrilled meat"; image = ItemSpriteSheet.STEAK; energy = Hunger.STARVING - Hunger.HUNGRY; + hornValue = 5; } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Food.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Food.java index 8eefcb238..bf667ca3e 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Food.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Food.java @@ -40,6 +40,8 @@ public class Food extends Item { public float energy = Hunger.HUNGRY; public String message = "That food tasted delicious!"; + + public int hornValue = 15; { stackable = true; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/FrozenCarpaccio.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/FrozenCarpaccio.java index 451c60bff..5a296485b 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/FrozenCarpaccio.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/FrozenCarpaccio.java @@ -37,6 +37,7 @@ public class FrozenCarpaccio extends Food { name = "frozen carpaccio"; image = ItemSpriteSheet.CARPACCIO; energy = Hunger.STARVING - Hunger.HUNGRY; + hornValue = 5; } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/MysteryMeat.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/MysteryMeat.java index 728bbc852..370b00132 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/MysteryMeat.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/MysteryMeat.java @@ -36,6 +36,7 @@ public class MysteryMeat extends Food { image = ItemSpriteSheet.MEAT; energy = Hunger.STARVING - Hunger.HUNGRY; message = "That food tasted... strange."; + hornValue = 5; } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/OverpricedRation.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/OverpricedRation.java index 1e7e7216a..dd19f197f 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/OverpricedRation.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/OverpricedRation.java @@ -27,6 +27,7 @@ public class OverpricedRation extends Food { image = ItemSpriteSheet.OVERPRICED; energy = Hunger.STARVING - Hunger.HUNGRY; message = "That food tasted ok."; + hornValue = 5; } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Pasty.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Pasty.java index 519891928..78b98b247 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Pasty.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Pasty.java @@ -26,6 +26,7 @@ public class Pasty extends Food { name = "pasty"; image = ItemSpriteSheet.PASTY; energy = Hunger.STARVING; + hornValue = 25; } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java index 5ec25234c..61f549743 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java @@ -19,6 +19,7 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; import android.graphics.RectF; +import com.shatteredpixel.shatteredpixeldungeon.items.food.Food; import com.watabou.gltextures.TextureCache; import com.watabou.noosa.BitmapText; import com.watabou.noosa.ColorBlock; @@ -58,7 +59,9 @@ public class WndBag extends WndTabbed { WEAPON, ARMOR, WAND, - SEED + SEED, + FOOD, + } protected static final int COLS = 4; @@ -348,6 +351,7 @@ public class WndBag extends WndTabbed { mode == Mode.ARMOR && (item instanceof Armor) || mode == Mode.WAND && (item instanceof Wand) || mode == Mode.SEED && (item instanceof Seed) || + mode == Mode.FOOD && (item instanceof Food) || mode == Mode.ALL ); }