* Prized Amalgam - Fixed that it also returned if it entered and left the battlefield after the trigger was created (fixes #2485).

This commit is contained in:
LevelX2 2016-10-20 15:04:27 +02:00
parent 4732f83082
commit 77729e892c
2 changed files with 26 additions and 9 deletions

View file

@ -33,7 +33,7 @@ import mage.abilities.common.EntersBattlefieldAllTriggeredAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.ReturnSourceFromGraveyardToBattlefieldEffect;
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
@ -45,6 +45,7 @@ import mage.filter.predicate.other.OwnerPredicate;
import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent;
import mage.target.targetpointer.FixedTarget;
import mage.watchers.common.CastFromGraveyardWatcher;
/**
@ -67,7 +68,7 @@ public class PrizedAmalgam extends CardImpl {
// Whenever a creature enters the battlefield, if it entered from your graveyard or you cast it from your graveyard, return Prized Amalgam from your graveyard to the battlefield tapped at the beginning of the next end step.
this.addAbility(new PrizedAmalgamTriggerdAbility(new CreateDelayedTriggeredAbilityEffect(
new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnSourceFromGraveyardToBattlefieldEffect(true))), filter),
new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromGraveyardToBattlefieldTargetEffect(true))), filter),
new CastFromGraveyardWatcher());
}
@ -98,20 +99,32 @@ class PrizedAmalgamTriggerdAbility extends EntersBattlefieldAllTriggeredAbility
@Override
public boolean checkTrigger(GameEvent event, Game game) {
/**
* 4/8/2016 Prized Amalgams ability triggers only if its in your
* graveyard immediately after a creature enters the battlefield from
* your graveyard or you cast a creature from your graveyard. A Prized
* Amalgam thats already on the battlefield wont be returned at the
* beginning of the next end step if its put into your graveyard later.
*/
boolean result = false;
if (super.checkTrigger(event, game)) {
EntersTheBattlefieldEvent entersEvent = (EntersTheBattlefieldEvent) event;
if (entersEvent.getFromZone().equals(Zone.GRAVEYARD)) {
return true;
}
if (entersEvent.getFromZone().equals(Zone.STACK) && entersEvent.getTarget().getControllerId().equals(getControllerId())) {
result = true;
} else if (entersEvent.getFromZone().equals(Zone.STACK) && entersEvent.getTarget().getControllerId().equals(getControllerId())) {
CastFromGraveyardWatcher watcher = (CastFromGraveyardWatcher) game.getState().getWatchers().get(CastFromGraveyardWatcher.class.getName());
if (watcher != null) {
int zcc = game.getState().getZoneChangeCounter(event.getSourceId());
return watcher.spellWasCastFromGraveyard(event.getSourceId(), zcc - 1);
result = watcher.spellWasCastFromGraveyard(event.getSourceId(), zcc - 1);
}
}
}
return false;
if (result) {
for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(getSourceId(), game.getState().getZoneChangeCounter(getSourceId())));
}
}
return result;
}
@Override

View file

@ -27,6 +27,8 @@
*/
package mage.abilities.effects.common;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
@ -70,12 +72,14 @@ public class ReturnFromGraveyardToBattlefieldTargetEffect extends OneShotEffect
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Set<Card> cardsToMove = new HashSet<>();
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
Card card = game.getCard(targetId);
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game, tapped, false, false, null);
cardsToMove.add(card);
}
}
controller.moveCards(cardsToMove, Zone.BATTLEFIELD, source, game, tapped, false, false, null);
return true;
}
return false;