Changes to the reset handling of ManaSpentToCastWatcher.

This commit is contained in:
LevelX2 2015-03-22 20:14:35 +01:00
parent 740611119b
commit 59293271a5
2 changed files with 12 additions and 3 deletions

View file

@ -34,7 +34,6 @@ import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
/**
*

View file

@ -33,6 +33,7 @@ import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.stack.Spell;
import mage.watchers.Watcher;
@ -63,6 +64,11 @@ public class ManaSpentToCastWatcher extends Watcher {
payment = spell.getSpellAbility().getManaCostsToPay().getPayment();
}
}
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && this.getSourceId().equals(event.getSourceId())) {
if (((ZoneChangeEvent) event).getFromZone().equals(Zone.BATTLEFIELD)) {
payment = null;
}
}
}
@Override
@ -74,11 +80,15 @@ public class ManaSpentToCastWatcher extends Watcher {
Mana returnPayment = null;
if (payment != null) {
returnPayment = payment.copy();
// reset payment for next check
payment = null;
}
return returnPayment;
}
@Override
public void reset() {
super.reset();
payment = null;
}
}