v0.7.0: added safety checks when items are dropped or thrown
This commit is contained in:
parent
8663623d19
commit
2ede820dab
|
@ -113,8 +113,10 @@ public class Item implements Bundlable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doDrop( Hero hero ) {
|
public void doDrop( Hero hero ) {
|
||||||
hero.spendAndNext( TIME_TO_DROP );
|
if (hero.belongings.backpack.contains(this)) {
|
||||||
Dungeon.level.drop( detachAll( hero.belongings.backpack ), hero.pos ).sprite.drop( hero.pos );
|
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
|
//resets an item's properties, to ensure consistency between runs
|
||||||
|
@ -124,7 +126,9 @@ public class Item implements Bundlable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doThrow( Hero hero ) {
|
public void doThrow( Hero hero ) {
|
||||||
GameScene.selectCell( thrower );
|
if (hero.belongings.backpack.contains(this)) {
|
||||||
|
GameScene.selectCell(thrower);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute( Hero hero, String action ) {
|
public void execute( Hero hero, String action ) {
|
||||||
|
|
|
@ -45,7 +45,9 @@ public abstract class Brew extends Potion {
|
||||||
@Override
|
@Override
|
||||||
public void doThrow(Hero hero) {
|
public void doThrow(Hero hero) {
|
||||||
//identical to Item.doThrow
|
//identical to Item.doThrow
|
||||||
GameScene.selectCell( thrower );
|
if (hero.belongings.backpack.contains(this)) {
|
||||||
|
GameScene.selectCell(thrower);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue
Block a user