v0.7.0: added safety checks when items are dropped or thrown
This commit is contained in:
parent
8663623d19
commit
2ede820dab
|
@ -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 ) {
|
||||
|
||||
|
|
|
@ -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 );
|
||||
|
|
Loading…
Reference in New Issue
Block a user