From 26b5fd7ac4b176a99d038face972944b0a9b74b5 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 2 Jan 2016 22:25:03 -0500 Subject: [PATCH] v0.3.4: externalized armor strings --- .../items/armor/Armor.java | 53 ++++++------------- .../items/armor/ClassArmor.java | 11 ++-- .../items/armor/ClothArmor.java | 6 +-- .../items/armor/HuntressArmor.java | 25 ++------- .../items/armor/LeatherArmor.java | 6 +-- .../items/armor/MageArmor.java | 20 +------ .../items/armor/MailArmor.java | 5 -- .../items/armor/PlateArmor.java | 8 +-- .../items/armor/RogueArmor.java | 25 ++------- .../items/armor/ScaleArmor.java | 7 +-- .../items/armor/WarriorArmor.java | 22 +------- .../messages/messages.properties | 43 +++++++++++---- 12 files changed, 66 insertions(+), 165 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java index 71e506ac9..f7a7b97e2 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/Armor.java @@ -43,15 +43,8 @@ public class Armor extends EquipableItem { private static final int HITS_TO_KNOW = 10; - private static final String TXT_EQUIP_CURSED = "your %s constricts around you painfully"; - - private static final String TXT_IDENTIFY = "you are now familiar enough with your %s to identify it. It is %s."; - private static final String TXT_TO_STRING = "%s :%d"; - private static final String TXT_INCOMPATIBLE = - "Interaction of different types of magic has erased the glyph on this armor!"; - public int tier; public int STR; @@ -104,7 +97,7 @@ public class Armor extends EquipableItem { cursedKnown = true; if (cursed) { equipCursed( hero ); - GLog.n( TXT_EQUIP_CURSED, toString() ); + GLog.n( Messages.get(Armor.class, "equip_cursed", toString()) ); } ((HeroSprite)hero.sprite).updateArmor(); @@ -159,7 +152,7 @@ public class Armor extends EquipableItem { if (glyph != null) { if (!inscribe && Random.Int( level() ) > 0) { - GLog.w( TXT_INCOMPATIBLE ); + GLog.w( Messages.get(Armor.class, "incompatible") ); inscribe( null ); } } else { @@ -189,7 +182,7 @@ public class Armor extends EquipableItem { if (!levelKnown) { if (--hitsToKnow <= 0) { levelKnown = true; - GLog.w( TXT_IDENTIFY, name(), toString() ); + GLog.w( Messages.get(Armor.class, "identify", name(), toString()) ); Badges.validateItemLevelAquired( this ); } } @@ -210,49 +203,33 @@ public class Armor extends EquipableItem { @Override public String info() { String name = name(); - StringBuilder info = new StringBuilder( desc() ); + String info = desc(); if (levelKnown) { - info.append( - "\n\nThis " + name + " provides damage absorption up to " + - "" + Math.max( DR(), 0 ) + " points per attack. " ); + info += Messages.get(Armor.class, "curr_absorb", name, Math.max( DR(), 0 )); if (STR > Dungeon.hero.STR()) { - - if (isEquipped( Dungeon.hero )) { - info.append( - "\n\nBecause of your inadequate strength your " + - "movement speed and defense skill is decreased. " ); - } else { - info.append( - "\n\nBecause of your inadequate strength wearing this armor " + - "will decrease your movement speed and defense skill. " ); - } - + info += Messages.get(Armor.class, "too_heavy"); } } else { - info.append( - "\n\nTypical " + name + " provides damage absorption up to " + typicalDR() + " points per attack " + - " and requires " + typicalSTR() + " points of strength. " ); + info += Messages.get(Armor.class, "avg_absorb", name, typicalDR(), typicalSTR()); + if (typicalSTR() > Dungeon.hero.STR()) { - info.append( "Probably this armor is too heavy for you. " ); + info += Messages.get(Armor.class, "probably_too_heavy"); } } if (glyph != null) { - info.append( "It is inscribed." ); + info += Messages.get(Armor.class, "inscribed", glyph.name()); } - if (isEquipped( Dungeon.hero )) { - info.append( "\n\nYou are wearing the " + name + - (cursed ? ", and because it is cursed, you are powerless to remove it." : ".") ); - } else { - if (cursedKnown && cursed) { - info.append( "\n\nYou can feel a malevolent magic lurking within the " + name + "." ); - } + if (cursed && isEquipped( Dungeon.hero )) { + info += Messages.get(Armor.class, "cursed_word"); + } else if (cursedKnown && cursed) { + info += Messages.get(Armor.class, "cursed"); } - return info.toString(); + return info; } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/ClassArmor.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/ClassArmor.java index c4bf441e9..cf755cd28 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/ClassArmor.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/ClassArmor.java @@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.armor; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.watabou.utils.Bundle; @@ -104,9 +105,9 @@ abstract public class ClassArmor extends Armor { if (action == special()) { if (hero.HP < 3) { - GLog.w( TXT_LOW_HEALTH ); + GLog.w( Messages.get(this, "low_hp") ); } else if (!isEquipped( hero )) { - GLog.w( TXT_NOT_EQUIPPED ); + GLog.w( Messages.get(this, "not_equipped") ); } else { curUser = hero; Invisibility.dispel(); @@ -140,9 +141,5 @@ abstract public class ClassArmor extends Armor { public int price() { return 0; } - - @Override - public String desc() { - return "The thing looks awesome!"; - } + } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/ClothArmor.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/ClothArmor.java index 39ded6861..cc8b58d62 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/ClothArmor.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/ClothArmor.java @@ -33,9 +33,5 @@ public class ClothArmor extends Armor { public ClothArmor() { super( 1 ); } - - @Override - public String desc() { - return "This lightweight armor offers basic protection."; - } + } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/HuntressArmor.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/HuntressArmor.java index 6489a00b2..28c97f91a 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/HuntressArmor.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/HuntressArmor.java @@ -29,6 +29,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Shuriken; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.sprites.MissileSprite; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; @@ -36,9 +37,6 @@ import com.watabou.utils.Callback; public class HuntressArmor extends ClassArmor { - private static final String TXT_NO_ENEMIES = "No enemies in sight"; - private static final String TXT_NOT_HUNTRESS = "Only huntresses can use this armor!"; - private static final String AC_SPECIAL = "SPECTRAL BLADES"; { @@ -79,7 +77,7 @@ public class HuntressArmor extends ClassArmor { } if (targets.size() == 0) { - GLog.w( TXT_NO_ENEMIES ); + GLog.w( Messages.get(this, "no_enemies") ); return; } @@ -88,22 +86,5 @@ public class HuntressArmor extends ClassArmor { curUser.sprite.zap( curUser.pos ); curUser.busy(); } - - @Override - public boolean doEquip( Hero hero ) { - if (hero.heroClass == HeroClass.HUNTRESS) { - return super.doEquip( hero ); - } else { - GLog.w( TXT_NOT_HUNTRESS ); - return false; - } - } - - @Override - public String desc() { - return - "A huntress in such cloak can create a fan of spectral blades. Each of these blades " + - "will target a single enemy in the huntress's field of view, inflicting damage depending " + - "on her currently equipped melee weapon."; - } + } \ No newline at end of file diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/LeatherArmor.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/LeatherArmor.java index 51d39d831..58e743b9a 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/LeatherArmor.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/LeatherArmor.java @@ -31,9 +31,5 @@ public class LeatherArmor extends Armor { public LeatherArmor() { super( 2 ); } - - @Override - public String desc() { - return "Armor made from tanned monster hide. Not as light as cloth armor but provides better protection."; - } + } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/MageArmor.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/MageArmor.java index 321434cfb..9996bb094 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/MageArmor.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/MageArmor.java @@ -39,8 +39,6 @@ public class MageArmor extends ClassArmor { private static final String AC_SPECIAL = "MOLTEN EARTH"; - private static final String TXT_NOT_MAGE = "Only mages can use this armor!"; - { image = ItemSpriteSheet.ARMOR_MAGE; } @@ -50,13 +48,6 @@ public class MageArmor extends ClassArmor { return AC_SPECIAL; } - @Override - public String desc() { - return - "Wearing this gorgeous robe, a mage can cast a spell of molten earth: all the enemies " + - "in his field of view will be set on fire and unable to move at the same time."; - } - @Override public void doSpecial() { @@ -76,14 +67,5 @@ public class MageArmor extends ClassArmor { curUser.sprite.centerEmitter().start( ElmoParticle.FACTORY, 0.15f, 4 ); Sample.INSTANCE.play( Assets.SND_READ ); } - - @Override - public boolean doEquip( Hero hero ) { - if (hero.heroClass == HeroClass.MAGE) { - return super.doEquip( hero ); - } else { - GLog.w( TXT_NOT_MAGE ); - return false; - } - } + } \ No newline at end of file diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/MailArmor.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/MailArmor.java index 9e793ac71..dc7572f1a 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/MailArmor.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/MailArmor.java @@ -32,9 +32,4 @@ public class MailArmor extends Armor { super( 3 ); } - @Override - public String desc() { - return - "Interlocking metal links make for a tough but flexible suit of armor."; - } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/PlateArmor.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/PlateArmor.java index 54f45d562..06fed3af9 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/PlateArmor.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/PlateArmor.java @@ -31,11 +31,5 @@ public class PlateArmor extends Armor { public PlateArmor() { super( 5 ); } - - @Override - public String desc() { - return - "Enormous plates of metal are joined together into a suit that provides " + - "unmatched protection to any adventurer strong enough to bear its staggering weight."; - } + } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/RogueArmor.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/RogueArmor.java index c0e8ac727..644a40f8c 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/RogueArmor.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/RogueArmor.java @@ -21,6 +21,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.armor; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.watabou.noosa.audio.Sample; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; @@ -40,9 +41,6 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; public class RogueArmor extends ClassArmor { - private static final String TXT_FOV = "You can only jump to an empty location in your field of view"; - private static final String TXT_NOT_ROGUE = "Only rogues can use this armor!"; - private static final String AC_SPECIAL = "SMOKE BOMB"; { @@ -59,23 +57,6 @@ public class RogueArmor extends ClassArmor { GameScene.selectCell( teleporter ); } - @Override - public boolean doEquip( Hero hero ) { - if (hero.heroClass == HeroClass.ROGUE) { - return super.doEquip( hero ); - } else { - GLog.w( TXT_NOT_ROGUE ); - return false; - } - } - - @Override - public String desc() { - return - "Wearing this dark garb, a rogue can perform a trick, that is called \"smoke bomb\" " + - "(though no real explosives are used): he blinds enemies who could see him and jumps aside."; - } - protected static CellSelector.Listener teleporter = new CellSelector.Listener() { @Override @@ -86,7 +67,7 @@ public class RogueArmor extends ClassArmor { !(Level.passable[target] || Level.avoid[target]) || Actor.findChar( target ) != null) { - GLog.w( TXT_FOV ); + GLog.w( Messages.get(RogueArmor.class, "fov") ); return; } @@ -112,7 +93,7 @@ public class RogueArmor extends ClassArmor { @Override public String prompt() { - return "Choose a location to jump to"; + return Messages.get(RogueArmor.class, "prompt"); } }; } \ No newline at end of file diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/ScaleArmor.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/ScaleArmor.java index b4845980f..8d88f89a0 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/ScaleArmor.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/ScaleArmor.java @@ -31,10 +31,5 @@ public class ScaleArmor extends Armor { public ScaleArmor() { super( 4 ); } - - @Override - public String desc() { - return - "The metal scales sewn onto a leather vest create a flexible, yet protective armor."; - } + } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/WarriorArmor.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/WarriorArmor.java index 08e9cb28c..3af6b8b93 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/WarriorArmor.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/armor/WarriorArmor.java @@ -20,6 +20,7 @@ */ package com.shatteredpixel.shatteredpixeldungeon.items.armor; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.watabou.noosa.Camera; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; @@ -46,8 +47,6 @@ public class WarriorArmor extends ClassArmor { private static final String AC_SPECIAL = "HEROIC LEAP"; - private static final String TXT_NOT_WARRIOR = "Only warriors can use this armor!"; - { image = ItemSpriteSheet.ARMOR_WARRIOR; } @@ -62,23 +61,6 @@ public class WarriorArmor extends ClassArmor { GameScene.selectCell( leaper ); } - @Override - public boolean doEquip( Hero hero ) { - if (hero.heroClass == HeroClass.WARRIOR) { - return super.doEquip( hero ); - } else { - GLog.w( TXT_NOT_WARRIOR ); - return false; - } - } - - @Override - public String desc() { - return - "While this armor looks heavy, it allows a warrior to perform heroic leap towards " + - "a targeted location, slamming down to stun all neighbouring enemies."; - } - protected static CellSelector.Listener leaper = new CellSelector.Listener() { @Override @@ -127,7 +109,7 @@ public class WarriorArmor extends ClassArmor { @Override public String prompt() { - return "Choose direction to leap"; + return Messages.get(WarriorArmor.class, "prompt"); } }; } \ No newline at end of file diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/messages/messages.properties b/src/com/shatteredpixel/shatteredpixeldungeon/messages/messages.properties index 34e960e10..b75dc6f94 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/messages/messages.properties +++ b/src/com/shatteredpixel/shatteredpixeldungeon/messages/messages.properties @@ -412,17 +412,42 @@ items.armor.glyphs.viscosity.deferred=deferred %d items.armor.glyphs.viscosity$defereddamage.name=Deferred damage items.armor.glyphs.viscosity$defereddamage.desc=While your armor's glyph has protected you from damage, it seems to be slowly paying you back for it.\n\nDamage is being dealt to you over time instead of immediately. You will take one damage per turn until there is no damage left.\n\nThere is %d deferred damage left. -items.armor.clotharmor.name=cloth armor -items.armor.huntressarmor.name=huntress cloak -items.armor.leatherarmor.name=leather armor -items.armor.magearmor.name=mage robe -items.armor.mailarmor.name=mail armor -items.armor.platearmor.name=plate armor -items.armor.roguearmor.name=rogue garb -items.armor.scalearmor.name=scale armor -items.armor.warriorarmor.name=warrior suit of armor +items.armor.armor.equip_cursed=your %s constricts around you painfully +items.armor.armor.identify=you are now familiar enough with your %s to identify it. It is %s. +items.armor.armor.incompatible=Interaction of different types of magic has erased the glyph on this armor! +items.armor.armor.curr_absorb=\n\nThis %s provides damage absorption up to %s points per attack. +items.armor.armor.avg_absorb=\n\nTypical %s provides damage absorption up to %d points per attack and requires %d points of strength. +items.armor.armor.too_heavy=\n\nBecause of your inadequate strength wearing this armor will decrease your movement speed and defense skill. +items.armor.armor.probably_too_heavy=\n\nProbably this armor is too heavy for you. +items.armor.armor.inscribed=\n\nIt is inscribed with a %s. +items.armor.armor.cursed_word=\n\nBecause this armor is cursed, you are powerless to remove it. +items.armor.armor.cursed=\n\nYou can feel a malevolent magic lurking within this armor. items.armor.armor$glyph.glyph=glyph items.armor.armor$glyph.killed=%s killed you... +items.armor.classarmor.low_hp=Your health is too low! +items.armor.classarmor.not_equipped=You need to be wearing this armor to use its special power! +items.armor.clotharmor.name=cloth armor +items.armor.clotharmor.desc=This lightweight armor offers basic protection. +items.armor.huntressarmor.name=huntress cloak +items.armor.huntressarmor.no_enemies=No enemies in sight +items.armor.huntressarmor.desc=A huntress in such cloak can create a fan of spectral blades. Each of these blades will target a single enemy in the huntress's field of view, inflicting damage depending on her currently equipped melee weapon. +items.armor.leatherarmor.name=leather armor +items.armor.leatherarmor.desc=Armor made from tanned monster hide. Not as light as cloth armor but provides better protection. +items.armor.magearmor.name=mage robe +items.armor.magearmor.desc=Wearing this gorgeous robe, a mage can cast a spell of molten earth: all the enemies in his field of view will be set on fire and unable to move at the same time. +items.armor.mailarmor.name=mail armor +items.armor.mailarmor.desc=Interlocking metal links make for a tough but flexible suit of armor. +items.armor.platearmor.name=plate armor +items.armor.platearmor.desc=Enormous plates of metal are joined together into a suit that provides unmatched protection to any adventurer strong enough to bear its staggering weight. +items.armor.roguearmor.name=rogue garb +items.armor.roguearmor.fov=You can only jump to an empty location in your field of view +items.armor.roguearmor.prompt=Choose a location to jump to +items.armor.roguearmor.desc=Wearing this dark garb, a rogue can perform a trick, that is called "smoke bomb": he blinds enemies who could see him and jumps aside. +items.armor.scalearmor.name=scale armor +items.armor.scalearmor.desc=The metal scales sewn onto a leather vest create a flexible, yet protective armor. +items.armor.warriorarmor.name=warrior suit of armor +items.armor.warriorarmor.prompt=Choose direction to leap +items.armor.warriorarmor.desc=While this armor looks heavy, it allows a warrior to perform heroic leap towards a targeted location, slamming down to stun all neighbouring enemies. items.artifacts.alchemiststoolkit.name=alchemists toolkit items.artifacts.capeofthorns.name=cape of Thorns