v0.3.4: externalized scroll strings

This commit is contained in:
Evan Debenham
2016-01-02 06:12:59 -05:00
committed by Evan Debenham
parent 5ab29b50fa
commit 7ee1f86ee2
19 changed files with 114 additions and 192 deletions
@@ -20,6 +20,7 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.items.scrolls;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
@@ -30,15 +31,9 @@ import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
public abstract class InventoryScroll extends Scroll {
protected String inventoryTitle = "Select an item";
protected String inventoryTitle = Messages.get(this, "inv_title");
protected WndBag.Mode mode = WndBag.Mode.ALL;
private static final String TXT_WARNING =
"Do you really want to cancel this scroll usage? " +
"It will be consumed anyway.";
private static final String TXT_YES = "Yes, I'm positive";
private static final String TXT_NO = "No, I changed my mind";
@Override
protected void doRead() {
@@ -53,7 +48,8 @@ public abstract class InventoryScroll extends Scroll {
}
private void confirmCancelation() {
GameScene.show( new WndOptions( name(), TXT_WARNING, TXT_YES, TXT_NO ) {
GameScene.show( new WndOptions( name(), Messages.get(this, "warning"),
Messages.get(this, "yes"), Messages.get(this, "no") ) {
@Override
protected void onSelect( int index ) {
switch (index) {
@@ -26,6 +26,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.UnstableSpellbook;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
@@ -35,17 +36,12 @@ import java.util.ArrayList;
import java.util.HashSet;
public abstract class Scroll extends Item {
private static final String TXT_BLINDED = "You can't read a scroll while blinded";
private static final String TXT_CURSED = "Your cursed spellbook prevents you from invoking this scroll's magic! " +
"A scroll of remove curse might be strong enough to still work though...";
public static final String AC_READ = "READ";
protected static final float TIME_TO_READ = 1f;
protected String initials;
protected String initials = Messages.get(this, "initials");
private static final Class<?>[] scrolls = {
ScrollOfIdentify.class,
@@ -90,7 +86,7 @@ public abstract class Scroll extends Item {
@SuppressWarnings("unchecked")
public static void initLabels() {
handler = new ItemStatusHandler<Scroll>( (Class<? extends Scroll>[])scrolls, runes, images );
handler = new ItemStatusHandler<>( (Class<? extends Scroll>[])scrolls, runes, images );
}
public static void save( Bundle bundle ) {
@@ -99,7 +95,7 @@ public abstract class Scroll extends Item {
@SuppressWarnings("unchecked")
public static void restore( Bundle bundle ) {
handler = new ItemStatusHandler<Scroll>( (Class<? extends Scroll>[])scrolls, runes, images, bundle );
handler = new ItemStatusHandler<>( (Class<? extends Scroll>[])scrolls, runes, images, bundle );
}
public Scroll() {
@@ -125,11 +121,11 @@ public abstract class Scroll extends Item {
if (action.equals( AC_READ )) {
if (hero.buff( Blindness.class ) != null) {
GLog.w( TXT_BLINDED );
GLog.w( Messages.get(this, "blinded") );
} else if (hero.buff(UnstableSpellbook.bookRecharge.class) != null
&& hero.buff(UnstableSpellbook.bookRecharge.class).isCursed()
&& !(this instanceof ScrollOfRemoveCurse)) {
GLog.n( TXT_CURSED );
GLog.n( Messages.get(this, "cursed") );
} else {
curUser = hero;
curItem = detach( hero.belongings.backpack );
@@ -168,18 +164,21 @@ public abstract class Scroll extends Item {
setKnown();
return super.identify();
}
public String rune() {
return Messages.get(Scroll.class, rune);
}
@Override
public String name() {
return isKnown() ? name : "scroll \"" + rune + "\"";
return isKnown() ? name : Messages.get(this, "unknown_name", rune());
}
@Override
public String info() {
return isKnown() ?
desc() :
"This parchment is covered with indecipherable writing, and bears a title " +
"of rune " + rune + ". Who knows what it will do when read aloud?";
Messages.get(this, "unknown_desc", rune());
}
public String initials(){
@@ -23,15 +23,13 @@ package com.shatteredpixel.shatteredpixeldungeon.items.scrolls;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.effects.Identification;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
public class ScrollOfIdentify extends InventoryScroll {
{
initials = "Id";
inventoryTitle = "Select an item to identify";
mode = WndBag.Mode.UNIDENTIFED;
bones = true;
@@ -43,17 +41,11 @@ public class ScrollOfIdentify extends InventoryScroll {
curUser.sprite.parent.add( new Identification( curUser.sprite.center().offset( 0, -16 ) ) );
item.identify();
GLog.i( "It is " + item );
GLog.i( Messages.get(this, "it_is", item) );
Badges.validateItemLevelAquired( item );
}
@Override
public String desc() {
return
"Permanently reveals all of the secrets of a single item.";
}
@Override
public int price() {
return isKnown() ? 30 * quantity : super.price();
@@ -21,6 +21,7 @@
package com.shatteredpixel.shatteredpixeldungeon.items.scrolls;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Drowsy;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
@@ -32,10 +33,6 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class ScrollOfLullaby extends Scroll {
{
initials = "Lu";
}
@Override
protected void doRead() {
@@ -53,19 +50,13 @@ public class ScrollOfLullaby extends Scroll {
Buff.affect( curUser, Drowsy.class );
GLog.i( "The scroll utters a soothing melody. You feel very sleepy." );
GLog.i( Messages.get(this, "sooth") );
setKnown();
readAnimation();
}
@Override
public String desc() {
return
"A soothing melody will lull all who hear it into a deep magical sleep ";
}
@Override
public int price() {
return isKnown() ? 50 * quantity : super.price();
@@ -20,6 +20,7 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.items.scrolls;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
@@ -34,12 +35,6 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class ScrollOfMagicMapping extends Scroll {
private static final String TXT_LAYOUT = "You are now aware of the level layout.";
{
initials = "MM";
}
@Override
protected void doRead() {
@@ -72,7 +67,7 @@ public class ScrollOfMagicMapping extends Scroll {
}
Dungeon.observe();
GLog.i( TXT_LAYOUT );
GLog.i( Messages.get(this, "layout") );
if (noticed) {
Sample.INSTANCE.play( Assets.SND_SECRET );
}
@@ -86,14 +81,6 @@ public class ScrollOfMagicMapping extends Scroll {
readAnimation();
}
@Override
public String desc() {
return
"When this scroll is read, an image of crystal clarity will be etched into your memory, " +
"alerting you to the precise layout of the level and revealing all hidden secrets. " +
"The locations of items and creatures will remain unknown.";
}
@Override
public int price() {
return isKnown() ? 25 * quantity : super.price();
@@ -27,17 +27,13 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
public class ScrollOfMagicalInfusion extends InventoryScroll {
private static final String TXT_INFUSE = "your %s is infused with arcane energy!";
{
initials = "MaI";
inventoryTitle = "Select an item to infuse";
mode = WndBag.Mode.ENCHANTABLE;
bones = true;
@@ -52,19 +48,12 @@ public class ScrollOfMagicalInfusion extends InventoryScroll {
else
((Armor)item).upgrade(true);
GLog.p( TXT_INFUSE, item.name() );
GLog.p( Messages.get(this, "infuse", item.name()) );
Badges.validateItemLevelAquired(item);
curUser.sprite.emitter().start(Speck.factory(Speck.UP), 0.2f, 3);
Enchanting.show(curUser, item);
}
@Override
public String desc() {
return
"This scroll will infuse a weapon or armor with powerful magical energy.\n\n" +
"In addition to being upgraded, A weapon will gain a magical enchantment, or armor will be imbued with a magical glyph.\n\n" +
"If the item already has an enchantment or glyph, it will never be erased by this scroll.";
}
}
@@ -35,10 +35,6 @@ public class ScrollOfMirrorImage extends Scroll {
private static final int NIMAGES = 3;
{
initials = "MI";
}
@Override
protected void doRead() {
@@ -73,10 +69,5 @@ public class ScrollOfMirrorImage extends Scroll {
readAnimation();
}
@Override
public String desc() {
return
"The incantation on this scroll will create illusionary twins of the reader, which will chase his enemies.";
}
}
@@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.scrolls;
import com.shatteredpixel.shatteredpixeldungeon.ResultDescriptions;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.watabou.noosa.audio.Sample;
@@ -38,8 +39,6 @@ import com.watabou.utils.Random;
public class ScrollOfPsionicBlast extends Scroll {
{
initials = "PB";
bones = true;
}
@@ -68,18 +67,10 @@ public class ScrollOfPsionicBlast extends Scroll {
if (!curUser.isAlive()) {
Dungeon.fail( Utils.format(ResultDescriptions.ITEM, name ));
GLog.n("The Psionic Blast tears your mind apart...");
GLog.n( Messages.get(this, "ondeath") );
}
}
@Override
public String desc() {
return
"This scroll contains destructive energy that can be psionically channeled to tear apart " +
"the minds of all visible creatures. The power unleashed by the scroll will also temporarily " +
"blind, stun, and seriously harm the reader.";
}
@Override
public int price() {
return isKnown() ? 80 * quantity : super.price();
@@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.scrolls;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
@@ -34,10 +35,6 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class ScrollOfRage extends Scroll {
{
initials = "Ra";
}
@Override
protected void doRead() {
@@ -59,7 +56,7 @@ public class ScrollOfRage extends Scroll {
}
}
GLog.w( "The scroll emits an enraging roar that echoes throughout the dungeon!" );
GLog.w( Messages.get(this, "roar") );
setKnown();
curUser.sprite.centerEmitter().start( Speck.factory( Speck.SCREAM ), 0.3f, 3 );
@@ -68,11 +65,5 @@ public class ScrollOfRage extends Scroll {
readAnimation();
}
@Override
public String desc() {
return
"When read aloud, this scroll will unleash a great roar " +
"that draws all enemies to the reader, and enrages nearby ones.";
}
}
@@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.scrolls;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Recharging;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
@@ -33,10 +34,6 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class ScrollOfRecharging extends Scroll {
public static final float BUFF_DURATION = 30f;
{
initials = "Re";
}
@Override
protected void doRead() {
@@ -47,20 +44,13 @@ public class ScrollOfRecharging extends Scroll {
Sample.INSTANCE.play( Assets.SND_READ );
Invisibility.dispel();
GLog.i( "a surge of energy courses through your body, invigorating your wands.");
GLog.i( Messages.get(this, "surge") );
SpellSprite.show( curUser, SpellSprite.CHARGE );
setKnown();
readAnimation();
}
@Override
public String desc() {
return
"The raw magical power bound up in this parchment will, when released, " +
"charge up all the users wands over time.";
}
public static void charge( Hero hero ) {
hero.sprite.centerEmitter().burst( EnergyParticle.FACTORY, 15 );
}
@@ -21,6 +21,7 @@
package com.shatteredpixel.shatteredpixeldungeon.items.scrolls;
import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
@@ -32,15 +33,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class ScrollOfRemoveCurse extends Scroll {
private static final String TXT_PROCCED =
"Your pack glows with a cleansing light, and a malevolent energy disperses.";
private static final String TXT_NOT_PROCCED =
"Your pack glows with a cleansing light, but nothing happens.";
{
initials = "RC";
}
@Override
protected void doRead() {
@@ -59,9 +51,9 @@ public class ScrollOfRemoveCurse extends Scroll {
Weakness.detach( curUser, Weakness.class );
if (procced) {
GLog.p( TXT_PROCCED );
GLog.p( Messages.get(this, "cleansed") );
} else {
GLog.i( TXT_NOT_PROCCED );
GLog.i( Messages.get(this, "not_cleansed") );
}
setKnown();
@@ -69,14 +61,6 @@ public class ScrollOfRemoveCurse extends Scroll {
readAnimation();
}
@Override
public String desc() {
return
"The incantation on this scroll will instantly strip from " +
"the reader's weapon, armor, rings and carried items any evil " +
"enchantments that might prevent the wearer from removing them.";
}
public static boolean uncurse( Hero hero, Item... items ) {
boolean procced = false;
@@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.scrolls;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
@@ -31,16 +32,6 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.noosa.tweeners.AlphaTweener;
public class ScrollOfTeleportation extends Scroll {
public static final String TXT_TELEPORTED =
"In a blink of an eye you were teleported to another location of the level.";
public static final String TXT_NO_TELEPORT =
"Strong magic aura of this place prevents you from teleporting!";
{
initials = "TP";
}
@Override
protected void doRead() {
@@ -67,7 +58,7 @@ public class ScrollOfTeleportation extends Scroll {
if (pos == -1 || Dungeon.bossLevel()) {
GLog.w( TXT_NO_TELEPORT );
GLog.w( Messages.get(ScrollOfTeleportation.class, "no_tele") );
} else {
@@ -75,7 +66,7 @@ public class ScrollOfTeleportation extends Scroll {
Dungeon.level.press( pos, hero );
Dungeon.observe();
GLog.i( TXT_TELEPORTED );
GLog.i( Messages.get(ScrollOfTeleportation.class, "tele") );
}
}
@@ -96,15 +87,6 @@ public class ScrollOfTeleportation extends Scroll {
Sample.INSTANCE.play( Assets.SND_TELEPORT );
}
@Override
public String desc() {
return
"The spell on this parchment instantly transports the reader " +
"to a random location on the dungeon level. It can be used " +
"to escape a dangerous situation, but the unlucky reader might " +
"find himself in an even more dangerous place.";
}
@Override
public int price() {
return isKnown() ? 40 * quantity : super.price();
@@ -20,6 +20,7 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.items.scrolls;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
@@ -32,10 +33,6 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class ScrollOfTerror extends Scroll {
{
initials = "Te";
}
@Override
protected void doRead() {
@@ -59,26 +56,19 @@ public class ScrollOfTerror extends Scroll {
switch (count) {
case 0:
GLog.i( "The scroll emits a brilliant flash of red light" );
GLog.i( Messages.get(this, "none") );
break;
case 1:
GLog.i( "The scroll emits a brilliant flash of red light and the " + affected.name + " flees!" );
GLog.i( Messages.get(this, "one", affected.name) );
break;
default:
GLog.i( "The scroll emits a brilliant flash of red light and the monsters flee!" );
GLog.i( Messages.get(this, "many") );
}
setKnown();
readAnimation();
}
@Override
public String desc() {
return
"A flash of red light will overwhelm all creatures in your field of view with terror, " +
"and they will turn and flee. Attacking a fleeing enemy will dispel the effect.";
}
@Override
public int price() {
return isKnown() ? 50 * quantity : super.price();
@@ -25,17 +25,13 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
public class ScrollOfUpgrade extends InventoryScroll {
public static final String TXT_LOOKS_BETTER = "your %s certainly looks better now";
{
initials = "Up";
inventoryTitle = "Select an item to upgrade";
mode = WndBag.Mode.UPGRADEABLE;
bones = true;
@@ -48,7 +44,7 @@ public class ScrollOfUpgrade extends InventoryScroll {
item.upgrade();
upgrade( curUser );
GLog.p( TXT_LOOKS_BETTER, item.name() );
GLog.p( Messages.get(this, "look_better", item.name()) );
Badges.validateItemLevelAquired( item );
}
@@ -56,14 +52,5 @@ public class ScrollOfUpgrade extends InventoryScroll {
public static void upgrade( Hero hero ) {
hero.sprite.emitter().start( Speck.factory( Speck.UP ), 0.2f, 3 );
}
@Override
public String desc() {
return
"This scroll will upgrade a single item, improving its quality. A wand will " +
"increase in power and in number of charges; a weapon will inflict more damage " +
"or find its mark more frequently; a suit of armor will deflect additional blows; " +
"the effect of a ring on its wearer will intensify. Weapons and armor will also " +
"require less strength to use, and any curses on the item will be lifted.";
}
}