v0.7.0: improved drop/throw safety checks
This commit is contained in:
parent
c2e636cb14
commit
ed33859d76
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
|
Loading…
Reference in New Issue
Block a user