forked from External/mage
Copying and creating tokens from double-sided cards.
This commit is contained in:
parent
642cd84e97
commit
0c9151cc1f
7 changed files with 52 additions and 2 deletions
|
|
@ -61,7 +61,10 @@ public interface Card extends MageObject {
|
|||
public boolean isFaceDown();
|
||||
|
||||
public boolean canTransform();
|
||||
public void setCanTransform(boolean value);
|
||||
public Card getSecondCardFace();
|
||||
public void setSecondCardFace(Card card);
|
||||
|
||||
public boolean isNightCard();
|
||||
|
||||
public void assignNewId();
|
||||
|
|
|
|||
|
|
@ -386,4 +386,14 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
|||
public boolean isNightCard() {
|
||||
return this.nightCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCanTransform(boolean canTransform) {
|
||||
this.canTransform = canTransform;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecondCardFace(Card card) {
|
||||
this.secondSideCard = card;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,12 +28,14 @@
|
|||
|
||||
package mage.game.permanent;
|
||||
|
||||
import mage.game.permanent.token.Token;
|
||||
import java.util.UUID;
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.token.Token;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -104,6 +106,8 @@ public class PermanentToken extends PermanentImpl<PermanentToken> {
|
|||
return token;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public PermanentToken copy() {
|
||||
return new PermanentToken(this);
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ public class Token extends MageObjectImpl<Token> {
|
|||
|
||||
protected String description;
|
||||
private UUID lastAddedTokenId;
|
||||
private boolean canTransform;
|
||||
private Card secondCardFace;
|
||||
|
||||
public Token(String name, String description) {
|
||||
this.name = name;
|
||||
|
|
@ -68,6 +70,7 @@ public class Token extends MageObjectImpl<Token> {
|
|||
public Token(final Token token) {
|
||||
super(token);
|
||||
this.description = token.description;
|
||||
this.canTransform = token.canTransform;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
|
|
@ -96,6 +99,10 @@ public class Token extends MageObjectImpl<Token> {
|
|||
amount = event.getAmount();
|
||||
for (int i = 0; i < amount; i++) {
|
||||
PermanentToken permanent = new PermanentToken(this, controllerId, setCode);
|
||||
if (this.canTransform) {
|
||||
permanent.setCanTransform(this.canTransform);
|
||||
permanent.setSecondCardFace(this.secondCardFace);
|
||||
}
|
||||
game.getBattlefield().addPermanent(permanent);
|
||||
this.lastAddedTokenId = permanent.getId();
|
||||
permanent.entersBattlefield(sourceId, game);
|
||||
|
|
@ -107,4 +114,11 @@ public class Token extends MageObjectImpl<Token> {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void setCanTransform(boolean canTransform) {
|
||||
this.canTransform = canTransform;
|
||||
}
|
||||
|
||||
public void setSecondCardFace(Card card) {
|
||||
this.secondCardFace = card;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -351,6 +351,10 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCanTransform(boolean value) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Card getSecondCardFace() {
|
||||
return null;
|
||||
|
|
@ -436,5 +440,9 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
|||
public void setCopiedSpell(boolean isCopied) {
|
||||
this.copiedSpell = isCopied;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecondCardFace(Card card) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,6 +79,11 @@ public class CopyFunction implements Function<Card, Card> {
|
|||
target.getPower().setValue(source.getPower().getValue());
|
||||
target.getToughness().setValue(source.getToughness().getValue());
|
||||
|
||||
if (source.canTransform()) {
|
||||
target.setCanTransform(true);
|
||||
target.setSecondCardFace(source.getSecondCardFace());
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ package mage.util.functions;
|
|||
import mage.Constants;
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.game.permanent.PermanentToken;
|
||||
import mage.game.permanent.token.Token;
|
||||
|
||||
/**
|
||||
|
|
@ -79,6 +80,11 @@ public class CopyTokenFunction implements Function<Token, Card> {
|
|||
target.getPower().setValue(source.getPower().getValue());
|
||||
target.getToughness().setValue(source.getToughness().getValue());
|
||||
|
||||
if (source.canTransform()) {
|
||||
target.setCanTransform(true);
|
||||
target.setSecondCardFace(source.getSecondCardFace());
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue