From fcefd370c713be1e9e7bd09eee6910c0536ca048 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 11 Jun 2016 14:03:58 -0400 Subject: [PATCH] v0.4.0: well of transmutation now works with mages staff --- .../actors/blobs/WaterOfTransmutation.java | 23 ++++++++++++++++++- .../items/weapon/melee/MagesStaff.java | 16 ++++++------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WaterOfTransmutation.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WaterOfTransmutation.java index 500be448c..52a91e60b 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WaterOfTransmutation.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/blobs/WaterOfTransmutation.java @@ -20,6 +20,7 @@ */ package com.shatteredpixel.shatteredpixeldungeon.actors.blobs; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Journal; import com.shatteredpixel.shatteredpixeldungeon.Journal.Feature; import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter; @@ -43,6 +44,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Glaive; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Knuckles; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Longsword; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Mace; +import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Quarterstaff; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Spear; @@ -58,7 +60,9 @@ public class WaterOfTransmutation extends WellWater { @Override protected Item affectItem( Item item ) { - if (item instanceof MeleeWeapon) { + if (item instanceof MagesStaff) { + item = changeStaff( (MagesStaff)item ); + } else if (item instanceof MeleeWeapon) { item = changeWeapon( (MeleeWeapon)item ); } else if (item instanceof Scroll) { item = changeScroll( (Scroll)item ); @@ -89,6 +93,23 @@ public class WaterOfTransmutation extends WellWater { super.use( emitter ); emitter.start( Speck.factory( Speck.CHANGE ), 0.2f, 0 ); } + + private MagesStaff changeStaff( MagesStaff staff ){ + Class wandClass = staff.wandClass(); + + if (wandClass == null){ + return null; + } else { + Wand n; + do { + n = (Wand)Generator.random(Category.WAND); + } while (n.getClass() == wandClass); + n.level(0); + staff.imbueWand(n, null); + } + + return staff; + } private Weapon changeWeapon( MeleeWeapon w ) { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java index 459fed5b1..2b903d848 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MagesStaff.java @@ -157,13 +157,6 @@ public class MagesStaff extends MeleeWeapon { this.wand = null; - GLog.p( Messages.get(this, "imbue", wand.name())); - - if (enchantment != null) { - GLog.w( Messages.get(this, "conflict") ); - enchant(null); - } - //syncs the level of the two items. int targetLevel = Math.max(this.level(), wand.level()); @@ -184,7 +177,7 @@ public class MagesStaff extends MeleeWeapon { wand.curCharges = wand.maxCharges; wand.identify(); wand.cursed = false; - wand.charge(owner); + if (owner != null) wand.charge(owner); name = Messages.get(wand, "staff_name"); @@ -193,6 +186,10 @@ public class MagesStaff extends MeleeWeapon { return this; } + public Class wandClass(){ + return wand != null ? wand.getClass() : null; + } + @Override public Item upgrade(boolean enchant) { super.upgrade( enchant ); @@ -313,7 +310,8 @@ public class MagesStaff extends MeleeWeapon { wand.detach(curUser.belongings.backpack); Badges.validateTutorial(); - imbueWand((Wand) wand, curUser); + GLog.p( Messages.get(MagesStaff.class, "imbue", wand.name())); + imbueWand( wand, curUser ); updateQuickslot(); }