v0.3.4: externalized item actions

This commit is contained in:
Evan Debenham
2016-01-22 22:12:02 -05:00
committed by Evan Debenham
parent 7757b47573
commit 13b9d2f801
17 changed files with 68 additions and 77 deletions
@@ -78,13 +78,6 @@ public class Armor extends EquipableItem {
inscribe((Glyph) bundle.get(GLYPH));
}
@Override
public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions( hero );
actions.add(isEquipped(hero) ? AC_UNEQUIP : AC_EQUIP);
return actions;
}
@Override
public boolean doEquip( Hero hero ) {
@@ -29,14 +29,13 @@ import com.watabou.utils.Bundle;
import java.util.ArrayList;
abstract public class ClassArmor extends Armor {
private static final String TXT_LOW_HEALTH = "Your health is too low!";
private static final String TXT_NOT_EQUIPPED = "You need to be wearing this armor to use its special power!";
private static final String AC_SPECIAL = "SPECIAL";
{
levelKnown = true;
cursedKnown = true;
defaultAction = special();
defaultAction = AC_SPECIAL;
bones = false;
}
@@ -95,14 +94,14 @@ abstract public class ClassArmor extends Armor {
public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions( hero );
if (hero.HP >= 3 && isEquipped( hero )) {
actions.add( special() );
actions.add( AC_SPECIAL );
}
return actions;
}
@Override
public void execute( Hero hero, String action ) {
if (action == special()) {
if (action.equals(AC_SPECIAL)) {
if (hero.HP < 3) {
GLog.w( Messages.get(this, "low_hp") );
@@ -118,8 +117,7 @@ abstract public class ClassArmor extends Armor {
super.execute( hero, action );
}
}
abstract public String special();
abstract public void doSpecial();
@Override
@@ -36,8 +36,7 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.Callback;
public class HuntressArmor extends ClassArmor {
private static final String AC_SPECIAL = "SPECTRAL BLADES";
{
image = ItemSpriteSheet.ARMOR_HUNTRESS;
@@ -45,11 +44,6 @@ public class HuntressArmor extends ClassArmor {
private HashMap<Callback, Mob> targets = new HashMap<Callback, Mob>();
@Override
public String special() {
return AC_SPECIAL;
}
@Override
public void doSpecial() {
@@ -37,17 +37,10 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class MageArmor extends ClassArmor {
private static final String AC_SPECIAL = "MOLTEN EARTH";
{
image = ItemSpriteSheet.ARMOR_MAGE;
}
@Override
public String special() {
return AC_SPECIAL;
}
@Override
public void doSpecial() {
@@ -41,17 +41,10 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class RogueArmor extends ClassArmor {
private static final String AC_SPECIAL = "SMOKE BOMB";
{
image = ItemSpriteSheet.ARMOR_ROGUE;
}
@Override
public String special() {
return AC_SPECIAL;
}
@Override
public void doSpecial() {
GameScene.selectCell( teleporter );
@@ -44,18 +44,11 @@ public class WarriorArmor extends ClassArmor {
private static int LEAP_TIME = 1;
private static int SHOCK_TIME = 3;
private static final String AC_SPECIAL = "HEROIC LEAP";
{
image = ItemSpriteSheet.ARMOR_WARRIOR;
}
@Override
public String special() {
return AC_SPECIAL;
}
@Override
public void doSpecial() {
GameScene.selectCell( leaper );