From 24e311dc58710fceffae253cbc8d964cb848cfd0 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 17 Nov 2018 15:27:39 -0500 Subject: [PATCH] v0.7.1: improved how trans/recycle handle exotics, stones, elixirs/brews --- .../items/scrolls/ScrollOfTransmutation.java | 29 ++++++++++++++++--- .../items/spells/Recycle.java | 23 ++++++++++++++- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfTransmutation.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfTransmutation.java index 518773182..e8985c5b3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfTransmutation.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfTransmutation.java @@ -29,9 +29,12 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; +import com.shatteredpixel.shatteredpixeldungeon.items.potions.brews.Brew; +import com.shatteredpixel.shatteredpixeldungeon.items.potions.elixirs.Elixir; import com.shatteredpixel.shatteredpixeldungeon.items.potions.exotic.ExoticPotion; import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ExoticScroll; +import com.shatteredpixel.shatteredpixeldungeon.items.stones.Runestone; import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff; @@ -53,9 +56,14 @@ public class ScrollOfTransmutation extends InventoryScroll { } public static boolean canTransmute(Item item){ - return item instanceof MagesStaff || item instanceof MeleeWeapon || item instanceof Potion - || item instanceof Scroll || item instanceof Ring || item instanceof Wand - || item instanceof Plant.Seed || item instanceof Artifact; + return item instanceof MeleeWeapon || + (item instanceof Potion && !(item instanceof Elixir || item instanceof Brew)) || + item instanceof Scroll || + item instanceof Ring || + item instanceof Wand || + item instanceof Plant.Seed || + item instanceof Runestone || + item instanceof Artifact; } @Override @@ -76,7 +84,9 @@ public class ScrollOfTransmutation extends InventoryScroll { } else if (item instanceof Wand) { result = changeWand( (Wand)item ); } else if (item instanceof Plant.Seed) { - result = changeSeed( (Plant.Seed)item ); + result = changeSeed((Plant.Seed) item); + } else if (item instanceof Runestone) { + result = changeStone((Runestone) item); } else if (item instanceof Artifact) { result = changeArtifact( (Artifact)item ); } else { @@ -219,6 +229,17 @@ public class ScrollOfTransmutation extends InventoryScroll { return n; } + private Runestone changeStone( Runestone r ) { + + Runestone n; + + do { + n = (Runestone) Generator.random( Generator.Category.STONE ); + } while (n.getClass() == r.getClass()); + + return n; + } + private Scroll changeScroll( Scroll s ) { try { if (s instanceof ExoticScroll) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/Recycle.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/Recycle.java index 136a6624b..7a1e3f4dc 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/Recycle.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/spells/Recycle.java @@ -21,11 +21,16 @@ package com.shatteredpixel.shatteredpixeldungeon.items.spells; +import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion; +import com.shatteredpixel.shatteredpixeldungeon.items.potions.brews.Brew; +import com.shatteredpixel.shatteredpixeldungeon.items.potions.elixirs.Elixir; +import com.shatteredpixel.shatteredpixeldungeon.items.potions.exotic.ExoticPotion; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTransmutation; +import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ExoticScroll; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ScrollOfDivination; import com.shatteredpixel.shatteredpixeldungeon.items.stones.Runestone; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; @@ -47,8 +52,24 @@ public class Recycle extends InventorySpell { do { if (item instanceof Potion) { result = Generator.random(Generator.Category.POTION); + if (item instanceof ExoticPotion){ + try { + result = ExoticPotion.regToExo.get(result.getClass()).newInstance(); + } catch ( Exception e ){ + ShatteredPixelDungeon.reportException(e); + result = item; + } + } } else if (item instanceof Scroll) { result = Generator.random(Generator.Category.SCROLL); + if (item instanceof ExoticScroll){ + try { + result = ExoticScroll.regToExo.get(result.getClass()).newInstance(); + } catch ( Exception e ){ + ShatteredPixelDungeon.reportException(e); + result = item; + } + } } else if (item instanceof Plant.Seed) { result = Generator.random(Generator.Category.SEED); } else { @@ -63,7 +84,7 @@ public class Recycle extends InventorySpell { } public static boolean isRecyclable(Item item){ - return item instanceof Potion || + return (item instanceof Potion && !(item instanceof Elixir || item instanceof Brew)) || item instanceof Scroll || item instanceof Plant.Seed || item instanceof Runestone;