From 9f5c118172374c4eebb1d488f178b446783c681d Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 28 Jul 2023 11:53:27 -0400 Subject: [PATCH] v2.2.0: transmute scroll no longer turns pots/scrolls into exotics The alchemy changes in v1.1.0 largely made this pointless anyway, as it's more efficient to just scrap transmutation for energy. --- .../items/scrolls/ScrollOfTransmutation.java | 42 +++++++++++-------- .../items/spells/Recycle.java | 26 +----------- 2 files changed, 25 insertions(+), 43 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 d60ef50eb..df6f4b5d7 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 @@ -131,7 +131,7 @@ public class ScrollOfTransmutation extends InventoryScroll { if (item instanceof MagesStaff) { return changeStaff((MagesStaff) item); }else if (item instanceof TippedDart){ - return changeTippeDart( (TippedDart)item ); + return changeTippedDart( (TippedDart)item ); } else if (item instanceof MeleeWeapon || item instanceof MissileWeapon) { return changeWeapon( (Weapon)item ); } else if (item instanceof Scroll) { @@ -182,7 +182,7 @@ public class ScrollOfTransmutation extends InventoryScroll { return staff; } - private static TippedDart changeTippeDart( TippedDart dart ){ + private static TippedDart changeTippedDart( TippedDart dart ){ TippedDart n; do { n = TippedDart.randomTipped(1); @@ -192,7 +192,6 @@ public class ScrollOfTransmutation extends InventoryScroll { } private static Weapon changeWeapon( Weapon w ) { - Weapon n; Generator.Category c; if (w instanceof MeleeWeapon) { @@ -276,7 +275,6 @@ public class ScrollOfTransmutation extends InventoryScroll { } private static Wand changeWand( Wand w ) { - Wand n; do { n = (Wand)Generator.random( Generator.Category.WAND ); @@ -300,7 +298,6 @@ public class ScrollOfTransmutation extends InventoryScroll { } private static Plant.Seed changeSeed( Plant.Seed s ) { - Plant.Seed n; do { @@ -311,7 +308,6 @@ public class ScrollOfTransmutation extends InventoryScroll { } private static Runestone changeStone( Runestone r ) { - Runestone n; do { @@ -320,21 +316,31 @@ public class ScrollOfTransmutation extends InventoryScroll { return n; } - + private static Scroll changeScroll( Scroll s ) { - if (s instanceof ExoticScroll) { - return Reflection.newInstance(ExoticScroll.exoToReg.get(s.getClass())); - } else { - return Reflection.newInstance(ExoticScroll.regToExo.get(s.getClass())); - } + Scroll n; + + do { + n = (Scroll)Generator.randomUsingDefaults( Generator.Category.SCROLL ); + if (s instanceof ExoticScroll){ + n = Reflection.newInstance(ExoticScroll.regToExo.get(n.getClass())); + } + } while (n.getClass() == s.getClass()); + + return n; } - + private static Potion changePotion( Potion p ) { - if (p instanceof ExoticPotion) { - return Reflection.newInstance(ExoticPotion.exoToReg.get(p.getClass())); - } else { - return Reflection.newInstance(ExoticPotion.regToExo.get(p.getClass())); - } + Potion n; + + do { + n = (Potion)Generator.randomUsingDefaults( Generator.Category.POTION ); + if (p instanceof ExoticPotion){ + n = Reflection.newInstance(ExoticPotion.regToExo.get(n.getClass())); + } + } while (n.getClass() == p.getClass()); + + return n; } @Override 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 1587f0c4c..80aa0484f 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,27 +21,22 @@ package com.shatteredpixel.shatteredpixeldungeon.items.spells; -import com.shatteredpixel.shatteredpixeldungeon.Challenges; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.Transmuting; -import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.potions.AlchemicalCatalyst; 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.stones.Runestone; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.TippedDart; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.plants.Plant; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; -import com.watabou.utils.Reflection; public class Recycle extends InventorySpell { @@ -60,26 +55,7 @@ public class Recycle extends InventorySpell { @Override protected void onItemSelected(Item item) { - Item result; - do { - if (item instanceof Potion) { - result = Generator.randomUsingDefaults(Generator.Category.POTION); - if (item instanceof ExoticPotion){ - result = Reflection.newInstance(ExoticPotion.regToExo.get(result.getClass())); - } - } else if (item instanceof Scroll) { - result = Generator.randomUsingDefaults(Generator.Category.SCROLL); - if (item instanceof ExoticScroll){ - result = Reflection.newInstance(ExoticScroll.regToExo.get(result.getClass())); - } - } else if (item instanceof Plant.Seed) { - result = Generator.randomUsingDefaults(Generator.Category.SEED); - } else if (item instanceof Runestone) { - result = Generator.randomUsingDefaults(Generator.Category.STONE); - } else { - result = TippedDart.randomTipped(1); - } - } while (result.getClass() == item.getClass() || Challenges.isItemBlocked(result)); + Item result = ScrollOfTransmutation.changeItem(item); item.detach(curUser.belongings.backpack); GLog.p(Messages.get(this, "recycled", result.name()));