From 0cccd06d44ec1d6aa0e928cea170c4c4710b24c3 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 28 May 2018 19:24:45 -0400 Subject: [PATCH] v0.7.0: refactored seed to potion alchemy --- .../shatteredpixeldungeon/items/Recipe.java | 2 +- .../items/food/Blandfruit.java | 2 +- .../items/potions/Potion.java | 46 +++++++++++++++++-- .../plants/BlandfruitBush.java | 1 - .../plants/Blindweed.java | 2 - .../plants/Dreamfoil.java | 2 - .../plants/Earthroot.java | 2 - .../plants/Fadeleaf.java | 2 - .../plants/Firebloom.java | 2 - .../shatteredpixeldungeon/plants/Icecap.java | 2 - .../shatteredpixeldungeon/plants/Plant.java | 2 - .../plants/Rotberry.java | 2 - .../plants/Sorrowmoss.java | 2 - .../plants/Starflower.java | 2 - .../plants/Stormvine.java | 2 - .../plants/Sungrass.java | 2 - .../messages/items/items.properties | 2 +- 17 files changed, 44 insertions(+), 33 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Recipe.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Recipe.java index 17bcd8059..7881cccfc 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Recipe.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Recipe.java @@ -120,7 +120,7 @@ public abstract class Recipe { }; private static Recipe[] threeIngredientRecipes = new Recipe[]{ - new Potion.RandomPotion() + new Potion.SeedToPotion() }; public static Recipe findRecipe(ArrayList ingredients){ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java index cf6d55a0c..de71e5630 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/food/Blandfruit.java @@ -131,7 +131,7 @@ public class Blandfruit extends Food { public Item cook(Seed seed){ try { - return imbuePotion((Potion)seed.alchemyClass.newInstance()); + return imbuePotion(Potion.SeedToPotion.types.get(seed.getClass()).newInstance()); } catch (Exception e) { ShatteredPixelDungeon.reportException(e); return null; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java index 9c9342c16..9e8fbabd7 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java @@ -42,7 +42,18 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Recipe; import com.shatteredpixel.shatteredpixeldungeon.journal.Catalog; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.plants.Blindweed; +import com.shatteredpixel.shatteredpixeldungeon.plants.Dreamfoil; +import com.shatteredpixel.shatteredpixeldungeon.plants.Earthroot; +import com.shatteredpixel.shatteredpixeldungeon.plants.Fadeleaf; +import com.shatteredpixel.shatteredpixeldungeon.plants.Firebloom; +import com.shatteredpixel.shatteredpixeldungeon.plants.Icecap; import com.shatteredpixel.shatteredpixeldungeon.plants.Plant; +import com.shatteredpixel.shatteredpixeldungeon.plants.Rotberry; +import com.shatteredpixel.shatteredpixeldungeon.plants.Sorrowmoss; +import com.shatteredpixel.shatteredpixeldungeon.plants.Starflower; +import com.shatteredpixel.shatteredpixeldungeon.plants.Stormvine; +import com.shatteredpixel.shatteredpixeldungeon.plants.Sungrass; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; @@ -338,7 +349,22 @@ public class Potion extends Item { } - public static class RandomPotion extends Recipe { + public static class SeedToPotion extends Recipe { + + public static HashMap, Class> types = new HashMap<>(); + static { + types.put(Blindweed.Seed.class, PotionOfInvisibility.class); + types.put(Dreamfoil.Seed.class, PotionOfPurity.class); + types.put(Earthroot.Seed.class, PotionOfParalyticGas.class); + types.put(Fadeleaf.Seed.class, PotionOfMindVision.class); + types.put(Firebloom.Seed.class, PotionOfLiquidFlame.class); + types.put(Icecap.Seed.class, PotionOfFrost.class); + types.put(Rotberry.Seed.class, PotionOfStrength.class); + types.put(Sorrowmoss.Seed.class, PotionOfToxicGas.class); + types.put(Starflower.Seed.class, PotionOfExperience.class); + types.put(Stormvine.Seed.class, PotionOfLevitation.class); + types.put(Sungrass.Seed.class, PotionOfHealing.class); + } @Override public boolean testIngredients(ArrayList ingredients) { @@ -347,7 +373,9 @@ public class Potion extends Item { } for (Item ingredient : ingredients){ - if (!(ingredient instanceof Plant.Seed && ingredient.quantity() >= 1)){ + if (!(ingredient instanceof Plant.Seed + && ingredient.quantity() >= 1 + && types.containsKey(ingredient.getClass()))){ return false; } } @@ -367,15 +395,23 @@ public class Potion extends Item { ingredient.quantity(ingredient.quantity() - 1); } + ArrayList> seeds = new ArrayList<>(); + for (Item i : ingredients) { + if (!seeds.contains(i.getClass())) { + seeds.add((Class) i.getClass()); + } + } + Item result; - if (Random.Int( 3 ) == 0) { + if ( (seeds.size() == 2 && Random.Int(4) == 0) + || (seeds.size() == 3 && Random.Int(2) == 0)) { result = Generator.random( Generator.Category.POTION ); } else { - Class itemClass = ((Plant.Seed)Random.element(ingredients)).alchemyClass; + Class itemClass = types.get(Random.element(ingredients).getClass()); try { result = itemClass.newInstance(); } catch (Exception e) { @@ -405,7 +441,7 @@ public class Potion extends Item { public Item sampleOutput(ArrayList ingredients) { return new WndBag.Placeholder(ItemSpriteSheet.POTION_HOLDER){ { - name = Messages.get(RandomPotion.class, "name"); + name = Messages.get(SeedToPotion.class, "name"); } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/BlandfruitBush.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/BlandfruitBush.java index 66c08aa9e..d03722c97 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/BlandfruitBush.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/BlandfruitBush.java @@ -41,7 +41,6 @@ public class BlandfruitBush extends Plant { image = ItemSpriteSheet.SEED_BLANDFRUIT; plantClass = BlandfruitBush.class; - alchemyClass = null; } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Blindweed.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Blindweed.java index d471de5dc..43df1580e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Blindweed.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Blindweed.java @@ -30,7 +30,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Cripple; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; -import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfInvisibility; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.watabou.utils.Random; @@ -64,7 +63,6 @@ public class Blindweed extends Plant { image = ItemSpriteSheet.SEED_BLINDWEED; plantClass = Blindweed.class; - alchemyClass = PotionOfInvisibility.class; } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Dreamfoil.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Dreamfoil.java index a507c731b..3264dffca 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Dreamfoil.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Dreamfoil.java @@ -34,7 +34,6 @@ 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.actors.mobs.Mob; -import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfPurity; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; @@ -70,7 +69,6 @@ public class Dreamfoil extends Plant { image = ItemSpriteSheet.SEED_DREAMFOIL; plantClass = Dreamfoil.class; - alchemyClass = PotionOfPurity.class; } } } \ No newline at end of file diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Earthroot.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Earthroot.java index 756ce3133..96e56866e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Earthroot.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Earthroot.java @@ -28,7 +28,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.EarthParticle; -import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfParalyticGas; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; @@ -61,7 +60,6 @@ public class Earthroot extends Plant { image = ItemSpriteSheet.SEED_EARTHROOT; plantClass = Earthroot.class; - alchemyClass = PotionOfParalyticGas.class; bones = true; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Fadeleaf.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Fadeleaf.java index 2148efe6d..094db8b5f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Fadeleaf.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Fadeleaf.java @@ -28,7 +28,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; -import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMindVision; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; @@ -79,7 +78,6 @@ public class Fadeleaf extends Plant { image = ItemSpriteSheet.SEED_FADELEAF; plantClass = Fadeleaf.class; - alchemyClass = PotionOfMindVision.class; } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Firebloom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Firebloom.java index 1659b05da..c0eb18640 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Firebloom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Firebloom.java @@ -26,7 +26,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlameParticle; -import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLiquidFlame; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; @@ -51,7 +50,6 @@ public class Firebloom extends Plant { image = ItemSpriteSheet.SEED_FIREBLOOM; plantClass = Firebloom.class; - alchemyClass = PotionOfLiquidFlame.class; } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Icecap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Icecap.java index 95c9299b8..037503882 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Icecap.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Icecap.java @@ -24,7 +24,6 @@ package com.shatteredpixel.shatteredpixeldungeon.plants; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Freezing; -import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfFrost; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.utils.BArray; import com.watabou.utils.PathFinder; @@ -54,7 +53,6 @@ public class Icecap extends Plant { image = ItemSpriteSheet.SEED_ICECAP; plantClass = Icecap.class; - alchemyClass = PotionOfFrost.class; } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Plant.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Plant.java index c30038017..9ddb1c58b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Plant.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Plant.java @@ -132,8 +132,6 @@ public abstract class Plant implements Bundlable { protected Class plantClass; - public Class alchemyClass; - @Override public ArrayList actions( Hero hero ) { ArrayList actions = super.actions( hero ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Rotberry.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Rotberry.java index 97fab487b..5a5672bd4 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Rotberry.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Rotberry.java @@ -24,7 +24,6 @@ package com.shatteredpixel.shatteredpixeldungeon.plants; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.LeafParticle; -import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; public class Rotberry extends Plant { @@ -54,7 +53,6 @@ public class Rotberry extends Plant { image = ItemSpriteSheet.SEED_ROTBERRY; plantClass = Rotberry.class; - alchemyClass = PotionOfStrength.class; } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Sorrowmoss.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Sorrowmoss.java index a6e55d31e..b12d57673 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Sorrowmoss.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Sorrowmoss.java @@ -28,7 +28,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.PoisonParticle; -import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfToxicGas; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; public class Sorrowmoss extends Plant { @@ -55,7 +54,6 @@ public class Sorrowmoss extends Plant { image = ItemSpriteSheet.SEED_SORROWMOSS; plantClass = Sorrowmoss.class; - alchemyClass = PotionOfToxicGas.class; } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Starflower.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Starflower.java index bb9a55af1..2fb17ef47 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Starflower.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Starflower.java @@ -26,7 +26,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Bless; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; -import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfExperience; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.watabou.utils.Random; @@ -53,7 +52,6 @@ public class Starflower extends Plant { image = ItemSpriteSheet.SEED_STARFLOWER; plantClass = Starflower.class; - alchemyClass = PotionOfExperience.class; } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Stormvine.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Stormvine.java index bbf10d87e..a1f34c31f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Stormvine.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Stormvine.java @@ -25,7 +25,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Vertigo; -import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLevitation; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; public class Stormvine extends Plant { @@ -48,7 +47,6 @@ public class Stormvine extends Plant { image = ItemSpriteSheet.SEED_STORMVINE; plantClass = Stormvine.class; - alchemyClass = PotionOfLevitation.class; } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Sungrass.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Sungrass.java index 9c9a9ad32..5f17151ca 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Sungrass.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Sungrass.java @@ -30,7 +30,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShaftParticle; -import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; @@ -61,7 +60,6 @@ public class Sungrass extends Plant { image = ItemSpriteSheet.SEED_SUNGRASS; plantClass = Sungrass.class; - alchemyClass = PotionOfHealing.class; bones = true; } diff --git a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties index 7a40c61dc..d0f5b3e11 100644 --- a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties +++ b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties @@ -444,7 +444,7 @@ items.potions.potion.no=No, I changed my mind items.potions.potion.sure_drink=Are you sure you want to drink it? In most cases you should throw such potions at your enemies. items.potions.potion.sure_throw=Are you sure you want to throw it? In most cases it makes sense to drink it. items.potions.potion.shatter=The flask shatters and the liquid splashes harmlessly. -items.potions.potion$randompotion.name=Random Potion +items.potions.potion$seedtopotion.name=Random Potion items.potions.potionofexperience.name=potion of experience items.potions.potionofexperience.desc=The storied experiences of multitudes of battles reduced to liquid form, this draught will instantly raise your experience level.