v0.3.4: externalized item actions
This commit is contained in:
committed by
Evan Debenham
parent
7757b47573
commit
13b9d2f801
@@ -33,7 +33,7 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
|
||||
public class Amulet extends Item {
|
||||
|
||||
private static final String AC_END = "END THE GAME";
|
||||
private static final String AC_END = "END";
|
||||
|
||||
{
|
||||
image = ItemSpriteSheet.AMULET;
|
||||
@@ -50,7 +50,7 @@ public class Amulet extends Item {
|
||||
|
||||
@Override
|
||||
public void execute( Hero hero, String action ) {
|
||||
if (action == AC_END) {
|
||||
if (action.equals(AC_END)) {
|
||||
|
||||
showAmuletScene( false );
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public class Bomb extends Item {
|
||||
//FIXME using a static variable for this is kinda gross, should be a better way
|
||||
private static boolean lightingFuse = false;
|
||||
|
||||
private static final String AC_LIGHTTHROW = "Light & Throw";
|
||||
private static final String AC_LIGHTTHROW = "LIGHTTHROW";
|
||||
|
||||
@Override
|
||||
public boolean isSimilar(Item item) {
|
||||
|
||||
@@ -28,6 +28,8 @@ import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public abstract class EquipableItem extends Item {
|
||||
|
||||
public static final String AC_EQUIP = "EQUIP";
|
||||
@@ -37,6 +39,13 @@ public abstract class EquipableItem extends Item {
|
||||
bones = true;
|
||||
}
|
||||
|
||||
@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 void execute( Hero hero, String action ) {
|
||||
if (action.equals( AC_EQUIP )) {
|
||||
|
||||
@@ -33,13 +33,6 @@ abstract public class KindOfWeapon extends EquipableItem {
|
||||
|
||||
protected static final float TIME_TO_EQUIP = 1f;
|
||||
|
||||
@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 isEquipped( Hero hero ) {
|
||||
return hero.belongings.weapon == this;
|
||||
|
||||
@@ -32,7 +32,6 @@ public class MerchantsBeacon extends Item {
|
||||
|
||||
private static final String AC_USE = "USE";
|
||||
|
||||
|
||||
{
|
||||
image = ItemSpriteSheet.BEACON;
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -70,14 +70,6 @@ public class Artifact extends KindofMisc {
|
||||
public Artifact(){
|
||||
super();
|
||||
}
|
||||
|
||||
@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( final Hero hero ) {
|
||||
|
||||
|
||||
@@ -108,13 +108,6 @@ public class Ring extends KindofMisc {
|
||||
gem = handler.label( this );
|
||||
}
|
||||
|
||||
@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( final Hero hero ) {
|
||||
|
||||
|
||||
@@ -51,9 +51,6 @@ abstract public class MissileWeapon extends Weapon {
|
||||
public ArrayList<String> actions( Hero hero ) {
|
||||
ArrayList<String> actions = super.actions( hero );
|
||||
actions.remove( AC_EQUIP );
|
||||
if (!isEquipped( hero )) {
|
||||
actions.remove( AC_UNEQUIP );
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user