From 40f2ea25295776b3435919de55440d2923c41cff Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 14 Aug 2014 17:27:54 -0400 Subject: [PATCH] V0.1.1: Blandfruit implemented. All functional parts of V0.1.1 completed, need cleanup & testing --- .../actors/hero/Hero.java | 1 + .../shatteredpixeldungeon/items/Ankh.java | 2 + .../shatteredpixeldungeon/items/Heap.java | 21 +++++++-- .../items/food/Blandfruit.java | 40 +++++++++++++++-- .../items/food/FrozenCarpaccio.java | 2 +- .../levels/features/AlchemyPot.java | 44 +++++++++++++++++-- .../plants/BlandfruitBush.java | 8 ++-- 7 files changed, 103 insertions(+), 15 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index a64f2696c..e3859cb80 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -1099,6 +1099,7 @@ public class Hero extends Char { Ankh ankh = (Ankh)belongings.getItem( Ankh.class ); if (ankh != null && ankh.isBlessed()) { this.HP = HT; + //TODO: add sparkle effect new Flare(8, 32).color(0xFFFF66, true).show(sprite, 2f); ankh.detach(belongings.backpack); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/Ankh.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/Ankh.java index c7f03667d..05dfc9b38 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/Ankh.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/Ankh.java @@ -79,6 +79,8 @@ public class Ankh extends Item { hero.spend( 1f ); hero.busy(); + //TODO: add sparkle effect + Sample.INSTANCE.play( Assets.SND_DRINK ); hero.sprite.operate( hero.pos ); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java index f76f610bf..357d1f83f 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java @@ -20,6 +20,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items; import java.util.Collection; import java.util.LinkedList; +import com.shatteredpixel.shatteredpixeldungeon.items.food.Blandfruit; import com.watabou.noosa.audio.Sample; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Badges; @@ -239,19 +240,33 @@ public class Heap implements Bundlable { float chances[] = new float[items.size()]; int count = 0; + + + if (items.get(0) instanceof Blandfruit && items.get(1) instanceof Seed) { + + CellEmitter.center( pos ).burst( Speck.factory( Speck.EVOKE ), 3 ); + + Blandfruit result = new Blandfruit(); + result.cook((Seed)items.get(1)); + + destroy(); + + return result; + + } int index = 0; for (Item item : items) { if (item instanceof Seed) { count += item.quantity; chances[index++] = item.quantity; - } else { + } else{ count = 0; break; } } - - if (count >= SEEDS_TO_POTION) { + + } else if (count >= SEEDS_TO_POTION) { CellEmitter.get( pos ).burst( Speck.factory( Speck.WOOL ), 6 ); Sample.INSTANCE.play( Assets.SND_PUFF ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java index b859dce7b..ce32ba6b4 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java @@ -5,12 +5,14 @@ import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Statistics; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.*; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Wandmaker; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.potions.*; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging; import com.shatteredpixel.shatteredpixeldungeon.plants.Plant.Seed; +import com.shatteredpixel.shatteredpixeldungeon.plants.*; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; @@ -25,6 +27,7 @@ public class Blandfruit extends Food { public String message = "You eat the Blandfruit, bleugh!"; public String info = "So dry and insubstantial, perhaps cooking could improve it."; + public Potion potionAttrib = null; public ItemSprite.Glowing potionGlow = null; @@ -77,7 +80,7 @@ public class Blandfruit extends Food { Buff.affect(hero, Invisibility.class, Invisibility.DURATION); break; case 1: - GLog.i( "You feel your skin hardens!" ); + GLog.i( "You feel your skin harden!" ); Buff.affect( hero, Barkskin.class ).level( hero.HT / 4 ); break; case 2: @@ -155,7 +158,6 @@ public class Blandfruit extends Food { return null; } - //implement pixmap potionAttrib.image = ItemSpriteSheet.BLANDFRUIT; if (potionAttrib instanceof PotionOfHealing){ @@ -165,7 +167,6 @@ public class Blandfruit extends Food { info = "The fruit has plumped up from its time soaking in the pot and has even absorbed the properties "+ "of the Sungrass seed it was cooked with. It looks delicious and hearty, ready to be eaten!"; - } else if (potionAttrib instanceof PotionOfStrength){ name = "Powerfruit"; @@ -220,6 +221,39 @@ public class Blandfruit extends Food { return this; } + public static final String NAME = "name"; + + @Override + public void storeInBundle(Bundle bundle){ + super.storeInBundle(bundle); + bundle.put(NAME name); + } + + @Override + public void restoreFromBundle(Bundle bundle){ + super.restoreFromBundle(bundle); + name = bundle.getString(NAME); + + if (name == "Healthfruit") + cook(new Sungrass.Seed()); + else if (name == "Powerfruit") + //TODO: make sure this doesn't break anything + cook(new Wandmaker.Rotberry.Seed()); + else if (name == "Paralyzefruit") + cook(new Earthroot.Seed()); + else if (name == "Invisifruit") + cook(new Blindweed.Seed()); + else if (name == "Flamefruit") + cook(new Firebloom.Seed()); + else if (name == "Frostfruit") + cook(new Icecap.Seed()); + else if (name == "Visionfruit") + cook(new Fadeleaf.Seed()); + else if (name == "Toxicfruit") + cook(new Sorrowmoss.Seed()); + + } + @Override public ItemSprite.Glowing glowing() { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/FrozenCarpaccio.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/FrozenCarpaccio.java index f49918d75..451c60bff 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/FrozenCarpaccio.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/FrozenCarpaccio.java @@ -52,7 +52,7 @@ public class FrozenCarpaccio extends Food { Buff.affect( hero, Invisibility.class, Invisibility.DURATION ); break; case 1: - GLog.i( "You feel your skin hardens!" ); + GLog.i( "You feel your skin harden!" ); Buff.affect( hero, Barkskin.class ).level( hero.HT / 4 ); break; case 2: diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/features/AlchemyPot.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/features/AlchemyPot.java index 6b1bf53dc..382e38adc 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/features/AlchemyPot.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/features/AlchemyPot.java @@ -17,24 +17,62 @@ */ package com.shatteredpixel.shatteredpixeldungeon.levels.features; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; +import com.shatteredpixel.shatteredpixeldungeon.items.Heap; import com.shatteredpixel.shatteredpixeldungeon.items.Item; +import com.shatteredpixel.shatteredpixeldungeon.items.food.Blandfruit; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions; + +import java.util.Iterator; public class AlchemyPot { - private static final String TXT_SELECT_SEED = "Select a seed to throw"; + private static final String TXT_SELECT_SEED = "Select a seed to throw"; + private static final String TXT_POT = "Alchemy Pot"; + private static final String TXT_FRUIT = "Cook a Blandfruit"; + private static final String TXT_POTION = "Brew a Potion"; + private static final String TXT_OPTIONS = + "Do you want to cook a Blandfruit with a seed, or brew a Potion from seeds?"; private static Hero hero; private static int pos; + + public static boolean cookingFruit; public static void operate( Hero hero, int pos ) { AlchemyPot.hero = hero; AlchemyPot.pos = pos; - - GameScene.selectItem( itemSelector, WndBag.Mode.SEED, TXT_SELECT_SEED ); + + Iterator items = hero.belongings.iterator(); + Item curItem = null; + cookingFruit = false; + Heap heap = Dungeon.level.heaps.get( pos ); + + if (heap == null) + while (items.hasNext() && cookingFruit == false){ + curItem = items.next(); + if (curItem instanceof Blandfruit) + if (((Blandfruit) curItem).potionAttrib == null) + GameScene.show( + new WndOptions( TXT_POT, TXT_OPTIONS, TXT_FRUIT, TXT_POTION ){ + @Override + protected void onSelect( int index ) { + if (index == 0) + cookingFruit = true; + } + } + ); + } + + if (cookingFruit) { + curItem.cast( hero, pos ); + } else { + GameScene.selectItem(itemSelector, WndBag.Mode.SEED, TXT_SELECT_SEED); + } } private static final WndBag.Listener itemSelector = new WndBag.Listener() { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/plants/BlandfruitBush.java b/src/com/shatteredpixel/shatteredpixeldungeon/plants/BlandfruitBush.java index 4107f9138..27d5eaf4b 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/plants/BlandfruitBush.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/plants/BlandfruitBush.java @@ -18,7 +18,7 @@ import com.watabou.utils.Random; public class BlandfruitBush extends Plant { private static final String TXT_DESC = - "Distant cousin of the Rotberry, the pear-shaped produce of the Blandfruit bush tastes like mushy chalk. " + + "Distant cousin of the Rotberry, the pear-shaped produce of the Blandfruit bush tastes like caked dust. " + "The fruit is gross and unsubstantial but isn't poisonous. perhaps it could be cooked."; { @@ -30,9 +30,7 @@ public class BlandfruitBush extends Plant { public void activate( Char ch ) { super.activate( ch ); - if (ch != null) { - //need to implement this - } + Dungeon.level.drop( new Seed(), pos ).sprite.drop(); } @Override @@ -48,7 +46,7 @@ public class BlandfruitBush extends Plant { image = ItemSpriteSheet.SEED_BLINDWEED; plantClass = BlandfruitBush.class; - alchemyClass = PotionOfInvisibility.class; + alchemyClass = null; } @Override