v0.2.3: refactored blandfruit bundling

This commit is contained in:
Evan Debenham
2014-11-20 15:44:57 -05:00
parent ec8ced5fc4
commit f40f7f325c
@@ -176,21 +176,25 @@ public class Blandfruit extends Food {
} }
public Item cook(Seed seed){ public Item cook(Seed seed){
Class<? extends Item> potion = seed.alchemyClass;
try { try {
potionAttrib = (Potion)potion.newInstance(); return imbuePotion((Potion)seed.alchemyClass.newInstance());
potionAttrib.ownedByFruit = true;
} catch (Exception e) { } catch (Exception e) {
return null; return null;
} }
}
public Item imbuePotion(Potion potion){
potionAttrib = potion;
potionAttrib.ownedByFruit = true;
potionAttrib.image = ItemSpriteSheet.BLANDFRUIT; potionAttrib.image = ItemSpriteSheet.BLANDFRUIT;
info = "The fruit has plumped up from its time soaking in the pot and has even absorbed the properties "+ info = "The fruit has plumped up from its time soaking in the pot and has even absorbed the properties "+
"of the " + seed.name() + " it was cooked with.\n\n"; "of the seed it was cooked with.\n\n";
if (potionAttrib instanceof PotionOfHealing){ if (potionAttrib instanceof PotionOfHealing){
@@ -257,7 +261,7 @@ public class Blandfruit extends Food {
return this; return this;
} }
public static final String NAME = "name"; public static final String POTIONATTRIB = "potionattrib";
@Override @Override
public void cast( final Hero user, int dst ) { public void cast( final Hero user, int dst ) {
@@ -278,34 +282,40 @@ public class Blandfruit extends Food {
@Override @Override
public void storeInBundle(Bundle bundle){ public void storeInBundle(Bundle bundle){
super.storeInBundle(bundle); super.storeInBundle(bundle);
bundle.put( NAME, name ); bundle.put( POTIONATTRIB , potionAttrib);
} }
@Override @Override
public void restoreFromBundle(Bundle bundle){ public void restoreFromBundle(Bundle bundle){
super.restoreFromBundle(bundle); super.restoreFromBundle(bundle);
name = bundle.getString(NAME); if (bundle.contains( POTIONATTRIB )) {
imbuePotion( (Potion)bundle.get( POTIONATTRIB ) );
if (name.equals("Sunfruit")) //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()); cook(new Sungrass.Seed());
else if (name.equals("Rotfruit")) else if (name.equals("Powerfruit"))
cook(new Wandmaker.Rotberry.Seed()); cook(new Wandmaker.Rotberry.Seed());
else if (name.equals("Earthfruit")) else if (name.equals("Paralyzefruit"))
cook(new Earthroot.Seed()); cook(new Earthroot.Seed());
else if (name.equals("Blindfruit")) else if (name.equals("Invisifruit"))
cook(new Blindweed.Seed()); cook(new Blindweed.Seed());
else if (name.equals("Firefruit")) else if (name.equals("Flamefruit"))
cook(new Firebloom.Seed()); cook(new Firebloom.Seed());
else if (name.equals("Icefruit")) else if (name.equals("Frostfruit"))
cook(new Icecap.Seed()); cook(new Icecap.Seed());
else if (name.equals("Fadefruit")) else if (name.equals("Visionfruit"))
cook(new Fadeleaf.Seed()); cook(new Fadeleaf.Seed());
else if (name.equals("Sorrowfruit")) else if (name.equals("Toxicfruit"))
cook(new Sorrowmoss.Seed()); cook(new Sorrowmoss.Seed());
else if (name.equals("Stormfruit")) else if (name.equals("Floatfruit"))
cook(new Stormvine.Seed()); cook(new Stormvine.Seed());
else if (name.equals("Dreamfruit")) else if (name.equals("Purefruit"))
cook(new Dreamfoil.Seed()); cook(new Dreamfoil.Seed());
}
} }