* Fixed some problems with creation of tokens of target permanents (fixes #1244).

This commit is contained in:
LevelX2 2015-09-08 18:13:32 +02:00
parent 39cfbec82f
commit e37c9a6472
24 changed files with 383 additions and 130 deletions

View file

@ -40,12 +40,9 @@ import mage.constants.Outcome;
import mage.constants.Rarity;
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;
import mage.util.CardUtil;
/**
*
@ -57,7 +54,6 @@ public class TemptWithReflections extends CardImpl {
super(ownerId, 60, "Tempt with Reflections", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{3}{U}");
this.expansionSetCode = "C13";
// Tempting offer - Choose target creature you control. Put a token onto the battlefield that's a copy of that creature. Each opponent may put a token onto the battlefield that's a copy of that creature. For each opponent who does, put a token onto the battlefield that's a copy of that creature.
this.getSpellAbility().addEffect(new TemptWithReflectionsEffect());
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
@ -115,16 +111,16 @@ class TemptWithReflectionsEffect extends OneShotEffect {
player = playerList.getNext(game);
} while (!player.getId().equals(game.getActivePlayerId()));
for (UUID playerId: playersSaidYes) {
for (UUID playerId : playersSaidYes) {
effect = new PutTokenOntoBattlefieldCopyTargetEffect(playerId);
effect.setTargetPointer(getTargetPointer());
effect.apply(game, source);
effect.apply(game, source);
}
if (playersSaidYes.size() > 0) {
effect = new PutTokenOntoBattlefieldCopyTargetEffect();
effect.setTargetPointer(getTargetPointer());
effect.apply(game, source);
effect.apply(game, source);
}
return true;
}

View file

@ -53,7 +53,7 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.EmptyToken;
import mage.util.CardUtil;
import mage.util.functions.ApplyToPermanent;
import mage.util.functions.AbilityApplier;
/**
*
@ -61,6 +61,12 @@ import mage.util.functions.ApplyToPermanent;
*/
public class ProgenitorMimic extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("no Token");
static {
filter.add(Predicates.not(new TokenPredicate()));
}
public ProgenitorMimic(UUID ownerId) {
super(ownerId, 92, "Progenitor Mimic", Rarity.MYTHIC, new CardType[]{CardType.CREATURE}, "{4}{G}{U}");
this.expansionSetCode = "DGM";
@ -72,11 +78,17 @@ public class ProgenitorMimic extends CardImpl {
// You may have Progenitor Mimic enter the battlefield as a copy of any creature on the battlefield
// except it gains "At the beginning of your upkeep, if this creature isn't a token,
// put a token onto the battlefield that's a copy of this creature."
AbilityApplier applier = new AbilityApplier(
new ConditionalTriggeredAbility(
new BeginningOfUpkeepTriggeredAbility(new ProgenitorMimicCopyEffect(), TargetController.YOU, false),
new SourceMatchesFilterCondition(filter),
"At the beginning of your upkeep, if this creature isn't a token, put a token onto the battlefield that's a copy of this creature.")
);
this.addAbility(new SimpleStaticAbility(
Zone.BATTLEFIELD,
new EntersBattlefieldEffect(new CopyPermanentEffect(new ProgenitorMimicApplyToPermanent()),
"You may have {this} enter the battlefield as a copy of any creature on the battlefield except it gains \"At the beginning of your upkeep, if this creature isn't a token, put a token onto the battlefield that's a copy of this creature.\"",
true)));
new EntersBattlefieldEffect(new CopyPermanentEffect(applier),
"You may have {this} enter the battlefield as a copy of any creature on the battlefield except it gains \"At the beginning of your upkeep, if this creature isn't a token, put a token onto the battlefield that's a copy of this creature.\"",
true)));
}
public ProgenitorMimic(final ProgenitorMimic card) {
@ -89,24 +101,6 @@ public class ProgenitorMimic extends CardImpl {
}
}
class ProgenitorMimicApplyToPermanent extends ApplyToPermanent {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("no Token");
static {
filter.add(Predicates.not(new TokenPredicate()));
}
@Override
public Boolean apply(Game game, Permanent permanent) {
Ability ability = new ConditionalTriggeredAbility(
new BeginningOfUpkeepTriggeredAbility(new ProgenitorMimicCopyEffect(), TargetController.YOU, false),
new SourceMatchesFilterCondition(filter),
"At the beginning of your upkeep, if this creature isn't a token, put a token onto the battlefield that's a copy of this creature.");
permanent.addAbility(ability, game);
return true;
}
}
class ProgenitorMimicCopyEffect extends OneShotEffect {
public ProgenitorMimicCopyEffect() {
@ -144,14 +138,14 @@ class ProgenitorMimicCopyEffect extends OneShotEffect {
// if it was no copy of copy take the target itself
copyFromPermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
}
if (copyFromPermanent != null) {
EmptyToken token = new EmptyToken();
if (copyFromPermanent != null) {
EmptyToken token = new EmptyToken();
CardUtil.copyTo(token).from(copyFromPermanent); // needed so that entersBattlefied triggered abilities see the attributes (e.g. Master Biomancer)
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
Permanent newPermanentToken = game.getPermanent(token.getLastAddedToken());
if (newPermanentToken != null) {
game.copyPermanent(copyFromPermanent, newPermanentToken, source, null);
game.copyPermanent(copyFromPermanent, newPermanentToken, source, null);
return true;
}
}

View file

@ -28,10 +28,8 @@
package mage.sets.innistrad;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
@ -41,6 +39,9 @@ import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.common.CopyPermanentEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.ObjectSourcePlayer;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
@ -55,8 +56,6 @@ import mage.util.functions.ApplyToPermanent;
*/
public class EvilTwin extends CardImpl {
public EvilTwin(UUID ownerId) {
super(ownerId, 212, "Evil Twin", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{2}{U}{B}");
this.expansionSetCode = "ISD";
@ -69,8 +68,8 @@ public class EvilTwin extends CardImpl {
this.addAbility(new SimpleStaticAbility(
Zone.BATTLEFIELD,
new EntersBattlefieldEffect(new CopyPermanentEffect(new EvilTwinApplyToPermanent()),
"You may have {this} enter the battlefield as a copy of any creature on the battlefield except it gains \"{U}{B}, {T}: Destroy target creature with the same name as this creature\"",
true)));
"You may have {this} enter the battlefield as a copy of any creature on the battlefield except it gains \"{U}{B}, {T}: Destroy target creature with the same name as this creature\"",
true)));
}
public EvilTwin(final EvilTwin card) {
@ -99,6 +98,16 @@ class EvilTwinApplyToPermanent extends ApplyToPermanent {
permanent.addAbility(ability, game);
return true;
}
@Override
public Boolean apply(Game game, MageObject mageObject) {
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new ManaCostsImpl("{U}{B}"));
ability.addCost(new TapSourceCost());
ability.addTarget(new TargetCreaturePermanent(filter));
mageObject.getAbilities().add(ability);
return true;
}
}
class EvilTwinPredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<Permanent>> {

View file

@ -28,7 +28,7 @@
package mage.sets.limitedalpha;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.EntersBattlefieldEffect;
@ -50,7 +50,7 @@ import mage.util.functions.ApplyToPermanent;
/**
*
* @author KholdFuzion
*
*/
public class CopyArtifact extends CardImpl {
@ -58,7 +58,6 @@ public class CopyArtifact extends CardImpl {
super(ownerId, 54, "Copy Artifact", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}");
this.expansionSetCode = "LEA";
// You may have Copy Artifact enter the battlefield as a copy of any artifact on the battlefield, except it's an enchantment in addition to its other types.
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new EntersBattlefieldEffect(
new CopyArtifactEffect(),
@ -79,6 +78,25 @@ public class CopyArtifact extends CardImpl {
class CopyArtifactEffect extends OneShotEffect {
ApplyToPermanent applier = new ApplyToPermanent() {
@Override
public Boolean apply(Game game, Permanent permanent) {
if (!permanent.getCardType().contains(CardType.ENCHANTMENT)) {
permanent.getCardType().add(CardType.ENCHANTMENT);
}
return true;
}
@Override
public Boolean apply(Game game, MageObject mageObject) {
if (!mageObject.getCardType().contains(CardType.ENCHANTMENT)) {
mageObject.getCardType().add(CardType.ENCHANTMENT);
}
return true;
}
};
private static final FilterPermanent filter = new FilterPermanent("artifact");
static {
@ -104,16 +122,7 @@ class CopyArtifactEffect extends OneShotEffect {
player.choose(Outcome.Copy, target, source.getSourceId(), game);
Permanent copyFromPermanent = game.getPermanent(target.getFirstTarget());
if (copyFromPermanent != null) {
game.copyPermanent(copyFromPermanent, sourcePermanent, source, new ApplyToPermanent() {
@Override
public Boolean apply(Game game, Permanent permanent) {
if (!permanent.getCardType().contains(CardType.ENCHANTMENT)) {
permanent.getCardType().add(CardType.ENCHANTMENT);
}
return true;
}
});
game.copyPermanent(copyFromPermanent, sourcePermanent, source, applier);
return true;
}
}

View file

@ -29,6 +29,7 @@ package mage.sets.magic2012;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.BecomesTargetTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
@ -115,6 +116,18 @@ class PhantasmalImageCopyEffect extends OneShotEffect {
//permanent.addAbility(new BecomesTargetTriggeredAbility(new SacrificeSourceEffect()), game);
return true;
}
@Override
public Boolean apply(Game game, MageObject mageObject) {
if (!mageObject.getSubtype().contains("Illusion")) {
mageObject.getSubtype().add("Illusion");
}
// Add directly because the created permanent is only used to copy from, so there is no need to add the ability to e.g. TriggeredAbilities
mageObject.getAbilities().add(new BecomesTargetTriggeredAbility(new SacrificeSourceEffect()));
//permanent.addAbility(new BecomesTargetTriggeredAbility(new SacrificeSourceEffect()), game);
return true;
}
});
return true;

View file

@ -47,7 +47,7 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.Target;
import mage.target.TargetPermanent;
import mage.util.functions.ApplyToPermanent;
import mage.util.functions.AbilityApplier;
/**
*
@ -82,6 +82,7 @@ public class MercurialPretender extends CardImpl {
return new MercurialPretender(this);
}
}
class MercurialPretenderCopyEffect extends OneShotEffect {
public MercurialPretenderCopyEffect() {
@ -103,16 +104,10 @@ class MercurialPretenderCopyEffect extends OneShotEffect {
player.choose(Outcome.Copy, target, source.getSourceId(), game);
Permanent copyFromPermanent = game.getPermanent(target.getFirstTarget());
if (copyFromPermanent != null) {
game.copyPermanent(copyFromPermanent, sourcePermanent, source, new ApplyToPermanent() {
@Override
public Boolean apply(Game game, Permanent permanent) {
game.copyPermanent(copyFromPermanent, sourcePermanent, source,
// {2}{U}{U}: Return this creature to its owner's hand.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ReturnToHandSourceEffect(true), new ManaCostsImpl("{2}{U}{U}"));
permanent.addAbility(ability, game);
return true;
}
});
new AbilityApplier(new SimpleActivatedAbility(Zone.BATTLEFIELD, new ReturnToHandSourceEffect(true), new ManaCostsImpl("{2}{U}{U}")))
);
return true;
}
}

View file

@ -29,6 +29,7 @@ package mage.sets.mirrodinbesieged;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
@ -110,6 +111,15 @@ class CryptoplasmEffect extends OneShotEffect {
permanent.addAbility(upkeepAbility, source.getSourceId(), game);
return true;
}
@Override
public Boolean apply(Game game, MageObject mageObject) {
Ability upkeepAbility = new BeginningOfUpkeepTriggeredAbility(new CryptoplasmEffect(), TargetController.YOU, true);
upkeepAbility.addTarget(new TargetCreaturePermanent());
mageObject.getAbilities().add(upkeepAbility);
return true;
}
});
game.addEffect(effect, source);

View file

@ -25,20 +25,20 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.newphyrexia;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.common.CopyPermanentEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
@ -51,7 +51,7 @@ import mage.util.functions.ApplyToPermanent;
* @author Loki
*/
public class PhyrexianMetamorph extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("artifact or creature");
static {
@ -59,8 +59,8 @@ public class PhyrexianMetamorph extends CardImpl {
new CardTypePredicate(CardType.ARTIFACT),
new CardTypePredicate(CardType.CREATURE)));
}
public PhyrexianMetamorph (UUID ownerId) {
public PhyrexianMetamorph(UUID ownerId) {
super(ownerId, 42, "Phyrexian Metamorph", Rarity.RARE, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{3}{UP}");
this.expansionSetCode = "NPH";
this.subtype.add("Shapeshifter");
@ -71,13 +71,19 @@ public class PhyrexianMetamorph extends CardImpl {
ApplyToPermanent phyrexianMetamorphApplier = new ApplyToPermanent() {
@Override
public Boolean apply(Game game, Permanent permanent) {
if (!permanent.getCardType().contains(CardType.ARTIFACT)) {
permanent.getCardType().add(CardType.ARTIFACT);
return apply(game, (MageObject) permanent);
}
@Override
public Boolean apply(Game game, MageObject mageObject) {
if (!mageObject.getCardType().contains(CardType.ARTIFACT)) {
mageObject.getCardType().add(CardType.ARTIFACT);
}
return true;
}
};
// {UP} ( can be paid with either {U} or 2 life.)
// You may have Phyrexian Metamorph enter the battlefield as a copy of any artifact or creature on the battlefield, except it's an artifact in addition to its other types.
Effect effect = new CopyPermanentEffect(filter, phyrexianMetamorphApplier);
@ -86,7 +92,7 @@ public class PhyrexianMetamorph extends CardImpl {
this.addAbility(ability);
}
public PhyrexianMetamorph (final PhyrexianMetamorph card) {
public PhyrexianMetamorph(final PhyrexianMetamorph card) {
super(card);
}

View file

@ -28,16 +28,17 @@
package mage.sets.planechase2012;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.common.CopyPermanentEffect;
import mage.abilities.keyword.NinjutsuAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.util.functions.ApplyToPermanent;
@ -60,7 +61,7 @@ public class SakashimasStudent extends CardImpl {
// Ninjutsu {1}{U}
this.addAbility(new NinjutsuAbility(new ManaCostsImpl("{1}{U}")));
// You may have Sakashima's Student enter the battlefield as a copy of any creature on the battlefield, except it's still a Ninja in addition to its other creature types.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,new EntersBattlefieldEffect(
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new EntersBattlefieldEffect(
new CopyPermanentEffect(new SakashimasStudentApplyToPermanent()),
"You may have {this} enter the battlefield as a copy of any creature on the battlefield, except it's still a Ninja in addition to its other creature types",
true)));
@ -86,4 +87,13 @@ class SakashimasStudentApplyToPermanent extends ApplyToPermanent {
}
return true;
}
@Override
public Boolean apply(Game game, MageObject mageObject) {
if (!mageObject.getSubtype().contains("Ninja")) {
mageObject.getSubtype().add("Ninja");
}
return true;
}
}

View file

@ -29,6 +29,7 @@ package mage.sets.saviorsofkamigawa;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
@ -119,6 +120,21 @@ class SakashimaTheImpostorCopyEffect extends OneShotEffect {
), game);
return true;
}
@Override
public Boolean apply(Game game, MageObject mageObject) {
if (!mageObject.getSupertype().contains("Legendary")) {
mageObject.getSubtype().add("Legendary");
}
mageObject.setName("Sakashima the Impostor");
// {2}{U}{U}: Return Sakashima the Impostor to its owner's hand at the beginning of the next end step
mageObject.getAbilities().add(new SimpleActivatedAbility(Zone.BATTLEFIELD,
new CreateDelayedTriggeredAbilityEffect(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnToHandSourceEffect(true)), false),
new ManaCostsImpl("{2}{U}{U}")
));
return true;
}
});
return true;

View file

@ -29,6 +29,7 @@ package mage.sets.theros;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CopyPermanentEffect;
@ -77,6 +78,14 @@ public class ArtisanOfForms extends CardImpl {
class ArtisanOfFormsApplyToPermanent extends ApplyToPermanent {
@Override
public Boolean apply(Game game, MageObject mageObject) {
Effect effect = new CopyPermanentEffect(new ArtisanOfFormsApplyToPermanent());
effect.setText("have {this} become a copy of target creature and gain this ability");
mageObject.getAbilities().add(new HeroicAbility(effect, true));
return true;
}
@Override
public Boolean apply(Game game, Permanent permanent) {
Effect effect = new CopyPermanentEffect(new ArtisanOfFormsApplyToPermanent());
@ -84,4 +93,5 @@ class ArtisanOfFormsApplyToPermanent extends ApplyToPermanent {
permanent.addAbility(new HeroicAbility(effect, true), game);
return true;
}
}

View file

@ -29,6 +29,7 @@ package mage.sets.unlimitededition;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
@ -115,6 +116,15 @@ class VesuvanDoppelgangerCopyEffect extends OneShotEffect {
new VesuvanDoppelgangerCopyEffect(), TargetController.YOU, true, false, rule2));
return true;
}
@Override
public Boolean apply(Game game, MageObject mageObject) {
mageObject.getColor(game).setColor(sourcePermanent.getColor(game));
mageObject.getAbilities().add(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD,
new VesuvanDoppelgangerCopyEffect(), TargetController.YOU, true, false, rule2));
return true;
}
});
return true;
}
@ -127,4 +137,4 @@ class VesuvanDoppelgangerCopyEffect extends OneShotEffect {
public VesuvanDoppelgangerCopyEffect copy() {
return new VesuvanDoppelgangerCopyEffect(this);
}
}
}

View file

@ -29,6 +29,7 @@ package mage.sets.vintagemasters;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.EntersBattlefieldEffect;
import mage.abilities.effects.common.CopyPermanentEffect;
@ -86,4 +87,12 @@ class DacksDuplicateApplyToPermanent extends ApplyToPermanent {
permanent.addAbility(HasteAbility.getInstance(), game);
return true;
}
@Override
public Boolean apply(Game game, MageObject mageObject) {
mageObject.getAbilities().add(new DethroneAbility());
mageObject.getAbilities().add(HasteAbility.getInstance());
return true;
}
}