v0.8.2a: refactored item names, fixed bugs with translation swapping.

This commit is contained in:
Evan Debenham 2020-08-15 11:49:17 -04:00
parent 789314e5c7
commit 013f05caeb
10 changed files with 80 additions and 71 deletions

View File

@ -60,9 +60,6 @@ public class Belongings implements Iterable<Item> {
this.owner = owner;
backpack = new Bag() {
{
name = Messages.get(Bag.class, "name");
}
public int capacity(){
int cap = super.capacity();
for (Item item : items){

View File

@ -64,8 +64,8 @@ public class Item implements Bundlable {
public String defaultAction;
public boolean usesTargeting;
protected String name = Messages.get(this, "name");
//TODO should these be private and accessed through methods?
public int image = 0;
public int icon = -1; //used as an identifier for items with randomized images
@ -120,10 +120,7 @@ public class Item implements Bundlable {
}
//resets an item's properties, to ensure consistency between runs
public void reset(){
//resets the name incase the language has changed.
name = Messages.get(this, "name");
}
public void reset(){}
public void doThrow( Hero hero ) {
GameScene.selectCell(thrower);
@ -404,11 +401,11 @@ public class Item implements Bundlable {
}
public String name() {
return name;
return trueName();
}
public final String trueName() {
return name;
return Messages.get(this, "name");
}
public int image() {

View File

@ -106,6 +106,11 @@ public class SandalsOfNature extends Artifact {
target.buff(Naturalism.class).charge();
}
@Override
public String name() {
return Messages.get(this, "name_" + (level()+1));
}
@Override
public String desc() {
String desc = Messages.get(this, "desc_" + (level()+1));
@ -135,7 +140,6 @@ public class SandalsOfNature extends Artifact {
else if (level() == 0) image = ItemSpriteSheet.ARTIFACT_SHOES;
else if (level() == 1) image = ItemSpriteSheet.ARTIFACT_BOOTS;
else if (level() >= 2) image = ItemSpriteSheet.ARTIFACT_GREAVES;
name = Messages.get(this, "name_" + (level()+1));
return super.upgrade();
}
@ -159,7 +163,6 @@ public class SandalsOfNature extends Artifact {
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle(bundle);
if (level() > 0) name = Messages.get(this, "name_" + level());
if (bundle.contains(SEEDS))
Collections.addAll(seeds , bundle.getClassArray(SEEDS));
if (level() == 1) image = ItemSpriteSheet.ARTIFACT_SHOES;

View File

@ -100,6 +100,23 @@ public class Blandfruit extends Food {
}
}
@Override
public String name() {
if (potionAttrib instanceof PotionOfHealing) return Messages.get(this, "sunfruit");
if (potionAttrib instanceof PotionOfStrength) return Messages.get(this, "rotfruit");
if (potionAttrib instanceof PotionOfParalyticGas) return Messages.get(this, "earthfruit");
if (potionAttrib instanceof PotionOfInvisibility) return Messages.get(this, "blindfruit");
if (potionAttrib instanceof PotionOfLiquidFlame) return Messages.get(this, "firefruit");
if (potionAttrib instanceof PotionOfFrost) return Messages.get(this, "icefruit");
if (potionAttrib instanceof PotionOfMindVision) return Messages.get(this, "fadefruit");
if (potionAttrib instanceof PotionOfToxicGas) return Messages.get(this, "sorrowfruit");
if (potionAttrib instanceof PotionOfLevitation) return Messages.get(this, "stormfruit");
if (potionAttrib instanceof PotionOfPurity) return Messages.get(this, "dreamfruit");
if (potionAttrib instanceof PotionOfExperience) return Messages.get(this, "starfruit");
if (potionAttrib instanceof PotionOfHaste) return Messages.get(this, "swiftfruit");
return super.name();
}
@Override
public String desc() {
if (potionAttrib== null) {
@ -134,43 +151,18 @@ public class Blandfruit extends Food {
potionAttrib.image = ItemSpriteSheet.BLANDFRUIT;
if (potionAttrib instanceof PotionOfHealing){
name = Messages.get(this, "sunfruit");
potionGlow = new ItemSprite.Glowing( 0x2EE62E );
} else if (potionAttrib instanceof PotionOfStrength){
name = Messages.get(this, "rotfruit");
potionGlow = new ItemSprite.Glowing( 0xCC0022 );
} else if (potionAttrib instanceof PotionOfParalyticGas){
name = Messages.get(this, "earthfruit");
potionGlow = new ItemSprite.Glowing( 0x67583D );
} else if (potionAttrib instanceof PotionOfInvisibility){
name = Messages.get(this, "blindfruit");
potionGlow = new ItemSprite.Glowing( 0xD9D9D9 );
} else if (potionAttrib instanceof PotionOfLiquidFlame){
name = Messages.get(this, "firefruit");
potionGlow = new ItemSprite.Glowing( 0xFF7F00 );
} else if (potionAttrib instanceof PotionOfFrost){
name = Messages.get(this, "icefruit");
potionGlow = new ItemSprite.Glowing( 0x66B3FF );
} else if (potionAttrib instanceof PotionOfMindVision){
name = Messages.get(this, "fadefruit");
potionGlow = new ItemSprite.Glowing( 0x919999 );
} else if (potionAttrib instanceof PotionOfToxicGas){
name = Messages.get(this, "sorrowfruit");
potionGlow = new ItemSprite.Glowing( 0xA15CE5 );
} else if (potionAttrib instanceof PotionOfLevitation) {
name = Messages.get(this, "stormfruit");
potionGlow = new ItemSprite.Glowing( 0x1B5F79 );
} else if (potionAttrib instanceof PotionOfPurity) {
name = Messages.get(this, "dreamfruit");
potionGlow = new ItemSprite.Glowing( 0xC152AA );
} else if (potionAttrib instanceof PotionOfExperience) {
name = Messages.get(this, "starfruit");
potionGlow = new ItemSprite.Glowing( 0x404040 );
} else if (potionAttrib instanceof PotionOfHaste) {
name = Messages.get(this, "swiftfruit");
potionGlow = new ItemSprite.Glowing( 0xCCBB00 );
}
if (potionAttrib instanceof PotionOfHealing) potionGlow = new ItemSprite.Glowing( 0x2EE62E );
if (potionAttrib instanceof PotionOfStrength) potionGlow = new ItemSprite.Glowing( 0xCC0022 );
if (potionAttrib instanceof PotionOfParalyticGas) potionGlow = new ItemSprite.Glowing( 0x67583D );
if (potionAttrib instanceof PotionOfInvisibility) potionGlow = new ItemSprite.Glowing( 0xD9D9D9 );
if (potionAttrib instanceof PotionOfLiquidFlame) potionGlow = new ItemSprite.Glowing( 0xFF7F00 );
if (potionAttrib instanceof PotionOfFrost) potionGlow = new ItemSprite.Glowing( 0x66B3FF );
if (potionAttrib instanceof PotionOfMindVision) potionGlow = new ItemSprite.Glowing( 0x919999 );
if (potionAttrib instanceof PotionOfToxicGas) potionGlow = new ItemSprite.Glowing( 0xA15CE5 );
if (potionAttrib instanceof PotionOfLevitation) potionGlow = new ItemSprite.Glowing( 0x1B5F79 );
if (potionAttrib instanceof PotionOfPurity) potionGlow = new ItemSprite.Glowing( 0xC152AA );
if (potionAttrib instanceof PotionOfExperience) potionGlow = new ItemSprite.Glowing( 0x404040 );
if (potionAttrib instanceof PotionOfHaste) potionGlow = new ItemSprite.Glowing( 0xCCBB00 );
return this;
}

View File

@ -83,15 +83,12 @@ public class Pasty extends Food {
super.reset();
switch(holiday){
case NONE:
name = Messages.get(this, "pasty");
image = ItemSpriteSheet.PASTY;
break;
case HWEEN:
name = Messages.get(this, "pie");
image = ItemSpriteSheet.PUMPKIN_PIE;
break;
case XMAS:
name = Messages.get(this, "cane");
image = ItemSpriteSheet.CANDY_CANE;
break;
}
@ -116,6 +113,18 @@ public class Pasty extends Food {
}
}
@Override
public String name() {
switch(holiday){
case NONE: default:
return Messages.get(this, "pasty");
case HWEEN:
return Messages.get(this, "pie");
case XMAS:
return Messages.get(this, "cane");
}
}
@Override
public String info() {
switch(holiday){

View File

@ -538,8 +538,10 @@ public class Potion extends Item {
@Override
public Item sampleOutput(ArrayList<Item> ingredients) {
return new WndBag.Placeholder(ItemSpriteSheet.POTION_HOLDER){
{
name = Messages.get(SeedToPotion.class, "name");
@Override
public String name() {
return Messages.get(Potion.SeedToPotion.class, "name");
}
@Override

View File

@ -224,7 +224,7 @@ public abstract class Scroll extends Item {
@Override
public String name() {
return isKnown() ? name : Messages.get(this, rune);
return isKnown() ? super.name() : Messages.get(this, rune);
}
@Override

View File

@ -94,7 +94,6 @@ public class MagesStaff extends MeleeWeapon {
this.wand = wand;
updateWand(false);
wand.curCharges = wand.maxCharges;
name = Messages.get(wand, "staff_name");
}
@Override
@ -202,8 +201,6 @@ public class MagesStaff extends MeleeWeapon {
wand.curCharges = wand.maxCharges;
if (owner != null) wand.charge(owner);
name = Messages.get(wand, "staff_name");
//This is necessary to reset any particles.
//FIXME this is gross, should implement a better way to fully reset quickslot visuals
int slot = Dungeon.quickslot.getSlot(this);
@ -264,6 +261,15 @@ public class MagesStaff extends MeleeWeapon {
else return wand.status();
}
@Override
public String name() {
if (wand == null) {
return super.name();
} else {
return Messages.get(wand, "staff_name");
}
}
@Override
public String info() {
String info = super.info();
@ -303,7 +309,6 @@ public class MagesStaff extends MeleeWeapon {
wand = (Wand) bundle.get(WAND);
if (wand != null) {
wand.maxCharges = Math.min(wand.maxCharges + 1, 10);
name = Messages.get(wand, "staff_name");
}
}

View File

@ -242,10 +242,11 @@ public class QuickRecipe extends Component {
switch (pageIdx){
case 0: default:
result.add(new QuickRecipe( new Potion.SeedToPotion(), new ArrayList<>(Arrays.asList(new Plant.Seed.PlaceHolder().quantity(3))), new WndBag.Placeholder(ItemSpriteSheet.POTION_HOLDER){
{
name = Messages.get(Potion.SeedToPotion.class, "name");
@Override
public String name() {
return Messages.get(Potion.SeedToPotion.class, "name");
}
@Override
public String info() {
return "";
@ -275,8 +276,9 @@ public class QuickRecipe extends Component {
result.add(new QuickRecipe( new Blandfruit.CookFruit(),
new ArrayList<>(Arrays.asList(new Blandfruit(), new Plant.Seed.PlaceHolder())),
new Blandfruit(){
{
name = Messages.get(Blandfruit.class, "cooked");
public String name(){
return Messages.get(Blandfruit.class, "cooked");
}
@Override

View File

@ -333,14 +333,16 @@ public class WndBag extends WndTabbed {
}
public static class Placeholder extends Item {
{
name = null;
}
public Placeholder( int image ) {
public Placeholder(int image ) {
this.image = image;
}
@Override
public String name() {
return null;
}
@Override
public boolean isIdentified() {
return true;