v0.3.4: externalized weapon strings

This commit is contained in:
Evan Debenham
2016-01-03 17:52:26 -05:00
committed by Evan Debenham
parent 26b5fd7ac4
commit 77c583b6b1
26 changed files with 134 additions and 291 deletions
@@ -202,31 +202,30 @@ public class Armor extends EquipableItem {
@Override
public String info() {
String name = name();
String info = desc();
if (levelKnown) {
info += Messages.get(Armor.class, "curr_absorb", name, Math.max( DR(), 0 ));
info += "\n\n" + Messages.get(Armor.class, "curr_absorb", Math.max( DR(), 0 ));
if (STR > Dungeon.hero.STR()) {
info += Messages.get(Armor.class, "too_heavy");
info += "\n\n" + Messages.get(Armor.class, "too_heavy");
}
} else {
info += Messages.get(Armor.class, "avg_absorb", name, typicalDR(), typicalSTR());
info += "\n\n" + Messages.get(Armor.class, "avg_absorb", typicalDR(), typicalSTR());
if (typicalSTR() > Dungeon.hero.STR()) {
info += Messages.get(Armor.class, "probably_too_heavy");
info += "\n\n" + Messages.get(Armor.class, "probably_too_heavy");
}
}
if (glyph != null) {
info += Messages.get(Armor.class, "inscribed", glyph.name());
info += "\n\n" + Messages.get(Armor.class, "inscribed", glyph.name());
}
if (cursed && isEquipped( Dungeon.hero )) {
info += Messages.get(Armor.class, "cursed_word");
info += "\n\n" + Messages.get(Armor.class, "cursed_worn");
} else if (cursedKnown && cursed) {
info += Messages.get(Armor.class, "cursed");
info += "\n\n" + Messages.get(Armor.class, "cursed");
}
return info;
@@ -242,12 +242,12 @@ public class Ring extends KindofMisc {
if (isEquipped( Dungeon.hero )) {
desc += Messages.get(Ring.class, "on_finger", name());
if (cursed) desc += Messages.get(Ring.class, "cursed_worn");
desc += "\n\n" + Messages.get(Ring.class, "on_finger", name());
if (cursed) desc += " " + Messages.get(Ring.class, "cursed_worn");
} else if (cursed && cursedKnown) {
desc += Messages.get(Ring.class, "curse_known", name());
desc += "\n\n" + Messages.get(Ring.class, "curse_known", name());
}
@@ -179,7 +179,7 @@ public abstract class Wand extends Item {
@Override
public String info() {
return (cursed && cursedKnown) ?
desc() + Messages.get(Wand.class, "cursed") :
desc() + "\n\n" + Messages.get(Wand.class, "cursed") :
desc();
}
@@ -44,10 +44,6 @@ abstract public class Weapon extends KindOfWeapon {
private static final int HITS_TO_KNOW = 20;
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_INCOMPATIBLE =
"Interaction of different types of magic has negated the enchantment on this weapon!";
private static final String TXT_TO_STRING = "%s :%d";
public int STR = 10;
@@ -73,7 +69,7 @@ abstract public class Weapon extends KindOfWeapon {
if (!levelKnown) {
if (--hitsToKnow <= 0) {
levelKnown = true;
GLog.i( TXT_IDENTIFY, name(), toString() );
GLog.i( Messages.get(Weapon.class, "identify", name(), toString()) );
Badges.validateItemLevelAquired( this );
}
}
@@ -167,7 +163,7 @@ abstract public class Weapon extends KindOfWeapon {
public Item upgrade( boolean enchant ) {
if (enchantment != null) {
if (!enchant && Random.Int( level() ) > 0) {
GLog.w( TXT_INCOMPATIBLE );
GLog.w( Messages.get(Weapon.class, "incompatible") );
enchant( null );
}
} else {
@@ -31,9 +31,5 @@ public class BattleAxe extends MeleeWeapon {
public BattleAxe() {
super( 4, 1.2f, 1f );
}
@Override
public String desc() {
return "The enormous steel head of this battle axe puts considerable heft behind each stroke.";
}
}
@@ -31,9 +31,5 @@ public class Dagger extends MeleeWeapon {
public Dagger() {
super( 1, 1.2f, 1f );
}
@Override
public String desc() {
return "A simple iron dagger with a well worn wooden handle.";
}
}
@@ -31,9 +31,5 @@ public class Glaive extends MeleeWeapon {
public Glaive() {
super( 5, 1f, 1f );
}
@Override
public String desc() {
return "A polearm consisting of a sword blade on the end of a pole.";
}
}
@@ -31,9 +31,5 @@ public class Knuckles extends MeleeWeapon {
public Knuckles() {
super( 1, 1f, 0.5f );
}
@Override
public String desc() {
return "A piece of iron shaped to fit around the knuckles.";
}
}
@@ -31,9 +31,5 @@ public class Longsword extends MeleeWeapon {
public Longsword() {
super( 4, 1f, 1f );
}
@Override
public String desc() {
return "This towering blade inflicts heavy damage by investing its heft into every cut.";
}
}
@@ -31,9 +31,5 @@ public class Mace extends MeleeWeapon {
public Mace() {
super( 3, 1f, 0.8f );
}
@Override
public String desc() {
return "The iron head of this weapon inflicts substantial damage.";
}
}
@@ -30,6 +30,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.*;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
@@ -52,12 +53,9 @@ public class MagesStaff extends MeleeWeapon {
public static final String AC_IMBUE = "IMBUE";
public static final String AC_ZAP = "ZAP";
private static final String TXT_SELECT_WAND = "Select a wand to consume";
private static final float STAFF_SCALE_FACTOR = 0.75f;
{
name = "mage's staff";
image = ItemSpriteSheet.MAGES_STAFF;
defaultAction = AC_ZAP;
@@ -86,7 +84,7 @@ public class MagesStaff extends MeleeWeapon {
this.wand = wand;
wand.maxCharges = Math.min(wand.maxCharges + 1, 10);
wand.curCharges = wand.maxCharges;
name = wand.name().replace("Wand", "Staff");
name = wand.name().replace(Messages.get(this, "wand"), Messages.get(this, "staff"));
}
@Override
@@ -109,7 +107,7 @@ public class MagesStaff extends MeleeWeapon {
if (action.equals(AC_IMBUE)) {
curUser = hero;
GameScene.selectItem(itemSelector, WndBag.Mode.WAND, TXT_SELECT_WAND);
GameScene.selectItem(itemSelector, WndBag.Mode.WAND, Messages.get(this, "prompt"));
} else if (action.equals(AC_ZAP)){
if (wand == null)
@@ -151,10 +149,10 @@ public class MagesStaff extends MeleeWeapon {
this.wand = null;
GLog.p("You imbue your staff with the " + wand.name());
GLog.p( Messages.get(this, "imbue", wand.name()));
if (enchantment != null) {
GLog.w("The conflicting magics erase the enchantment on your staff.");
GLog.w( Messages.get(this, "conflict") );
enchant(null);
}
@@ -180,12 +178,11 @@ public class MagesStaff extends MeleeWeapon {
wand.cursed = false;
wand.charge(owner);
name = wand.name().replace("Wand", "Staff");
name = wand.name().replace(Messages.get(this, "wand"), Messages.get(this, "staff"));
updateQuickslot();
return this;
}
@Override
@@ -259,64 +256,28 @@ public class MagesStaff extends MeleeWeapon {
wand = (Wand) bundle.get(WAND);
if (wand != null) {
wand.maxCharges = Math.min(wand.maxCharges + 1, 10);
name = wand.name().replace("wand", "staff");
name = wand.name().replace(Messages.get(this, "wand"), Messages.get(this, "staff"));
}
}
@Override
public String desc() {
String result = "Crafted by the mage himself, this extraordinary staff is a one of a kind multi-purpose magical weapon.\n" +
"\n" +
"Rather than having an innate magic in it, this staff is instead imbued with magical energy from a wand, permanently granting it new power.\n" +
"\n";
if (wand == null) {
result += "The staff is currently a slightly magical stick, it needs a wand!";
} else if (wand instanceof WandOfMagicMissile){
result += "The staff radiates consistent magical energy from the wand it is imbued with.";
} else if (wand instanceof WandOfFireblast){
result += "The staff burns and sizzles with fiery energy from the wand it is imbued with.";
} else if (wand instanceof WandOfLightning){
result += "The staff fizzes and crackles with electrical energy from the wand it is imbued with.";
} else if (wand instanceof WandOfDisintegration){
result += "The staff hums with deep and powerful energy from the wand it is imbued with.";
} else if (wand instanceof WandOfVenom){
result += "The staff drips and hisses with corrosive energy from the wand it is imbued with.";
} else if (wand instanceof WandOfPrismaticLight){
result += "The staff glows and shimmers with bright energy from the wand it is imbued with.";
} else if (wand instanceof WandOfFrost){
result += "The staff chills the air with the cold energy from the wand it is imbued with.";
} else if (wand instanceof WandOfBlastWave){
result += "The staff pops and crackles with explosive energy from the wand it is imbued with.";
} else if (wand instanceof WandOfRegrowth){
result += "The staff flourishes and grows with natural energy from the wand it is imbued with.";
} else if (wand instanceof WandOfTransfusion){
result += "The staff courses and flows with life energy from the wand it is imbued with.";
}
return result;
}
private final WndBag.Listener itemSelector = new WndBag.Listener() {
@Override
public void onSelect( final Item item ) {
if (item != null) {
if (!item.isIdentified()) {
GLog.w("You'll need to identify this wand first.");
GLog.w(Messages.get(this, "id_first"));
return;
} else if (item.cursed){
GLog.w("You can't use a cursed wand.");
GLog.w(Messages.get(this, "cursed"));
return;
}
GameScene.show(
new WndOptions("",
"Are you sure you want to imbue your staff with this " + item.name() + "?\n\n" +
"Your staff will inherit the highest level between it and the wand, " +
"and all magic currently affecting the staff will be lost.",
"Yes, i'm sure.",
"No, I changed my mind") {
Messages.get(this, "warning"),
Messages.get(this, "yes"),
Messages.get(this, "no")) {
@Override
protected void onSelect(int index) {
if (index == 0) {
@@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.watabou.utils.Random;
@@ -88,87 +89,49 @@ public class MeleeWeapon extends Weapon {
@Override
public String info() {
String name = name();
final String p = "\n\n";
StringBuilder info = new StringBuilder( desc() );
String quality = levelKnown && level() != 0 ? (level() > 0 ? "upgraded" : "degraded") : "";
info.append( p );
info.append( "This " + name + " is " + Utils.indefinite( quality ) );
info.append( " tier-" + tier + " melee weapon. " );
String info = desc();
info += "\n\n" + Messages.get(MeleeWeapon.class, "tier", tier);
if (levelKnown) {
int min = min();
int max = max();
info.append( "Its average damage is " +
Math.round((min + (max - min) / 2)*(imbue == Imbue.LIGHT ? 0.7f : (imbue == Imbue.HEAVY ? 1.5f : 1)))
+ " points per hit. " );
float dmgfactor = (imbue == Imbue.LIGHT ? 0.7f : imbue == Imbue.HEAVY ? 1.5f : 1);
info += " " + Messages.get(Weapon.class, "avg_dmg", Math.round((min + (max - min) / 2)*dmgfactor));
} else {
int min = minBase();
int max = maxBase();
info.append(
"Its typical average damage is " + (min + (max - min) / 2) + " points per hit " +
"and usually it requires " + typicalSTR() + " points of strength. " );
info += " " + Messages.get(MeleeWeapon.class, "unknown", (min + (max - min) / 2), typicalSTR());
if (typicalSTR() > Dungeon.hero.STR()) {
info.append( "Probably this weapon is too heavy for you. " );
info += " " + Messages.get(MeleeWeapon.class, "probably_too_heavy");
}
}
if (DLY != 1f) {
info.append( "This is a rather " + (DLY < 1f ? "fast" : "slow") );
if (ACU != 1f) {
if ((ACU > 1f) == (DLY < 1f)) {
info.append( " and ");
} else {
info.append( " but ");
}
info.append( ACU > 1f ? "accurate" : "inaccurate" );
}
info.append( " weapon. ");
} else if (ACU != 1f) {
info.append( "This is a rather " + (ACU > 1f ? "accurate" : "inaccurate") + " weapon. " );
}
switch (imbue) {
case LIGHT:
info.append( "It was balanced to be lighter. " );
info += " " + Messages.get(Weapon.class, "lighter");
break;
case HEAVY:
info.append( "It was balanced to be heavier. " );
info += " " + Messages.get(Weapon.class, "heavier");
break;
case NONE:
}
if (enchantment != null) {
info.append( "It is enchanted." );
String stats_desc = Messages.get(this, "stats_desc");
if (!stats_desc.equals("")) info+= "\n\n" + stats_desc;
if (levelKnown && STR > Dungeon.hero.STR()) {
info += "\n\n" + Messages.get(Weapon.class, "too_heavy");
}
if (cursed && isEquipped( Dungeon.hero )) {
info += "\n\n" + Messages.get(MeleeWeapon.class, "cursed_worn");
} else if (cursedKnown && cursed) {
info += "\n\n" + Messages.get(MeleeWeapon.class, "cursed");
}
if (levelKnown && Dungeon.hero.belongings.backpack.items.contains( this )) {
if (STR > Dungeon.hero.STR()) {
info.append( p );
info.append(
"Because of your inadequate strength the accuracy and speed " +
"of your attack with this " + name + " is decreased." );
}
if (STR < Dungeon.hero.STR()) {
info.append( p );
info.append(
"Because of your excess strength the damage " +
"of your attack with this " + name + " is increased." );
}
}
if (isEquipped( Dungeon.hero )) {
info.append( p );
info.append( "You hold the " + name + " at the ready" +
(cursed ? ", and because it is cursed, you are powerless to let go." : ".") );
} else {
if (cursedKnown && cursed) {
info.append( p );
info.append( "You can feel a malevolent magic lurking within the " + name +"." );
}
}
return info.toString();
return info;
}
@Override
@@ -31,9 +31,5 @@ public class Quarterstaff extends MeleeWeapon {
public Quarterstaff() {
super( 2, 1f, 1f );
}
@Override
public String desc() {
return "A staff of hardwood, its ends are shod with iron.";
}
}
@@ -99,12 +99,6 @@ public class ShortSword extends MeleeWeapon {
}
}
@Override
public String desc() {
return
"It is indeed quite short, just a few inches longer, than a dagger.";
}
private final WndBag.Listener itemSelector = new WndBag.Listener() {
@Override
public void onSelect( Item item ) {
@@ -31,9 +31,5 @@ public class Spear extends MeleeWeapon {
public Spear() {
super( 2, 1f, 1.5f );
}
@Override
public String desc() {
return "A slender wooden rod tipped with sharpened iron.";
}
}
@@ -31,9 +31,5 @@ public class Sword extends MeleeWeapon {
public Sword() {
super( 3, 1f, 1f );
}
@Override
public String desc() {
return "The razor-sharp length of steel blade shines reassuringly.";
}
}
@@ -31,11 +31,5 @@ public class WarHammer extends MeleeWeapon {
public WarHammer() {
super( 5, 1.2f, 1f );
}
@Override
public String desc() {
return
"Few creatures can withstand the crushing blow of this towering mass of lead and steel, " +
"but only the strongest of adventurers can use it effectively.";
}
}
@@ -24,6 +24,8 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.sprites.MissileSprite;
@@ -113,14 +115,13 @@ public class Boomerang extends MissileWeapon {
@Override
public String desc() {
String info =
"Thrown to the enemy this flat curved wooden missile will return to the hands of its thrower.";
String info = super.desc();
switch (imbue) {
case LIGHT:
info += "\n\nIt was balanced to be lighter. ";
info += "\n\n" + Messages.get(Weapon.class, "lighter");
break;
case HEAVY:
info += "\n\nIt was balanced to be heavier. ";
info += "\n\n" + Messages.get(Weapon.class, "heavier");
break;
case NONE:
}
@@ -62,13 +62,6 @@ public class CurareDart extends MissileWeapon {
super.proc( attacker, defender, damage );
}
@Override
public String desc() {
return
"These little evil darts don't do much damage but they can paralyze " +
"the target leaving it helpless and motionless for some time.";
}
@Override
public Item random() {
quantity = Random.Int( 2, 5 );
@@ -51,13 +51,6 @@ public class Dart extends MissileWeapon {
quantity = number;
}
@Override
public String desc() {
return
"These simple metal spikes are weighted to fly true and " +
"sting their prey with a flick of the wrist.";
}
@Override
public Item random() {
quantity = Random.Int( 5, 15 );
@@ -76,13 +76,6 @@ public class IncendiaryDart extends MissileWeapon {
super.proc( attacker, defender, damage );
}
@Override
public String desc() {
return
"The spike on each of these darts is designed to pin it to its target " +
"while the unstable compounds strapped to its length burst into brilliant flames.";
}
@Override
public Item random() {
quantity = Random.Int( 3, 6 );
@@ -60,13 +60,6 @@ public class Javelin extends MissileWeapon {
Buff.prolong( defender, Cripple.class, Cripple.DURATION );
}
@Override
public String desc() {
return
"This length of metal is weighted to keep the spike " +
"at its tip foremost as it sails through the air.";
}
@Override
public Item random() {
quantity = Random.Int( 5, 15 );
@@ -32,18 +32,13 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfSharpshooting;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
import com.watabou.utils.Random;
abstract public class MissileWeapon extends Weapon {
private static final String TXT_MISSILES = "Missile weapon";
private static final String TXT_YES = "Yes, I know what I'm doing";
private static final String TXT_NO = "No, I changed my mind";
private static final String TXT_R_U_SURE =
"Do you really want to equip it as a melee weapon?";
{
stackable = true;
levelKnown = true;
@@ -55,8 +50,8 @@ abstract public class MissileWeapon extends Weapon {
@Override
public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions( hero );
if (hero.heroClass != HeroClass.HUNTRESS && hero.heroClass != HeroClass.ROGUE) {
actions.remove( AC_EQUIP );
actions.remove( AC_EQUIP );
if (!isEquipped( hero )) {
actions.remove( AC_UNEQUIP );
}
return actions;
@@ -114,22 +109,6 @@ abstract public class MissileWeapon extends Weapon {
}
}
@Override
public boolean doEquip( final Hero hero ) {
GameScene.show(
new WndOptions( TXT_MISSILES, TXT_R_U_SURE, TXT_YES, TXT_NO ) {
@Override
protected void onSelect(int index) {
if (index == 0) {
MissileWeapon.super.doEquip( hero );
}
};
}
);
return false;
}
@Override
public Item random() {
return this;
@@ -148,30 +127,16 @@ abstract public class MissileWeapon extends Weapon {
@Override
public String info() {
String name = name();
StringBuilder info = new StringBuilder( desc() );
String info = desc();
info.append( "\n\nAverage damage of this weapon equals to " + (min() + (max() - min()) / 2) + " points per hit. " );
if (Dungeon.hero.belongings.backpack.items.contains( this )) {
if (STR > Dungeon.hero.STR()) {
info.append(
"\n\nBecause of your inadequate strength the accuracy and speed " +
"of your attack with this " + name + " is decreased." );
}
if (STR < Dungeon.hero.STR() && Dungeon.hero.heroClass == HeroClass.HUNTRESS) {
info.append(
"\n\nBecause of your excess strength the damage " +
"of your attack with this " + name + " is increased." );
}
info += "\n\n" + Messages.get( Weapon.class, "avg_dmg",(min() + (max() - min()) / 2));
if (STR > Dungeon.hero.STR()) {
info += Messages.get(Weapon.class, "too_heavy");
}
info.append( "\n\nAs this weapon is designed to be used at a distance, it is much less accurate if used at melee range.");
info += "\n\n" + Messages.get(MissileWeapon.class, "distance");
if (isEquipped( Dungeon.hero )) {
info.append( "\n\nYou hold the " + name + " at the ready." );
}
return info.toString();
return info;
}
}
@@ -53,13 +53,6 @@ public class Shuriken extends MissileWeapon {
quantity = number;
}
@Override
public String desc() {
return
"Star-shaped pieces of metal with razor-sharp blades do significant damage " +
"when they hit a target. They can be thrown at very high rate.";
}
@Override
public Item random() {
quantity = Random.Int( 5, 15 );
@@ -60,13 +60,6 @@ public class Tamahawk extends MissileWeapon {
Buff.affect( defender, Bleeding.class ).set( damage );
}
@Override
public String desc() {
return
"This throwing axe is not that heavy, but it still " +
"requires significant strength to be used effectively.";
}
@Override
public Item random() {
quantity = Random.Int( 5, 12 );