v0.7.0: improved drop/throw safety checks
This commit is contained in:
parent
c2e636cb14
commit
ed33859d76
|
@ -113,10 +113,8 @@ 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
|
||||||
|
@ -126,9 +124,7 @@ 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 ) {
|
||||||
|
@ -141,11 +137,15 @@ public class Item implements Bundlable {
|
||||||
|
|
||||||
if (action.equals( AC_DROP )) {
|
if (action.equals( AC_DROP )) {
|
||||||
|
|
||||||
doDrop( hero );
|
if (hero.belongings.backpack.contains(this) || isEquipped(hero)) {
|
||||||
|
doDrop(hero);
|
||||||
|
}
|
||||||
|
|
||||||
} else if (action.equals( AC_THROW )) {
|
} else if (action.equals( AC_THROW )) {
|
||||||
|
|
||||||
doThrow( hero );
|
if (hero.belongings.backpack.contains(this) || isEquipped(hero)) {
|
||||||
|
doThrow(hero);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,10 +44,7 @@ public abstract class Brew extends Potion {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doThrow(Hero hero) {
|
public void doThrow(Hero hero) {
|
||||||
//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