v0.3.4: externalized food strings

This commit is contained in:
Evan Debenham
2016-01-01 22:07:20 -05:00
committed by Evan Debenham
parent c1aca208b4
commit 861fa34420
9 changed files with 102 additions and 231 deletions
@@ -379,7 +379,7 @@ public class Item implements Bundlable {
}
public String desc() {
return "";
return Messages.get(this, "desc");
}
public int quantity() {
@@ -20,50 +20,33 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.items.food;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Statistics;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Barkskin;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bleeding;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Cripple;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.EarthImbue;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FireImbue;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Recharging;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.ToxicImbue;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Weakness;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.*;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging;
import com.shatteredpixel.shatteredpixeldungeon.plants.*;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant.Seed;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
public class Blandfruit extends Food {
public String message = "You eat the Blandfruit, bleugh!";
public String info = "So dry and insubstantial, perhaps stewing it with another ingredient would improve it.";
public Potion potionAttrib = null;
public ItemSprite.Glowing potionGlow = null;
{
name = "Blandfruit";
stackable = true;
image = ItemSpriteSheet.BLANDFRUIT;
energy = (Hunger.STARVING - Hunger.HUNGRY)/2;
hornValue = 6; //only applies when blandfruit is cooked
//only applies when blandfruit is cooked
energy = Hunger.STARVING;
hornValue = 6;
bones = true;
}
@@ -85,90 +68,28 @@ public class Blandfruit extends Food {
@Override
public void execute( Hero hero, String action ) {
if (action.equals( AC_EAT )){
if (potionAttrib == null) {
detach(hero.belongings.backpack);
GLog.w( Messages.get(this, "raw"));
((Hunger) hero.buff(Hunger.class)).satisfy(energy);
GLog.i(message);
hero.sprite.operate(hero.pos);
hero.busy();
SpellSprite.show(hero, SpellSprite.FOOD);
Sample.INSTANCE.play(Assets.SND_EAT);
hero.spend(1f);
Statistics.foodEaten++;
Badges.validateFoodEaten();
} else {
((Hunger) hero.buff(Hunger.class)).satisfy(Hunger.HUNGRY);
detach(hero.belongings.backpack);
hero.spend(1f);
hero.busy();
super.execute(hero, action);
if (potionAttrib instanceof PotionOfFrost) {
GLog.i("the Icefruit tastes a bit like Frozen Carpaccio.");
switch (Random.Int(5)) {
case 0:
GLog.i("You see your hands turn invisible!");
Buff.affect(hero, Invisibility.class, Invisibility.DURATION);
break;
case 1:
GLog.i("You feel your skin harden!");
Buff.affect(hero, Barkskin.class).level(hero.HT / 4);
break;
case 2:
GLog.i("Refreshing!");
Buff.detach(hero, Poison.class);
Buff.detach(hero, Cripple.class);
Buff.detach(hero, Weakness.class);
Buff.detach(hero, Bleeding.class);
break;
case 3:
GLog.i("You feel better!");
if (hero.HP < hero.HT) {
hero.HP = Math.min(hero.HP + hero.HT / 4, hero.HT);
hero.sprite.emitter().burst(Speck.factory(Speck.HEALING), 1);
}
break;
}
GLog.i(Messages.get(this, "ice_msg"));
FrozenCarpaccio.effect(hero);
} else if (potionAttrib instanceof PotionOfLiquidFlame){
GLog.i("You feel a great fire burning within you!");
GLog.i(Messages.get(this, "fire_msg"));
Buff.affect(hero, FireImbue.class).set(FireImbue.DURATION);
} else if (potionAttrib instanceof PotionOfToxicGas) {
GLog.i("You are imbued with vile toxic power!");
GLog.i(Messages.get(this, "toxic_msg"));
Buff.affect(hero, ToxicImbue.class).set(ToxicImbue.DURATION);
} else if (potionAttrib instanceof PotionOfParalyticGas) {
GLog.i("You feel the power of the earth coursing through you!");
GLog.i(Messages.get(this, "para_msg"));
Buff.affect(hero, EarthImbue.class, EarthImbue.DURATION);
} else
potionAttrib.apply(hero);
Sample.INSTANCE.play( Assets.SND_EAT );
SpellSprite.show(hero, SpellSprite.FOOD);
hero.sprite.operate(hero.pos);
switch (hero.heroClass) {
case WARRIOR:
if (hero.HP < hero.HT) {
hero.HP = Math.min( hero.HP + 5, hero.HT );
hero.sprite.emitter().burst( Speck.factory(Speck.HEALING), 1 );
}
break;
case MAGE:
//1 charge
Buff.affect(hero, Recharging.class, 4f);
ScrollOfRecharging.charge(hero);
break;
case ROGUE:
case HUNTRESS:
break;
}
}
} else {
super.execute(hero, action);
@@ -176,8 +97,9 @@ public class Blandfruit extends Food {
}
@Override
public String info() {
return info;
public String desc() {
if (potionAttrib== null) return super.desc();
else return Messages.get(this, "desc_cooked");
}
@Override
@@ -202,76 +124,39 @@ public class Blandfruit extends Food {
potionAttrib.image = ItemSpriteSheet.BLANDFRUIT;
info = "The fruit has plumped up from its time soaking in the pot and has even absorbed the properties "+
"of the seed it was cooked with.\n\n";
if (potionAttrib instanceof PotionOfHealing){
name = "Sunfruit";
name = Messages.get(this, "sunfruit");
potionGlow = new ItemSprite.Glowing( 0x2EE62E );
info += "It looks delicious and hearty, ready to be eaten!";
} else if (potionAttrib instanceof PotionOfStrength){
name = "Rotfruit";
name = Messages.get(this, "rotfruit");
potionGlow = new ItemSprite.Glowing( 0xCC0022 );
info += "It looks delicious and powerful, ready to be eaten!";
} else if (potionAttrib instanceof PotionOfParalyticGas){
name = "Earthfruit";
name = Messages.get(this, "earthfruit");
potionGlow = new ItemSprite.Glowing( 0x67583D );
info += "It looks delicious and firm, ready to be eaten!";
} else if (potionAttrib instanceof PotionOfInvisibility){
name = "Blindfruit";
name = Messages.get(this, "blindfruit");
potionGlow = new ItemSprite.Glowing( 0xE5D273 );
info += "It looks delicious and shiny, ready to be eaten!";
} else if (potionAttrib instanceof PotionOfLiquidFlame){
name = "Firefruit";
name = Messages.get(this, "firefruit");
potionGlow = new ItemSprite.Glowing( 0xFF7F00 );
info += "It looks delicious and spicy, ready to be eaten!";
} else if (potionAttrib instanceof PotionOfFrost){
name = "Icefruit";
name = Messages.get(this, "icefruit");
potionGlow = new ItemSprite.Glowing( 0x66B3FF );
info += "It looks delicious and refreshing, ready to be eaten!";
} else if (potionAttrib instanceof PotionOfMindVision){
name = "Fadefruit";
name = Messages.get(this, "fadefruit");
potionGlow = new ItemSprite.Glowing( 0xB8E6CF );
info += "It looks delicious and shadowy, ready to be eaten!";
} else if (potionAttrib instanceof PotionOfToxicGas){
name = "Sorrowfruit";
name = Messages.get(this, "sorrowfruit");
potionGlow = new ItemSprite.Glowing( 0xA15CE5 );
info += "It looks delicious and crisp, ready to be eaten!";
} else if (potionAttrib instanceof PotionOfLevitation) {
name = "Stormfruit";
name = Messages.get(this, "stormfruit");
potionGlow = new ItemSprite.Glowing( 0x1C3A57 );
info += "It looks delicious and lightweight, ready to be eaten!";
} else if (potionAttrib instanceof PotionOfPurity) {
name = "Dreamfruit";
name = Messages.get(this, "dreamfruit");
potionGlow = new ItemSprite.Glowing( 0x8E2975 );
info += "It looks delicious and clean, ready to be eaten!";
} else if (potionAttrib instanceof PotionOfExperience) {
name = "Starfruit";
name = Messages.get(this, "starfruit");
potionGlow = new ItemSprite.Glowing( 0xA79400 );
info += "It looks delicious and glorious, ready to be eaten!";
}
return this;
@@ -302,40 +187,13 @@ public class Blandfruit extends Food {
}
@Override
public void restoreFromBundle(Bundle bundle){
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
if (bundle.contains( POTIONATTRIB )) {
imbuePotion( (Potion)bundle.get( POTIONATTRIB ) );
//TODO: legacy code for pre-v0.2.3, remove when saves from that version are no longer supported.
} else if (bundle.contains("name")) {
name = bundle.getString("name");
if (name.equals("Healthfruit"))
cook(new Sungrass.Seed());
else if (name.equals("Powerfruit"))
cook(new Rotberry.Seed());
else if (name.equals("Paralyzefruit"))
cook(new Earthroot.Seed());
else if (name.equals("Invisifruit"))
cook(new Blindweed.Seed());
else if (name.equals("Flamefruit"))
cook(new Firebloom.Seed());
else if (name.equals("Frostfruit"))
cook(new Icecap.Seed());
else if (name.equals("Visionfruit"))
cook(new Fadeleaf.Seed());
else if (name.equals("Toxicfruit"))
cook(new Sorrowmoss.Seed());
else if (name.equals("Floatfruit"))
cook(new Stormvine.Seed());
else if (name.equals("Purefruit"))
cook(new Dreamfoil.Seed());
if (bundle.contains(POTIONATTRIB)) {
imbuePotion((Potion) bundle.get(POTIONATTRIB));
}
}
@Override
public ItemSprite.Glowing glowing() {
return potionGlow;
@@ -31,11 +31,6 @@ public class ChargrilledMeat extends Food {
hornValue = 1;
}
@Override
public String info() {
return "It looks like a decent steak.";
}
@Override
public int price() {
return 5 * quantity;
@@ -31,6 +31,7 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.noosa.audio.Sample;
@@ -44,7 +45,7 @@ public class Food extends Item {
public static final String AC_EAT = "EAT";
public float energy = Hunger.HUNGRY;
public String message = "That food tasted delicious!";
public String message = Messages.get(this, "eat_msg");
public int hornValue = 3;
@@ -68,7 +69,7 @@ public class Food extends Item {
detach( hero.belongings.backpack );
((Hunger)hero.buff( Hunger.class )).satisfy( energy );
(hero.buff( Hunger.class )).satisfy( energy );
GLog.i( message );
switch (hero.heroClass) {
@@ -104,13 +105,6 @@ public class Food extends Item {
}
}
@Override
public String info() {
return
"Nothing fancy here: dried meat, " +
"some biscuits - things like that.";
}
@Override
public boolean isUpgradable() {
@@ -33,6 +33,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Vertigo;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Weakness;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.Random;
@@ -51,18 +52,26 @@ public class FrozenCarpaccio extends Food {
super.execute( hero, action );
if (action.equals( AC_EAT )) {
switch (Random.Int( 5 )) {
effect(hero);
}
}
public int price() {
return 10 * quantity;
}
public static void effect(Hero hero){
switch (Random.Int( 5 )) {
case 0:
GLog.i( "You see your hands turn invisible!" );
GLog.i( Messages.get(FrozenCarpaccio.class, "invis") );
Buff.affect( hero, Invisibility.class, Invisibility.DURATION );
break;
case 1:
GLog.i( "You feel your skin harden!" );
GLog.i( Messages.get(FrozenCarpaccio.class, "hard") );
Buff.affect( hero, Barkskin.class ).level( hero.HT / 4 );
break;
case 2:
GLog.i( "Refreshing!" );
GLog.i( Messages.get(FrozenCarpaccio.class, "refresh") );
Buff.detach( hero, Poison.class );
Buff.detach( hero, Cripple.class );
Buff.detach( hero, Weakness.class );
@@ -72,27 +81,15 @@ public class FrozenCarpaccio extends Food {
Buff.detach( hero, Vertigo.class);
break;
case 3:
GLog.i( "You feel better!" );
GLog.i( Messages.get(FrozenCarpaccio.class, "better") );
if (hero.HP < hero.HT) {
hero.HP = Math.min( hero.HP + hero.HT / 4, hero.HT );
hero.sprite.emitter().burst( Speck.factory( Speck.HEALING ), 1 );
}
break;
}
}
}
@Override
public String info() {
return
"It's a piece of frozen raw meat. The only way to eat it is " +
"by cutting thin slices of it. And this way it's suprisingly good.";
}
public int price() {
return 10 * quantity;
};
public static Food cook( MysteryMeat ingredient ) {
FrozenCarpaccio result = new FrozenCarpaccio();
result.quantity = ingredient.quantity();
@@ -28,6 +28,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Roots;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Slow;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.Random;
@@ -37,7 +38,6 @@ public class MysteryMeat extends Food {
{
image = ItemSpriteSheet.MEAT;
energy = Hunger.STARVING - Hunger.HUNGRY;
message = "That food tasted... strange.";
hornValue = 1;
}
@@ -47,34 +47,32 @@ public class MysteryMeat extends Food {
super.execute( hero, action );
if (action.equals( AC_EAT )) {
switch (Random.Int( 5 )) {
effect(hero);
}
}
public int price() {
return 5 * quantity;
}
public static void effect(Hero hero){
switch (Random.Int( 5 )) {
case 0:
GLog.w( "Oh it's hot!" );
GLog.w( Messages.get(MysteryMeat.class, "hot") );
Buff.affect( hero, Burning.class ).reignite( hero );
break;
case 1:
GLog.w( "You can't feel your legs!" );
GLog.w( Messages.get(MysteryMeat.class, "legs") );
Buff.prolong( hero, Roots.class, Paralysis.duration( hero ) );
break;
case 2:
GLog.w( "You are not feeling well." );
GLog.w( Messages.get(MysteryMeat.class, "not_well") );
Buff.affect( hero, Poison.class ).set( Poison.durationFactor( hero ) * hero.HT / 5 );
break;
case 3:
GLog.w( "You are stuffed." );
GLog.w( Messages.get(MysteryMeat.class, "stuffed") );
Buff.prolong( hero, Slow.class, Slow.duration( hero ) );
break;
}
}
}
@Override
public String info() {
return "Eat at your own risk!";
}
public int price() {
return 5 * quantity;
};
}
@@ -28,15 +28,9 @@ public class OverpricedRation extends Food {
{
image = ItemSpriteSheet.OVERPRICED;
energy = Hunger.STARVING - Hunger.HUNGRY;
message = "That food tasted ok.";
hornValue = 1;
}
@Override
public String info() {
return "It looks exactly like a standard ration of food but smaller.";
}
@Override
public int price() {
return 20 * quantity;
@@ -99,10 +99,9 @@ public class Pasty extends Food {
public String info() {
switch(holiday){
case NONE: default:
return "This is authentic Cornish pasty with traditional filling of beef and potato.";
return Messages.get(this, "pasty_desc");
case XMAS:
return "A huge sugary sweet candy cane! It's big enough to fill you up, " +
"and the sugar might give your wands a tiny bit of extra charge too.\n\nHappy Holidays!";
return Messages.get(this, "cane_desc");
}
}