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,81 +58,64 @@ 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);
hero.busy();
((Hunger)hero.buff( Hunger.class )).satisfy(Hunger.HUNGRY); if (potionAttrib instanceof PotionOfFrost) {
GLog.i("the Frostfruit tastes 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 harden!");
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);
detach( hero.belongings.backpack ); Sample.INSTANCE.play( Assets.SND_EAT );
hero.spend( 1f ); hero.sprite.operate(hero.pos);
hero.busy();
if (potionAttrib instanceof PotionOfFrost){ switch (hero.heroClass) {
GLog.i( "the Frostfruit takes a bit like Frozen Carpaccio." ); case WARRIOR:
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 harden!" );
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) { if (hero.HP < hero.HT) {
hero.HP = Math.min( hero.HP + hero.HT / 4, hero.HT ); hero.HP = Math.min( hero.HP + 5, hero.HT );
hero.sprite.emitter().burst( Speck.factory( Speck.HEALING ), 1 ); hero.sprite.emitter().burst( Speck.factory(Speck.HEALING), 1 );
} }
break; break;
case MAGE:
hero.belongings.charge( false );
ScrollOfRecharging.charge(hero);
break;
case ROGUE:
case HUNTRESS:
break;
} }
} else
potionAttrib.apply(hero);
Sample.INSTANCE.play( Assets.SND_EAT );
hero.sprite.operate(hero.pos);
switch (hero.heroClass) {
case WARRIOR:
if (hero.HP < hero.HT) {
hero.HP = Math.min( hero.HP + 5, hero.HT );
hero.sprite.emitter().burst( Speck.factory(Speck.HEALING), 1 );
}
break;
case MAGE:
hero.belongings.charge( false );
ScrollOfRecharging.charge(hero);
break;
case ROGUE:
case HUNTRESS:
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