From fb2c6e330767649cb61148a88f99c8b832d4ad1d Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 2 Jan 2016 07:04:08 -0500 Subject: [PATCH] v0.3.4: externalized ring strings --- .../items/rings/Ring.java | 55 ++++++++----------- .../items/rings/RingOfAccuracy.java | 8 --- .../items/rings/RingOfElements.java | 8 --- .../items/rings/RingOfEvasion.java | 10 ---- .../items/rings/RingOfForce.java | 18 ------ .../items/rings/RingOfFuror.java | 9 --- .../items/rings/RingOfHaste.java | 8 --- .../items/rings/RingOfMagic.java | 8 --- .../items/rings/RingOfMight.java | 9 --- .../items/rings/RingOfSharpshooting.java | 9 --- .../items/rings/RingOfTenacity.java | 9 --- .../items/rings/RingOfWealth.java | 9 --- .../messages/messages.properties | 33 +++++++++++ 13 files changed, 56 insertions(+), 137 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/Ring.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/Ring.java index 2bd8fc09f..4fd9ba460 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/Ring.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/Ring.java @@ -32,6 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; @@ -45,13 +46,6 @@ public class Ring extends KindofMisc { private static final float TIME_TO_EQUIP = 1f; - 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_UNEQUIP_TITLE = "Unequip one item"; - private static final String TXT_UNEQUIP_MESSAGE = - "You can only wear two misc items at a time."; - protected Buff buff; private static final Class[] rings = { @@ -91,7 +85,7 @@ public class Ring extends KindofMisc { @SuppressWarnings("unchecked") public static void initGems() { - handler = new ItemStatusHandler( (Class[])rings, gems, images ); + handler = new ItemStatusHandler<>( (Class[])rings, gems, images ); } public static void save( Bundle bundle ) { @@ -100,7 +94,7 @@ public class Ring extends KindofMisc { @SuppressWarnings("unchecked") public static void restore( Bundle bundle ) { - handler = new ItemStatusHandler( (Class[])rings, gems, images, bundle ); + handler = new ItemStatusHandler<>( (Class[])rings, gems, images, bundle ); } public Ring() { @@ -129,7 +123,8 @@ public class Ring extends KindofMisc { final KindofMisc m2 = hero.belongings.misc2; ShatteredPixelDungeon.scene().add( - new WndOptions(TXT_UNEQUIP_TITLE, TXT_UNEQUIP_MESSAGE, + new WndOptions(Messages.get(Ring.class, "unequip_title"), + Messages.get(Ring.class, "unequip_message"), Utils.capitalize(m1.toString()), Utils.capitalize(m2.toString())) { @@ -160,7 +155,7 @@ public class Ring extends KindofMisc { cursedKnown = true; if (cursed) { equipCursed( hero ); - GLog.n( "your " + this + " tightens around your finger painfully" ); + GLog.n( Messages.get(this, "cursed", this) ); } hero.spendAndNext( TIME_TO_EQUIP ); @@ -230,35 +225,33 @@ public class Ring extends KindofMisc { Badges.validateAllRingsIdentified(); } - - @Override - public String name() { - return isKnown() ? super.name() : gem + " ring"; + + public String gem() { + return Messages.get(Ring.class, gem); } @Override - public String desc() { - return - "This metal band is adorned with a large " + gem + " gem " + - "that glitters in the darkness. Who knows what effect it has when worn?"; + public String name() { + return isKnown() ? super.name() : Messages.get(this, "unknown_name", gem()); } @Override public String info() { + + String desc = isKnown()? desc() : Messages.get(this, "unknown_desc", gem()); + if (isEquipped( Dungeon.hero )) { - return desc() + "\n\n" + "The " + name() + " is on your finger" + - (cursed ? ", and because it is cursed, you are powerless to remove it." : "." ); + desc += Messages.get(Ring.class, "on_finger", name()); + if (cursed) desc += Messages.get(Ring.class, "cursed_worn"); } else if (cursed && cursedKnown) { - - return desc() + "\n\nYou can feel a malevolent magic lurking within the " + name() + "."; - - } else { - - return desc(); - + + desc += Messages.get(Ring.class, "curse_known", name()); + } + + return desc; } @Override @@ -336,8 +329,6 @@ public class Ring extends KindofMisc { public class RingBuff extends Buff { - private static final String TXT_KNOWN = "This is a %s"; - public int level; public RingBuff() { level = Ring.this.level(); @@ -348,7 +339,7 @@ public class Ring extends KindofMisc { if (target instanceof Hero && ((Hero)target).heroClass == HeroClass.ROGUE && !isKnown()) { setKnown(); - GLog.i( TXT_KNOWN, name() ); + GLog.i( Messages.get(Ring.class, "known", name()) ); Badges.validateItemLevelAquired( Ring.this ); } @@ -361,7 +352,7 @@ public class Ring extends KindofMisc { if (!isIdentified() && --ticksToKnow <= 0) { String gemName = name(); identify(); - GLog.w( TXT_IDENTIFY, gemName, Ring.this.toString() ); + GLog.w( Messages.get(Ring.class, "identify", gemName, Ring.this.toString()) ); Badges.validateItemLevelAquired( Ring.this ); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfAccuracy.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfAccuracy.java index a1bbedfbb..5811a5cd8 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfAccuracy.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfAccuracy.java @@ -27,14 +27,6 @@ public class RingOfAccuracy extends Ring { return new Accuracy(); } - @Override - public String desc() { - return isKnown() ? - "This ring increases your focus, reducing your enemy's ability to dodge your attacks. "+ - "A degraded ring will instead make you easier to evade.": - super.desc(); - } - public class Accuracy extends RingBuff { } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfElements.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfElements.java index 38c16150b..b1339f828 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfElements.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfElements.java @@ -37,14 +37,6 @@ public class RingOfElements extends Ring { protected RingBuff buff( ) { return new Resistance(); } - - @Override - public String desc() { - return isKnown() ? - "This ring provides resistance to different elements, such as fire, " + - "electricity, gases etc. Also it decreases duration of negative effects." : - super.desc(); - } private static final HashSet> EMPTY = new HashSet>(); private static final HashSet> FULL; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfEvasion.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfEvasion.java index ec8c06f76..2d4166fd7 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfEvasion.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfEvasion.java @@ -30,16 +30,6 @@ public class RingOfEvasion extends Ring { protected RingBuff buff( ) { return new Evasion(); } - - @Override - public String desc() { - return isKnown() ? - "This ring obfuscates the true position of the wearer, making them harder to detect and attack. " + - "This ring is much stronger while the user remains undetected, and if the user is targeted the power of " + - "evasion will slowly fade away, remaining undetected will restore the ring's effectiveness. " + - "A degraded ring will instead make the user easier to detect and strike.": - super.desc(); - } //yup, the only ring in the game with logic inside of its class public class Evasion extends RingBuff { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfForce.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfForce.java index ce80b00f2..1c2b4fd3d 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfForce.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfForce.java @@ -29,24 +29,6 @@ public class RingOfForce extends Ring { return new Force(); } - @Override - public String desc() { - if (isKnown()){ - String desc = "This ring enhances the force of the wearer's blows. " + - "This extra power is largely wasted when wielding weapons, " + - "but an unarmed attack will be made much stronger. " + - "A degraded ring will instead weaken the wearer's blows.\n\n" + - "When unarmed, at your current strength, "; - int str = Dungeon.hero.STR() - 8; - desc += levelKnown ? - "average damage with this ring is " + (str/2+level() + (int)(str*0.5f*level()) + str*2)/2 + " points per hit.": - "typical average damage with this ring is" + (str/2+1 + (int)(str*0.5f) + str*2)/2 + " points per hit."; - desc += " Wearing a second ring of force would enhance this."; - return desc; - } else - return super.desc(); - } - public class Force extends RingBuff { } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfFuror.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfFuror.java index 3c172e22f..3fe5fee17 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfFuror.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfFuror.java @@ -27,15 +27,6 @@ public class RingOfFuror extends Ring { return new Furor(); } - @Override - public String desc() { - return isKnown() ? - "This ring grants the wearer an inner fury, allowing them to attack more rapidly. " + - "This fury works best in large bursts, so slow weapons benefit far more than fast ones. " + - "A degraded ring will instead slow the wearer's speed of attack." : - super.desc(); - } - public class Furor extends RingBuff { } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfHaste.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfHaste.java index 2e4934849..f27ed41fe 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfHaste.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfHaste.java @@ -27,14 +27,6 @@ public class RingOfHaste extends Ring { return new Haste(); } - @Override - public String desc() { - return isKnown() ? - "This ring reduces the stress of movement on the wearer, allowing them to run " + - "at superhuman speeds. A degraded ring will instead weigh the wearer down.": - super.desc(); - } - public class Haste extends RingBuff { } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfMagic.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfMagic.java index d73a547d2..805218356 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfMagic.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfMagic.java @@ -27,14 +27,6 @@ public class RingOfMagic extends Ring { return new Magic(); } - @Override - public String desc() { - return isKnown() ? - "Your wands will become more powerful in the arcane field " + - "that radiates from this ring. Degraded rings of magic will instead weaken your wands." : - super.desc(); - } - public class Magic extends RingBuff { } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfMight.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfMight.java index 493da2084..f3c5616a3 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfMight.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfMight.java @@ -28,15 +28,6 @@ public class RingOfMight extends Ring { return new Might(); } - @Override - public String desc() { - return isKnown() ? - "This ring enhances the physical traits of the wearer, " + - "granting them greater physical strength and constitution. " + - "A degraded ring will weaken the wearer." : - super.desc(); - } - public class Might extends RingBuff { } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfSharpshooting.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfSharpshooting.java index b117fddf8..ddfd752ae 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfSharpshooting.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfSharpshooting.java @@ -27,15 +27,6 @@ public class RingOfSharpshooting extends Ring { return new Aim(); } - @Override - public String desc() { - return isKnown() ? - "This ring enhances the wearer's precision and aim, which will " + - "make all projectile weapons more accurate and durable. " + - "A degraded ring will have the opposite effect.": - super.desc(); - } - public class Aim extends RingBuff { } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfTenacity.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfTenacity.java index 15efd7450..0c9376c15 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfTenacity.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfTenacity.java @@ -27,15 +27,6 @@ public class RingOfTenacity extends Ring { return new Tenacity(); } - @Override - public String desc() { - return isKnown() ? - "When worn, this ring will allow the wearer to resist normally mortal strikes. " + - "The more injured the user is, the more resistant they will be to damage. " + - "A degraded ring will instead make it easier for enemies to execute the wearer." : - super.desc(); - } - public class Tenacity extends RingBuff { } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfWealth.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfWealth.java index a93f0f012..17d9a7c9b 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfWealth.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfWealth.java @@ -27,15 +27,6 @@ public class RingOfWealth extends Ring { return new Wealth(); } - @Override - public String desc() { - return isKnown() ? - "It's not clear what this ring does exactly, good luck may influence " + - "the life of an adventurer in many subtle ways. " + - "Naturally a degraded ring would give bad luck." : - super.desc(); - } - public class Wealth extends RingBuff { } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/messages/messages.properties b/src/com/shatteredpixel/shatteredpixeldungeon/messages/messages.properties index 2b2b5c851..34e960e10 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/messages/messages.properties +++ b/src/com/shatteredpixel/shatteredpixeldungeon/messages/messages.properties @@ -590,17 +590,50 @@ items.quest.pickaxe.desc=This is a large and sturdy tool for breaking rocks. Pro items.quest.ratskull.name=giant rat skull items.quest.ratskull.desc=A surprisingly large rat skull. It would make a great hunting trophy, if you had a wall to mount it on. +items.rings.ring.diamond=diamond +items.rings.ring.opal=opal +items.rings.ring.garnet=garnet +items.rings.ring.ruby=ruby +items.rings.ring.amethyst=amethyst +items.rings.ring.topaz=topaz +items.rings.ring.onyx=onyx +items.rings.ring.tourmaline=tourmaline +items.rings.ring.emerald=emerald +items.rings.ring.sapphire=sapphire +items.rings.ring.quartz=quartz +items.rings.ring.agate=agate +items.rings.ring.cursed=your %s tightens around your finger painfully +items.rings.ring.unknown_name=%s ring +items.rings.ring.unknown_desc=This metal band is adorned with a large %s gem that glitters in the darkness. Who knows what effect it has when worn? +items.rings.ring.known=This is a %s +items.rings.ring.identify=You are now familiar enough with your %s to identify it. It is %s. +items.rings.ring.on_finger=\n\nThe %s is on your finger. +items.rings.ring.cursed_worn=Because it is cursed, you are powerless to remove it. +items.rings.ring.curse_known=\n\nYou can feel a malevolent magic lurking within the %s. +items.rings.ring.unequip_title=Unequip one item +items.rings.ring.unequip_message=You can only wear two misc items at a time. items.rings.ringofaccuracy.name=ring of accuracy +items.rings.ringofaccuracy.desc=This ring increases your focus, reducing your enemy's ability to dodge your attacks. A degraded ring will instead make you easier to evade. items.rings.ringofelements.name=ring of elements +items.rings.ringofelements.desc=This ring provides resistance to different elements, such as fire, electricity, gases etc. Also it decreases duration of negative effects. items.rings.ringofevasion.name=ring of evasion +items.rings.ringofevasion.desc=This ring obfuscates the true position of the wearer, making them harder to detect and attack. This ring is much stronger while the user remains undetected, and if the user is targeted the power of evasion will slowly fade away, remaining undetected will restore the ring's effectiveness. A degraded ring will instead make the user easier to detect and strike. items.rings.ringofforce.name=ring of force +items.rings.ringofforce.desc=This ring enhances the force of the wearer's blows. This extra power is largely wasted when wielding weapons, but an unarmed attack will be made much stronger. A degraded ring will instead weaken the wearer's blows. items.rings.ringoffuror.name=ring of furor +items.rings.ringoffuror.desc=This ring grants the wearer an inner fury, allowing them to attack more rapidly. This fury works best in large bursts, so slow weapons benefit far more than fast ones. A degraded ring will instead slow the wearer's speed of attack. items.rings.ringofhaste.name=ring of haste +items.rings.ringofhaste.desc=This ring reduces the stress of movement on the wearer, allowing them to run at superhuman speeds. A degraded ring will instead weigh the wearer down. items.rings.ringofmagic.name=ring of magic +items.rings.ringofmagic.desc=Your wands will become more powerful in the arcane field that radiates from this ring. Degraded rings of magic will instead weaken your wands. items.rings.ringofmight.name=ring of might +items.rings.ringofmight.desc=This ring enhances the physical traits of the wearer, granting them greater physical strength and constitution. A degraded ring will weaken the wearer. items.rings.ringofsharpshooting.name=ring of sharpshooting +items.rings.ringofsharpshooting.desc=This ring enhances the wearer's precision and aim, which will make all projectile weapons more accurate and durable. A degraded ring will have the opposite effect. items.rings.ringoftenacity.name=ring of tenacity +items.rings.ringoftenacity.desc=When worn, this ring will allow the wearer to resist normally mortal strikes. The more injured the user is, the more resistant they will be to damage. A degraded ring will instead make it easier for enemies to execute the wearer. items.rings.ringofwealth.name=ring of wealth +items.rings.ringofwealth.desc=It's not clear what this ring does exactly, good luck may influence the life of an adventurer in many subtle ways. Naturally a degraded ring would give bad luck. items.scrolls.scroll.kaunan=KAUNAN items.scrolls.scroll.sowilo=SOWILO