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 ) {
|
public void doDrop( Hero hero ) {
|
||||||
|
if (hero.belongings.backpack.contains(this)) {
|
||||||
hero.spendAndNext(TIME_TO_DROP);
|
hero.spendAndNext(TIME_TO_DROP);
|
||||||
Dungeon.level.drop(detachAll(hero.belongings.backpack), hero.pos).sprite.drop(hero.pos);
|
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
|
||||||
public void reset(){
|
public void reset(){
|
||||||
|
@ -124,8 +126,10 @@ public class Item implements Bundlable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doThrow( Hero hero ) {
|
public void doThrow( Hero hero ) {
|
||||||
|
if (hero.belongings.backpack.contains(this)) {
|
||||||
GameScene.selectCell(thrower);
|
GameScene.selectCell(thrower);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void execute( Hero hero, String action ) {
|
public void execute( Hero hero, String action ) {
|
||||||
|
|
||||||
|
|
|
@ -45,8 +45,10 @@ 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
|
||||||
|
if (hero.belongings.backpack.contains(this)) {
|
||||||
GameScene.selectCell(thrower);
|
GameScene.selectCell(thrower);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract void shatter( int cell );
|
public abstract void shatter( int cell );
|
||||||
|
|
Loading…
Reference in New Issue
Block a user