v0.4.0: well of transmutation now works with mages staff

This commit is contained in:
Evan Debenham 2016-06-11 14:03:58 -04:00 committed by Evan Debenham
parent 76294049e1
commit fcefd370c7
2 changed files with 29 additions and 10 deletions

View File

@ -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<?extends Wand> 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 ) {

View File

@ -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<?extends Wand> 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();
}