v0.7.0: added safety checks when items are dropped or thrown

This commit is contained in:
Evan Debenham 2018-09-17 14:11:31 -04:00
parent 8663623d19
commit 2ede820dab
2 changed files with 10 additions and 4 deletions

View File

@ -113,9 +113,11 @@ 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(){
@ -124,8 +126,10 @@ 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 ) {

View File

@ -45,8 +45,10 @@ 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 );