v0.3.4: externalized ring strings

This commit is contained in:
Evan Debenham
2016-01-02 07:04:08 -05:00
committed by Evan Debenham
parent 492e9069d2
commit fb2c6e3307
13 changed files with 56 additions and 137 deletions
@@ -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<Ring>( (Class<? extends Ring>[])rings, gems, images );
handler = new ItemStatusHandler<>( (Class<? extends Ring>[])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<Ring>( (Class<? extends Ring>[])rings, gems, images, bundle );
handler = new ItemStatusHandler<>( (Class<? extends Ring>[])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 );
}
@@ -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 {
}
}
@@ -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<Class<?>> EMPTY = new HashSet<Class<?>>();
private static final HashSet<Class<?>> FULL;
@@ -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 {
@@ -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 {
}
}
@@ -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 {
}
}
@@ -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 {
}
}
@@ -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 {
}
}
@@ -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 {
}
}
@@ -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 {
}
}
@@ -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 {
}
}
@@ -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 {
}
}