mirror of
https://github.com/magefree/mage.git
synced 2026-01-23 03:39:54 -08:00
add new TDFC class which allows for gradual transition to new refactor
This commit is contained in:
parent
6b2317839b
commit
acdc774e40
10 changed files with 222 additions and 51 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package mage.cards;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Abilities;
|
||||
|
|
@ -250,6 +251,10 @@ public interface Card extends MageObject, Ownerable {
|
|||
|
||||
List<UUID> getAttachments();
|
||||
|
||||
void setPT(int power, int toughness);
|
||||
|
||||
void setPT(MageInt power, MageInt toughness);
|
||||
|
||||
/**
|
||||
* @param attachment can be any object: card, permanent, token
|
||||
* @param source can be null for default checks like state base
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package mage.cards;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.MageObjectImpl;
|
||||
import mage.Mana;
|
||||
|
|
@ -393,6 +394,17 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
this.abilities.setControllerId(ownerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPT(int power, int toughness) {
|
||||
this.setPT(new MageInt(power), new MageInt(toughness));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPT(MageInt power, MageInt toughness) {
|
||||
this.power = power;
|
||||
this.toughness = toughness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getControllerOrOwnerId() {
|
||||
return getOwnerId();
|
||||
|
|
@ -947,7 +959,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (controller != null && spellAbility != null && !spellAbility.getTargets().isEmpty()){
|
||||
if (controller != null && spellAbility != null && !spellAbility.getTargets().isEmpty()) {
|
||||
// Line of code below functionally gets the target of the aura's Enchant ability, then compares to this permanent. Enchant improperly implemented in XMage, see #9583
|
||||
// Note: stillLegalTarget used exclusively to account for Dream Leash. Can be made canTarget in the event that that card is rewritten (and "stillLegalTarget" removed from TargetImpl).
|
||||
canAttach &= spellAbility.getTargets().get(0).copy().withNotTarget(true).stillLegalTarget(controller, this.getId(), source, game);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package mage.cards;
|
||||
|
||||
import mage.MageInt;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
|
|
@ -9,8 +7,4 @@ public interface ModalDoubleFacedCardHalf extends SubCard<ModalDoubleFacedCard>
|
|||
|
||||
@Override
|
||||
ModalDoubleFacedCardHalf copy();
|
||||
|
||||
void setPT(int power, int toughness);
|
||||
|
||||
void setPT(MageInt power, MageInt toughness);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,17 +114,6 @@ public class ModalDoubleFacedCardHalfImpl extends CardImpl implements ModalDoubl
|
|||
return this.parentCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPT(int power, int toughness) {
|
||||
this.setPT(new MageInt(power), new MageInt(toughness));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPT(MageInt power, MageInt toughness) {
|
||||
this.power = power;
|
||||
this.toughness = toughness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdName() {
|
||||
// id must send to main card (popup card hint in game logs)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,90 @@
|
|||
package mage.cards;
|
||||
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.SuperType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public abstract class TransformingDoubleFacedCard extends CardImpl {
|
||||
|
||||
protected TransformingDoubleFacedCardHalfImpl leftHalfCard; // main card in all zone
|
||||
protected TransformingDoubleFacedCardHalfImpl rightHalfCard; // second side card, can be only in stack and battlefield zones
|
||||
|
||||
public TransformingDoubleFacedCard(
|
||||
UUID ownerId, CardSetInfo setInfo,
|
||||
CardType[] typesLeft, SubType[] subTypesLeft, String costsLeft,
|
||||
String secondSideName,
|
||||
CardType[] typesRight, SubType[] subTypesRight, String colorRight
|
||||
) {
|
||||
this(
|
||||
ownerId, setInfo,
|
||||
new SuperType[]{}, typesLeft, subTypesLeft, costsLeft,
|
||||
secondSideName,
|
||||
new SuperType[]{}, typesRight, subTypesRight, colorRight
|
||||
);
|
||||
}
|
||||
|
||||
public TransformingDoubleFacedCard(
|
||||
UUID ownerId, CardSetInfo setInfo,
|
||||
SuperType[] superTypesLeft, CardType[] typesLeft, SubType[] subTypesLeft, String costsLeft,
|
||||
String secondSideName,
|
||||
SuperType[] superTypesRight, CardType[] typesRight, SubType[] subTypesRight, String colorRight
|
||||
) {
|
||||
super(ownerId, setInfo, typesLeft, costsLeft);
|
||||
this.leftHalfCard = new TransformingDoubleFacedCardHalfImpl(ownerId, setInfo, costsLeft);
|
||||
this.rightHalfCard = new TransformingDoubleFacedCardHalfImpl(ownerId, setInfo, "");
|
||||
for (SuperType superType : superTypesLeft) {
|
||||
this.getLeftHalfCard().getSuperType().add(superType);
|
||||
}
|
||||
this.getLeftHalfCard().getSubtype().add(subTypesLeft);
|
||||
for (SuperType superType : superTypesRight) {
|
||||
this.getRightHalfCard().getSuperType().add(superType);
|
||||
}
|
||||
this.getRightHalfCard().addCardType(typesRight);
|
||||
this.getRightHalfCard().setName(secondSideName);
|
||||
this.getRightHalfCard().addSubType(subTypesRight);
|
||||
this.getRightHalfCard().getColor().addColor(new ObjectColor(colorRight));
|
||||
}
|
||||
|
||||
protected TransformingDoubleFacedCard(final TransformingDoubleFacedCard card) {
|
||||
super(card);
|
||||
this.leftHalfCard = card.leftHalfCard.copy();
|
||||
this.rightHalfCard = card.rightHalfCard.copy();
|
||||
}
|
||||
|
||||
public Card getLeftHalfCard() {
|
||||
return leftHalfCard;
|
||||
}
|
||||
|
||||
public Card getRightHalfCard() {
|
||||
return rightHalfCard;
|
||||
}
|
||||
|
||||
protected void finalizeDFC() {
|
||||
this.getSuperType().addAll(this.getLeftHalfCard().getSuperType());
|
||||
this.getCardType().addAll(this.getLeftHalfCard().getCardType());
|
||||
this.getSubtype().addAll(this.getLeftHalfCard().getSubtype());
|
||||
for (Ability ability : this.getLeftHalfCard().getAbilities()) {
|
||||
this.addAbility(ability);
|
||||
}
|
||||
this.power = this.getLeftHalfCard().getPower().copy();
|
||||
this.toughness = this.getLeftHalfCard().getToughness().copy();
|
||||
}
|
||||
|
||||
public static void copyToBackFace(TransformingDoubleFacedCard tdfc, Card card) {
|
||||
card.getColor().setColor(tdfc.getRightHalfCard().getColor());
|
||||
card.getSuperType().addAll(tdfc.getRightHalfCard().getSuperType());
|
||||
card.getCardType().addAll(tdfc.getRightHalfCard().getCardType());
|
||||
card.getSubtype().addAll(tdfc.getRightHalfCard().getSubtype());
|
||||
for (Ability ability : tdfc.getRightHalfCard().getAbilities()) {
|
||||
card.addAbility(ability);
|
||||
}
|
||||
card.setPT(tdfc.getRightHalfCard().getPower().copy(), tdfc.getRightHalfCard().getToughness().copy());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package mage.cards;
|
||||
|
||||
import mage.constants.CardType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class TransformingDoubleFacedCardHalfImpl extends CardImpl {
|
||||
|
||||
TransformingDoubleFacedCardHalfImpl(UUID ownerId, CardSetInfo setInfo, String costs) {
|
||||
super(ownerId, setInfo, new CardType[]{}, costs);
|
||||
}
|
||||
|
||||
private TransformingDoubleFacedCardHalfImpl(final TransformingDoubleFacedCardHalfImpl card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransformingDoubleFacedCardHalfImpl copy() {
|
||||
return new TransformingDoubleFacedCardHalfImpl(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -777,6 +777,16 @@ public class Spell extends StackObjectImpl implements Card {
|
|||
public void setOwnerId(UUID controllerId) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPT(int power, int toughness) {
|
||||
throw new UnsupportedOperationException("Unsupported operation");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPT(MageInt power, MageInt toughness) {
|
||||
throw new UnsupportedOperationException("Unsupported operation");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRules() {
|
||||
return card.getRules();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue