From a7caea15981317047a5a0533274a361e0900b21f Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 14 Aug 2014 01:31:39 -0400 Subject: [PATCH] V0.1.1: Blandfruit now half implemented, almost finished... --- .../items/food/BlandFruit.java | 40 +++++++++++-- .../levels/painters/GardenPainter.java | 17 ++++-- .../plants/BlandfruitBush.java | 59 +++++++++++++++++++ 3 files changed, 106 insertions(+), 10 deletions(-) create mode 100644 src/com/shatteredpixel/shatteredpixeldungeon/plants/BlandfruitBush.java diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/BlandFruit.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/BlandFruit.java index 0aed56a20..b859dce7b 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/food/BlandFruit.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/food/BlandFruit.java @@ -3,7 +3,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.food; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Statistics; -import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.*; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite; @@ -16,6 +16,7 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.watabou.noosa.audio.Sample; +import com.watabou.utils.Random; /** * Created by debenhame on 12/08/2014. @@ -61,13 +62,41 @@ public class Blandfruit extends Food { } else if (action.equals( AC_EAT )){ - ((Hunger)hero.buff( Hunger.class )).satisfy( Hunger.HUNGRY ); + ((Hunger)hero.buff( Hunger.class )).satisfy(Hunger.HUNGRY); detach( hero.belongings.backpack ); hero.spend( 1f ); hero.busy(); - potionAttrib.apply(hero); + + if (potionAttrib instanceof PotionOfFrost){ + GLog.i( "the Frostfruit takes a bit like Frozen Carpaccio." ); + switch (Random.Int(5)) { + case 0: + GLog.i( "You see your hands turn invisible!" ); + Buff.affect(hero, Invisibility.class, Invisibility.DURATION); + break; + case 1: + GLog.i( "You feel your skin hardens!" ); + Buff.affect( hero, Barkskin.class ).level( hero.HT / 4 ); + break; + case 2: + GLog.i( "Refreshing!" ); + Buff.detach( hero, Poison.class ); + Buff.detach( hero, Cripple.class ); + Buff.detach( hero, Weakness.class ); + Buff.detach( hero, Bleeding.class ); + break; + case 3: + GLog.i( "You feel better!" ); + if (hero.HP < hero.HT) { + hero.HP = Math.min( hero.HP + hero.HT / 4, hero.HT ); + hero.sprite.emitter().burst( Speck.factory( Speck.HEALING ), 1 ); + } + break; + } + } else + potionAttrib.apply(hero); Sample.INSTANCE.play( Assets.SND_EAT ); @@ -93,7 +122,8 @@ public class Blandfruit extends Food { if (potionAttrib instanceof PotionOfLiquidFlame || potionAttrib instanceof PotionOfToxicGas || - potionAttrib instanceof PotionOfParalyticGas){ + potionAttrib instanceof PotionOfParalyticGas || + potionAttrib instanceof PotionOfFrost){ potionAttrib.execute(hero, action); detach( hero.belongings.backpack ); } else { @@ -185,8 +215,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 Sorrowmoss seed it was cooked with. It looks crisp and volatile, I shouldn't eat this."; - } else { - } return this; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/painters/GardenPainter.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/painters/GardenPainter.java index fc378dbd3..47445f250 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/painters/GardenPainter.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/painters/GardenPainter.java @@ -22,6 +22,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Room; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.plants.Sungrass; +import com.shatteredpixel.shatteredpixeldungeon.plants.BlandfruitBush; import com.watabou.utils.Random; public class GardenPainter extends Painter { @@ -34,10 +35,18 @@ public class GardenPainter extends Painter { room.entrance().set( Room.Door.Type.REGULAR ); - int bushes = Random.Int( 3 ) == 0 ? (Random.Int( 5 ) == 0 ? 2 : 1) : 0; - for (int i=0; i < bushes; i++) { - level.plant( new Sungrass.Seed(), room.random() ); - } + int bushes = Random.Int( 3 ); + if (bushes == 0) { + level.plant(new Sungrass.Seed(), room.random()); + } else if (bushes == 1) { + level.plant(new BlandfruitBush.Seed(), room.random() ); + } else { + bushes = Random.Int( 5 ); + if (bushes == 0){ + level.plant(new Sungrass.Seed(), room.random()); + level.plant(new BlandfruitBush.Seed(), room.random() ); + } + } Foliage light = (Foliage)level.blobs.get( Foliage.class ); if (light == null) { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/plants/BlandfruitBush.java b/src/com/shatteredpixel/shatteredpixeldungeon/plants/BlandfruitBush.java new file mode 100644 index 000000000..4107f9138 --- /dev/null +++ b/src/com/shatteredpixel/shatteredpixeldungeon/plants/BlandfruitBush.java @@ -0,0 +1,59 @@ +package com.shatteredpixel.shatteredpixeldungeon.plants; + +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.actors.Char; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Blindness; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Cripple; +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; +import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; +import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; +import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfInvisibility; +import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; +import com.watabou.utils.Random; + +/** + * Created by Evan on 13/08/2014. + */ +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. " + + "The fruit is gross and unsubstantial but isn't poisonous. perhaps it could be cooked."; + + { + image = 8; + plantName = "Blandfruit"; + } + + @Override + public void activate( Char ch ) { + super.activate( ch ); + + if (ch != null) { + //need to implement this + } + } + + @Override + public String desc() { + return TXT_DESC; + } + + public static class Seed extends Plant.Seed { + { + plantName = "Blandfruit"; + + name = "seed of " + plantName; + image = ItemSpriteSheet.SEED_BLINDWEED; + + plantClass = BlandfruitBush.class; + alchemyClass = PotionOfInvisibility.class; + } + + @Override + public String desc() { + return TXT_DESC; + } + } +}