v0.7.0: improved drop/throw safety checks

This commit is contained in:
Evan Debenham 2018-09-18 04:36:27 -04:00
parent c2e636cb14
commit ed33859d76
2 changed files with 10 additions and 13 deletions

View File

@ -113,11 +113,9 @@ public class Item implements Bundlable {
}
public void doDrop( Hero hero ) {
if (hero.belongings.backpack.contains(this)) {
hero.spendAndNext(TIME_TO_DROP);
Dungeon.level.drop(detachAll(hero.belongings.backpack), hero.pos).sprite.drop(hero.pos);
}
}
//resets an item's properties, to ensure consistency between runs
public void reset(){
@ -126,10 +124,8 @@ public class Item implements Bundlable {
}
public void doThrow( Hero hero ) {
if (hero.belongings.backpack.contains(this)) {
GameScene.selectCell(thrower);
}
}
public void execute( Hero hero, String action ) {
@ -141,11 +137,15 @@ public class Item implements Bundlable {
if (action.equals( AC_DROP )) {
doDrop( hero );
if (hero.belongings.backpack.contains(this) || isEquipped(hero)) {
doDrop(hero);
}
} else if (action.equals( AC_THROW )) {
doThrow( hero );
if (hero.belongings.backpack.contains(this) || isEquipped(hero)) {
doThrow(hero);
}
}
}

View File

@ -44,11 +44,8 @@ public abstract class Brew extends Potion {
@Override
public void doThrow(Hero hero) {
//identical to Item.doThrow
if (hero.belongings.backpack.contains(this)) {
GameScene.selectCell(thrower);
}
}
@Override
public abstract void shatter( int cell );