* Angelic Destiny - Fixed that the enchantment did not return from graveyard to hand.

This commit is contained in:
LevelX2 2015-05-13 23:05:02 +02:00
parent db694a4c1e
commit 988ed217f3
4 changed files with 101 additions and 6 deletions

View file

@ -6,7 +6,6 @@ import mage.abilities.effects.Effect;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
/**
* "When enchanted/equipped creature dies" triggered ability

View file

@ -44,21 +44,33 @@ import mage.players.Player;
*/
public class ReturnToHandSourceEffect extends OneShotEffect {
boolean fromBattlefieldOnly = false;
boolean fromBattlefieldOnly;
boolean returnFromNextZone ;
public ReturnToHandSourceEffect() {
this(false);
}
public ReturnToHandSourceEffect(boolean fromBattlefieldOnly) {
this(fromBattlefieldOnly, false);
}
/**
*
* @param fromBattlefieldOnly the object is only returned if it's on the battlefield as the effect resolves
* @param returnFromNextZone the object is only returned, if it has changed the zone one time after the source ability triggered or was activated (e.g. Angelic Destiny)
*/
public ReturnToHandSourceEffect(boolean fromBattlefieldOnly, boolean returnFromNextZone) {
super(Outcome.ReturnToHand);
this.fromBattlefieldOnly = fromBattlefieldOnly;
this.returnFromNextZone = returnFromNextZone;
staticText = "return {this} to it's owner's hand";
}
public ReturnToHandSourceEffect(final ReturnToHandSourceEffect effect) {
super(effect);
this.fromBattlefieldOnly = effect.fromBattlefieldOnly;
this.returnFromNextZone = effect.returnFromNextZone;
}
@Override
@ -70,7 +82,13 @@ public class ReturnToHandSourceEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
MageObject mageObject = source.getSourceObjectIfItStillExists(game);
MageObject mageObject;
if (returnFromNextZone &&
game.getState().getZoneChangeCounter(source.getSourceId()) == source.getSourceObjectZoneChangeCounter() + 1) {
mageObject = game.getObject(source.getSourceId());
} else {
mageObject = source.getSourceObjectIfItStillExists(game);
}
if (mageObject != null) {
switch (game.getState().getZone(mageObject.getId())) {
case BATTLEFIELD: