* Fixes to put token onto the battlefield that's a copy of creature on the battlefield effects that copy creatures that already copy other creatures.

This commit is contained in:
LevelX2 2014-10-21 16:01:00 +02:00
parent f84bab3c5b
commit 7dd873b1e6
13 changed files with 329 additions and 141 deletions

View file

@ -28,21 +28,14 @@
package mage.sets.bornofthegods;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.condition.common.MyTurnCondition;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.PutTokenOntoBattlefieldCopyTargetEffect;
import mage.abilities.effects.common.ScryEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.EmptyToken;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.util.CardUtil;
/**
*
@ -57,7 +50,7 @@ public class FatedInfatuation extends CardImpl {
this.color.setBlue(true);
// Put a token onto the battlefield that's a copy of target creature you control. If it's your turn, scry 2.
this.getSpellAbility().addEffect(new FatedInfatuationCopyEffect());
this.getSpellAbility().addEffect(new PutTokenOntoBattlefieldCopyTargetEffect());
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
this.getSpellAbility().addEffect(new ConditionalOneShotEffect(new ScryEffect(2), MyTurnCondition.getInstance(), "If it's your turn, scry 2"));
}
@ -71,35 +64,3 @@ public class FatedInfatuation extends CardImpl {
return new FatedInfatuation(this);
}
}
class FatedInfatuationCopyEffect extends OneShotEffect {
public FatedInfatuationCopyEffect() {
super(Outcome.PutCreatureInPlay);
staticText = "Put a token onto the battlefield that's a copy of target creature you control";
}
public FatedInfatuationCopyEffect(final FatedInfatuationCopyEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent == null) {
permanent = (Permanent) game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
}
if (permanent != null) {
EmptyToken token = new EmptyToken();
CardUtil.copyTo(token).from(permanent);
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
return true;
}
return false;
}
@Override
public FatedInfatuationCopyEffect copy() {
return new FatedInfatuationCopyEffect(this);
}
}

View file

@ -36,21 +36,18 @@ import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DoIfCostPaid;
import mage.abilities.effects.common.ExileTargetEffect;
import mage.abilities.keyword.HasteAbility;
import mage.abilities.effects.common.PutTokenOntoBattlefieldCopyTargetEffect;
import mage.abilities.keyword.InspiredAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.EmptyToken;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
/**
*
@ -108,28 +105,20 @@ class FelhideSpiritbinderEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) {
permanent = (Permanent) game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
}
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getFirstTarget());
if (permanent != null) {
EmptyToken token = new EmptyToken();
CardUtil.copyTo(token).from(permanent);
PutTokenOntoBattlefieldCopyTargetEffect effect = new PutTokenOntoBattlefieldCopyTargetEffect(null, CardType.ENCHANTMENT, true);
effect.setTargetPointer(getTargetPointer());
if (effect.apply(game, source) && effect.getAddedPermanent() != null) {
ExileTargetEffect exileEffect = new ExileTargetEffect();
exileEffect.setTargetPointer(new FixedTarget(effect.getAddedPermanent().getId()));
DelayedTriggeredAbility delayedAbility = new AtEndOfTurnDelayedTriggeredAbility(exileEffect);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
game.addDelayedTriggeredAbility(delayedAbility);
if (!token.getCardType().contains(CardType.ENCHANTMENT)) {
token.getCardType().add(CardType.ENCHANTMENT);
return true;
}
token.addAbility(HasteAbility.getInstance());
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
ExileTargetEffect exileEffect = new ExileTargetEffect();
exileEffect.setTargetPointer(new FixedTarget(token.getLastAddedToken()));
DelayedTriggeredAbility delayedAbility = new AtEndOfTurnDelayedTriggeredAbility(exileEffect);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
game.addDelayedTriggeredAbility(delayedAbility);
return true;
}
return false;

View file

@ -36,14 +36,10 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.OnEventTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.EnchantedCondition;
import mage.abilities.condition.common.FlippedCondition;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.decorator.ConditionalContinousEffect;
import mage.abilities.decorator.ConditionalTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CopyTokenEffect;
import mage.abilities.effects.common.FlipSourceEffect;
import mage.cards.CardImpl;
import mage.filter.common.FilterEnchantment;

View file

@ -30,7 +30,7 @@ package mage.sets.commander;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.effects.common.PutCopySourceTokenOntoBattlefield;
import mage.abilities.effects.common.PutTokenOntoBattlefieldCopySource;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -54,7 +54,7 @@ public class Spawnwrithe extends CardImpl {
// Trample
this.addAbility(TrampleAbility.getInstance());
// Whenever Spawnwrithe deals combat damage to a player, put a token that's a copy of Spawnwrithe onto the battlefield.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new PutCopySourceTokenOntoBattlefield(), false));
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new PutTokenOntoBattlefieldCopySource(), false));
}

View file

@ -31,15 +31,17 @@ import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.PutTokenOntoBattlefieldCopyTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.EmptyToken;
import mage.game.permanent.token.Token;
import mage.players.Player;
import mage.players.PlayerList;
import mage.target.common.TargetControlledCreaturePermanent;
@ -90,15 +92,11 @@ class TemptWithReflectionsEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (permanent == null) {
permanent = (Permanent) game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
}
Permanent permanent = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source));
if (permanent != null) {
EmptyToken token = new EmptyToken();
CardUtil.copyTo(token).from(permanent);
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
Effect effect = new PutTokenOntoBattlefieldCopyTargetEffect();
effect.setTargetPointer(getTargetPointer());
effect.apply(game, source);
Set<UUID> playersSaidYes = new HashSet<>();
PlayerList playerList = game.getPlayerList().copy();
@ -119,15 +117,15 @@ class TemptWithReflectionsEffect extends OneShotEffect {
} while (!player.getId().equals(game.getActivePlayerId()));
for (UUID playerId: playersSaidYes) {
token = new EmptyToken();
CardUtil.copyTo(token).from(permanent);
token.putOntoBattlefield(1, game, source.getSourceId(), playerId);
effect = new PutTokenOntoBattlefieldCopyTargetEffect(playerId);
effect.setTargetPointer(getTargetPointer());
effect.apply(game, source);
}
if (playersSaidYes.size() > 0) {
token = new EmptyToken();
CardUtil.copyTo(token).from(permanent);
token.putOntoBattlefield(playersSaidYes.size(), game, source.getSourceId(), source.getControllerId());
effect = new PutTokenOntoBattlefieldCopyTargetEffect();
effect.setTargetPointer(getTargetPointer());
effect.apply(game, source);
}
return true;
}

View file

@ -52,7 +52,6 @@ import mage.filter.predicate.permanent.TokenPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.EmptyToken;
import mage.game.permanent.token.Token;
import mage.util.CardUtil;
import mage.util.functions.ApplyToPermanent;

View file

@ -29,20 +29,13 @@ package mage.sets.innistrad;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TimingRule;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.PutTokenOntoBattlefieldCopyTargetEffect;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.EmptyToken;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.util.CardUtil;
/**
* @author nantuko
@ -56,7 +49,7 @@ public class CacklingCounterpart extends CardImpl {
this.color.setBlue(true);
// Put a token onto the battlefield that's a copy of target creature you control.
this.getSpellAbility().addEffect(new CacklingCounterpartEffect());
this.getSpellAbility().addEffect(new PutTokenOntoBattlefieldCopyTargetEffect());
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
// Flashback {5}{U}{U}
@ -73,36 +66,4 @@ public class CacklingCounterpart extends CardImpl {
}
}
class CacklingCounterpartEffect extends OneShotEffect {
public CacklingCounterpartEffect() {
super(Outcome.PutCreatureInPlay);
staticText = "Put a token onto the battlefield that's a copy of target creature you control";
}
public CacklingCounterpartEffect(final CacklingCounterpartEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent == null) {
permanent = (Permanent) game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
}
if (permanent != null) {
EmptyToken token = new EmptyToken();
CardUtil.copyTo(token).from(permanent);
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
return true;
}
return false;
}
@Override
public CacklingCounterpartEffect copy() {
return new CacklingCounterpartEffect(this);
}
}