mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
* Becomes a copy abilities: improved support with MDF cards (#8335);
This commit is contained in:
parent
35b257bd8f
commit
afdae939c3
9 changed files with 141 additions and 18 deletions
|
|
@ -10,20 +10,20 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
import mage.game.permanent.PermanentToken;
|
||||
import mage.util.CardUtil;
|
||||
import mage.util.functions.CopyApplier;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Make battlefield's permanent as a copy of the source object
|
||||
* (source can be a card or another permanent)
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CopyEffect extends ContinuousEffectImpl {
|
||||
|
||||
/**
|
||||
* Object we copy from
|
||||
*/
|
||||
protected MageObject copyFromObject;
|
||||
|
||||
protected UUID copyToObjectId;
|
||||
protected CopyApplier applier;
|
||||
|
||||
|
|
@ -47,9 +47,13 @@ public class CopyEffect extends ContinuousEffectImpl {
|
|||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
|
||||
// must copy the default side of the card (example: clone with mdf card)
|
||||
if (!(copyFromObject instanceof Permanent) && (copyFromObject instanceof Card)) {
|
||||
this.copyFromObject = new PermanentCard((Card) copyFromObject, source.getControllerId(), game);
|
||||
Card newBluePrint = CardUtil.getDefaultCardSideForBattlefield(game, (Card) copyFromObject);
|
||||
this.copyFromObject = new PermanentCard(newBluePrint, source.getControllerId(), game);
|
||||
}
|
||||
|
||||
Permanent permanent = game.getPermanent(copyToObjectId);
|
||||
if (permanent != null) {
|
||||
affectedObjectList.add(new MageObjectReference(permanent, game));
|
||||
|
|
|
|||
|
|
@ -997,7 +997,7 @@ public final class CardUtil {
|
|||
// same logic as ZonesHandler->maybeRemoveFromSourceZone
|
||||
|
||||
// workaround to put real permanent from one side (example: you call mdf card by cheats)
|
||||
Card permCard = getDefaultCardSideForBattlefield(newCard);
|
||||
Card permCard = getDefaultCardSideForBattlefield(game, newCard);
|
||||
|
||||
// prepare card and permanent
|
||||
permCard.setZone(Zone.BATTLEFIELD, game);
|
||||
|
|
@ -1035,12 +1035,17 @@ public final class CardUtil {
|
|||
|
||||
/**
|
||||
* Choose default card's part to put on battlefield (for cheats and tests only)
|
||||
* or to find a default card side (for copy effect)
|
||||
*
|
||||
* @param card
|
||||
* @return
|
||||
*/
|
||||
public static Card getDefaultCardSideForBattlefield(Card card) {
|
||||
// chose left side all time
|
||||
public static Card getDefaultCardSideForBattlefield(Game game, Card card) {
|
||||
if (card instanceof PermanentCard) {
|
||||
return card;
|
||||
}
|
||||
|
||||
// must choose left side all time
|
||||
Card permCard;
|
||||
if (card instanceof SplitCard) {
|
||||
permCard = card;
|
||||
|
|
@ -1051,6 +1056,12 @@ public final class CardUtil {
|
|||
} else {
|
||||
permCard = card;
|
||||
}
|
||||
|
||||
// must be creature/planeswalker (if you catch this error then check targeting/copying code)
|
||||
if (permCard.isInstantOrSorcery(game)) {
|
||||
throw new IllegalArgumentException("Card side can't be put to battlefield: " + permCard.getName());
|
||||
}
|
||||
|
||||
return permCard;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue