V0.1.1: fixed a bug involving throwing blandfruit (need to test)

This commit is contained in:
Evan Debenham
2014-08-15 09:20:15 -04:00
parent ef59fd8536
commit 8c8ccf8db4
@@ -40,9 +40,9 @@ public class Blandfruit extends Food {
@Override @Override
public void execute( Hero hero, String action ) { public void execute( Hero hero, String action ) {
if (potionAttrib == null){ if (action.equals( AC_EAT )){
if (action.equals( AC_EAT )) { if (potionAttrib == null) {
detach(hero.belongings.backpack); detach(hero.belongings.backpack);
@@ -58,43 +58,38 @@ public class Blandfruit extends Food {
Statistics.foodEaten++; Statistics.foodEaten++;
Badges.validateFoodEaten(); Badges.validateFoodEaten();
} } else {
else super.execute(hero, action); ((Hunger) hero.buff(Hunger.class)).satisfy(Hunger.HUNGRY);
detach(hero.belongings.backpack);
} else if (action.equals( AC_EAT )){ hero.spend(1f);
((Hunger)hero.buff( Hunger.class )).satisfy(Hunger.HUNGRY);
detach( hero.belongings.backpack );
hero.spend( 1f );
hero.busy(); hero.busy();
if (potionAttrib instanceof PotionOfFrost){ if (potionAttrib instanceof PotionOfFrost) {
GLog.i( "the Frostfruit takes a bit like Frozen Carpaccio." ); GLog.i("the Frostfruit tastes a bit like Frozen Carpaccio.");
switch (Random.Int(5)) { switch (Random.Int(5)) {
case 0: case 0:
GLog.i( "You see your hands turn invisible!" ); GLog.i("You see your hands turn invisible!");
Buff.affect(hero, Invisibility.class, Invisibility.DURATION); Buff.affect(hero, Invisibility.class, Invisibility.DURATION);
break; break;
case 1: case 1:
GLog.i( "You feel your skin harden!" ); GLog.i("You feel your skin harden!");
Buff.affect( hero, Barkskin.class ).level( hero.HT / 4 ); Buff.affect(hero, Barkskin.class).level(hero.HT / 4);
break; break;
case 2: case 2:
GLog.i( "Refreshing!" ); GLog.i("Refreshing!");
Buff.detach( hero, Poison.class ); Buff.detach(hero, Poison.class);
Buff.detach( hero, Cripple.class ); Buff.detach(hero, Cripple.class);
Buff.detach( hero, Weakness.class ); Buff.detach(hero, Weakness.class);
Buff.detach( hero, Bleeding.class ); Buff.detach(hero, Bleeding.class);
break; break;
case 3: case 3:
GLog.i( "You feel better!" ); GLog.i("You feel better!");
if (hero.HP < hero.HT) { if (hero.HP < hero.HT) {
hero.HP = Math.min( hero.HP + hero.HT / 4, hero.HT ); hero.HP = Math.min(hero.HP + hero.HT / 4, hero.HT);
hero.sprite.emitter().burst( Speck.factory( Speck.HEALING ), 1 ); hero.sprite.emitter().burst(Speck.factory(Speck.HEALING), 1);
} }
break; break;
} }
@@ -120,19 +115,7 @@ public class Blandfruit extends Food {
case HUNTRESS: case HUNTRESS:
break; break;
} }
} else if (action.equals( AC_THROW )){
if (potionAttrib instanceof PotionOfLiquidFlame ||
potionAttrib instanceof PotionOfToxicGas ||
potionAttrib instanceof PotionOfParalyticGas ||
potionAttrib instanceof PotionOfFrost){
potionAttrib.execute(hero, action);
//detaches in Potion.cast, this is an awkward workaround due to throwing being on a different thread.
} else {
super.execute(hero, action);
} }
} else { } else {
super.execute(hero, action); super.execute(hero, action);
} }
@@ -224,10 +207,24 @@ public class Blandfruit extends Food {
public static final String NAME = "name"; public static final String NAME = "name";
@Override
public void cast( final Hero user, int dst ) {
if (potionAttrib instanceof PotionOfLiquidFlame ||
potionAttrib instanceof PotionOfToxicGas ||
potionAttrib instanceof PotionOfParalyticGas ||
potionAttrib instanceof PotionOfFrost) {
potionAttrib.cast(user, dst);
detach( user.belongings.backpack );
} else {
super.cast(user, dst);
}
}
@Override @Override
public void storeInBundle(Bundle bundle){ public void storeInBundle(Bundle bundle){
super.storeInBundle(bundle); super.storeInBundle(bundle);
bundle.put(NAME name); bundle.put( NAME, name );
} }
@Override @Override