mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 05:09:16 -08:00
New way of copying permanents - supports copies of copies. +1 test pass.
This commit is contained in:
parent
e5b6807d91
commit
0d732e8f86
11 changed files with 149 additions and 49 deletions
|
|
@ -27,8 +27,6 @@
|
|||
*/
|
||||
package mage.sets.magic2012;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
|
|
@ -38,7 +36,6 @@ import mage.abilities.common.BecomesTargetTriggeredAbility;
|
|||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.effects.EntersBattlefieldEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.CopyEffect;
|
||||
import mage.abilities.effects.common.SacrificeSourceEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
|
|
@ -47,6 +44,9 @@ import mage.game.permanent.Permanent;
|
|||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.util.functions.ApplyToPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -98,15 +98,17 @@ class PhantasmalImageCopyEffect extends OneShotEffect<PhantasmalImageCopyEffect>
|
|||
target.setRequired(true);
|
||||
target.setNotTarget(true);
|
||||
player.choose(Outcome.Copy, target, source.getSourceId(), game);
|
||||
Permanent permanent = game.getPermanent(target.getFirstTarget());
|
||||
UUID targetId = target.getFirstTarget();
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent != null) {
|
||||
permanent = permanent.copy();
|
||||
permanent.reset(game);
|
||||
permanent.assignNewId();
|
||||
permanent.getSubtype().add("Illusion");
|
||||
permanent.addAbility(new BecomesTargetTriggeredAbility(new SacrificeSourceEffect()), game);
|
||||
|
||||
game.addEffect(new CopyEffect(permanent), source);
|
||||
game.copyPermanent(permanent, source, new ApplyToPermanent() {
|
||||
@Override
|
||||
public Boolean apply(Game game, Permanent permanent) {
|
||||
permanent.getSubtype().add("Illusion");
|
||||
permanent.addAbility(new BecomesTargetTriggeredAbility(new SacrificeSourceEffect()), game);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@
|
|||
|
||||
package mage.sets.newphyrexia;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
|
|
@ -38,7 +36,6 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.effects.EntersBattlefieldEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.CopyEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.FilterPermanent;
|
||||
|
|
@ -47,6 +44,9 @@ import mage.game.permanent.Permanent;
|
|||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.util.functions.ApplyToPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -96,7 +96,6 @@ class PhyrexianMetamorphEffect extends OneShotEffect<PhyrexianMetamorphEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
//TODO: handle copying copies
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
Target target = new TargetPermanent(filter);
|
||||
|
|
@ -104,12 +103,16 @@ class PhyrexianMetamorphEffect extends OneShotEffect<PhyrexianMetamorphEffect> {
|
|||
player.choose(Outcome.Copy, target, source.getSourceId(), game);
|
||||
Permanent perm = game.getPermanent(target.getFirstTarget());
|
||||
if (perm != null) {
|
||||
perm = perm.copy();
|
||||
perm.reset(game);
|
||||
perm.assignNewId();
|
||||
if (!perm.getCardType().contains(CardType.ARTIFACT))
|
||||
perm.getCardType().add(CardType.ARTIFACT);
|
||||
game.addEffect(new CopyEffect(perm), source);
|
||||
game.copyPermanent(perm, source, new ApplyToPermanent() {
|
||||
@Override
|
||||
public Boolean apply(Game game, Permanent permanent) {
|
||||
if (!permanent.getCardType().contains(CardType.ARTIFACT)) {
|
||||
permanent.getCardType().add(CardType.ARTIFACT);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue