* Unearth - Fixed a problem with exiling the unearthed creature (fixes #1912).

This commit is contained in:
LevelX2 2016-04-27 16:52:15 +02:00
parent 0d11a39fc4
commit 6a03522ee8
4 changed files with 34 additions and 33 deletions

View file

@ -29,6 +29,7 @@ package mage.sets.darkascension;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
@ -115,14 +116,13 @@ class DungeonGeistsEffect extends ContinuousRuleModifyingEffectImpl {
return event.getType() == GameEvent.EventType.UNTAP || event.getType() == GameEvent.EventType.ZONE_CHANGE || event.getType() == GameEvent.EventType.LOST_CONTROL;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
// Source must be on the battlefield (it's neccessary to check here because if as response to the enter
// the battlefield triggered ability the source dies (or will be exiled), then the ZONE_CHANGE or LOST_CONTROL
// event will happen before this effect is applied ever)
Permanent sourcePermanent = (Permanent) source.getSourceObjectIfItStillExists(game);
if (sourcePermanent == null || !sourcePermanent.getControllerId().equals(source.getControllerId())) {
MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
if (!(sourceObject instanceof Permanent) || !((Permanent) sourceObject).getControllerId().equals(source.getControllerId())) {
discard();
return false;
}

View file

@ -29,6 +29,7 @@ package mage.sets.tempest;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
@ -116,8 +117,8 @@ class StarkeOfRathEffect extends OneShotEffect {
if (targetPermanent != null) {
targetPermanent.destroy(source.getSourceId(), game, false);
}
Permanent sourcePermanent = (Permanent) source.getSourceObjectIfItStillExists(game);
if (sourcePermanent != null && targetPermanent != null) {
MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
if ((sourceObject instanceof Permanent) && targetPermanent != null) {
ContinuousEffect effect = new StarkeOfRathControlEffect();
effect.setTargetPointer(new FixedTarget(targetPermanent.getControllerId()));
game.addEffect(effect, source);

View file

@ -1176,7 +1176,7 @@ public abstract class AbilityImpl implements Ability {
MageObjectReference mor = new MageObjectReference(currentObject, game);
if (mor.getZoneChangeCounter() == getSourceObjectZoneChangeCounter()) {
// source object has meanwhile not changed zone
return sourceObject;
return currentObject;
}
}
return null;

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.keyword;
import mage.abilities.Ability;
@ -55,11 +54,12 @@ import mage.players.Player;
*
* 702.82. Unearth
*
* 702.82a Unearth is an activated ability that functions while the card with unearth
* is in a graveyard. "Unearth [cost]" means "[Cost]: Return this card from your graveyard
* to the battlefield. It gains haste. Exile it at the beginning of the next end step.
* If it would leave the battlefield, exile it instead of putting it anywhere else.
* Activate this ability only any time you could cast a sorcery."
* 702.82a Unearth is an activated ability that functions while the card with
* unearth is in a graveyard. "Unearth [cost]" means "[Cost]: Return this card
* from your graveyard to the battlefield. It gains haste. Exile it at the
* beginning of the next end step. If it would leave the battlefield, exile it
* instead of putting it anywhere else. Activate this ability only any time you
* could cast a sorcery."
*
*/
public class UnearthAbility extends ActivatedAbilityImpl {
@ -149,7 +149,7 @@ class UnearthLeavesBattlefieldEffect extends ReplacementEffectImpl {
if (event.getTargetId().equals(source.getSourceId())) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() != Zone.EXILED) {
// started in graveyard goint to battlefield so current zone change counter has to be +1
// started in graveyard going to battlefield so current zone change counter has to be +1
return source.getSourceObjectZoneChangeCounter() + 1 == game.getState().getZoneChangeCounter(source.getSourceId());
}
}