mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
Change supertype method in constructors (#10361)
* replace addSuperType with supertype.add in card constructors * more supertype replacements * update MDFC supertype implementation * remove unnecessary class * update test
This commit is contained in:
parent
4cc9329b15
commit
a850e3660b
2452 changed files with 2651 additions and 2731 deletions
|
|
@ -13,6 +13,10 @@ public final class CardSetInfo implements Serializable, Copyable<CardSetInfo> {
|
|||
private final Rarity rarity;
|
||||
private final CardGraphicInfo graphicInfo;
|
||||
|
||||
public CardSetInfo(String name, CardSetInfo cardSetInfo) {
|
||||
this(name, cardSetInfo.expansionSetCode, cardSetInfo.cardNumber, cardSetInfo.rarity, cardSetInfo.graphicInfo);
|
||||
}
|
||||
|
||||
public CardSetInfo(String name, String expansionSetCode, String cardNumber, Rarity rarity) {
|
||||
this(name, expansionSetCode, cardNumber, rarity, null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,15 +27,38 @@ public abstract class ModalDoubleFacesCard extends CardImpl implements CardWithH
|
|||
protected Card leftHalfCard; // main card in all zone
|
||||
protected Card rightHalfCard; // second side card, can be only in stack and battlefield zones
|
||||
|
||||
public ModalDoubleFacesCard(UUID ownerId, CardSetInfo setInfo,
|
||||
CardType[] typesLeft, SubType[] subTypesLeft, String costsLeft,
|
||||
String secondSideName, CardType[] typesRight, SubType[] subTypesRight, String costsRight) {
|
||||
public ModalDoubleFacesCard(
|
||||
UUID ownerId, CardSetInfo setInfo,
|
||||
CardType[] typesLeft, SubType[] subTypesLeft, String costsLeft,
|
||||
String secondSideName,
|
||||
CardType[] typesRight, SubType[] subTypesRight, String costsRight
|
||||
) {
|
||||
this(
|
||||
ownerId, setInfo,
|
||||
new SuperType[]{}, typesLeft, subTypesLeft, costsLeft,
|
||||
secondSideName,
|
||||
new SuperType[]{}, typesRight, subTypesRight, costsRight
|
||||
);
|
||||
}
|
||||
|
||||
public ModalDoubleFacesCard(
|
||||
UUID ownerId, CardSetInfo setInfo,
|
||||
SuperType[] superTypesLeft, CardType[] typesLeft, SubType[] subTypesLeft, String costsLeft,
|
||||
String secondSideName,
|
||||
SuperType[] superTypesRight, CardType[] typesRight, SubType[] subTypesRight, String costsRight
|
||||
) {
|
||||
super(ownerId, setInfo, typesLeft, costsLeft + costsRight, SpellAbilityType.MODAL);
|
||||
// main card name must be same as left side
|
||||
leftHalfCard = new ModalDoubleFacesCardHalfImpl(this.getOwnerId(), new CardSetInfo(setInfo.getName(), setInfo.getExpansionSetCode(), setInfo.getCardNumber(), setInfo.getRarity(), setInfo.getGraphicInfo()),
|
||||
typesLeft, subTypesLeft, costsLeft, this, SpellAbilityType.MODAL_LEFT);
|
||||
rightHalfCard = new ModalDoubleFacesCardHalfImpl(this.getOwnerId(), new CardSetInfo(secondSideName, setInfo.getExpansionSetCode(), setInfo.getCardNumber(), setInfo.getRarity(), setInfo.getGraphicInfo()),
|
||||
typesRight, subTypesRight, costsRight, this, SpellAbilityType.MODAL_RIGHT);
|
||||
leftHalfCard = new ModalDoubleFacesCardHalfImpl(
|
||||
this.getOwnerId(), setInfo.copy(),
|
||||
superTypesLeft, typesLeft, subTypesLeft, costsLeft,
|
||||
this, SpellAbilityType.MODAL_LEFT
|
||||
);
|
||||
rightHalfCard = new ModalDoubleFacesCardHalfImpl(
|
||||
this.getOwnerId(), new CardSetInfo(secondSideName, setInfo),
|
||||
superTypesRight, typesRight, subTypesRight, costsRight,
|
||||
this, SpellAbilityType.MODAL_RIGHT
|
||||
);
|
||||
}
|
||||
|
||||
public ModalDoubleFacesCard(ModalDoubleFacesCard card) {
|
||||
|
|
|
|||
|
|
@ -2,10 +2,7 @@ package mage.cards;
|
|||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SpellAbilityType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
|
@ -19,9 +16,13 @@ public class ModalDoubleFacesCardHalfImpl extends CardImpl implements ModalDoubl
|
|||
|
||||
ModalDoubleFacesCard parentCard;
|
||||
|
||||
public ModalDoubleFacesCardHalfImpl(UUID ownerId, CardSetInfo setInfo, CardType[] cardTypes, SubType[] cardSubTypes,
|
||||
String costs, ModalDoubleFacesCard parentCard, SpellAbilityType spellAbilityType) {
|
||||
public ModalDoubleFacesCardHalfImpl(
|
||||
UUID ownerId, CardSetInfo setInfo,
|
||||
SuperType[] cardSuperTypes, CardType[] cardTypes, SubType[] cardSubTypes,
|
||||
String costs, ModalDoubleFacesCard parentCard, SpellAbilityType spellAbilityType
|
||||
) {
|
||||
super(ownerId, setInfo, cardTypes, costs, spellAbilityType);
|
||||
this.supertype.addAll(Arrays.asList(cardSuperTypes));
|
||||
this.subtype.addAll(Arrays.asList(cardSubTypes));
|
||||
this.parentCard = parentCard;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public abstract class BasicLand extends CardImpl {
|
|||
|
||||
public BasicLand(UUID ownerId, CardSetInfo setInfo, ActivatedManaAbilityImpl mana) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.LAND}, null);
|
||||
addSuperType(SuperType.BASIC);
|
||||
this.supertype.add(SuperType.BASIC);
|
||||
this.subtype.add(SubType.byDescription(name));
|
||||
this.addAbility(mana);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ class DefaultCommander extends CardImpl {
|
|||
|
||||
public DefaultCommander(UUID ownerId, String commanderName, String manaString) {
|
||||
super(ownerId, new CardSetInfo(commanderName, "", "999", Rarity.RARE), new CardType[]{CardType.CREATURE}, manaString);
|
||||
this.addSuperType(SuperType.LEGENDARY);
|
||||
this.supertype.add(SuperType.LEGENDARY);
|
||||
|
||||
if (manaString.contains("{G}")) {
|
||||
this.color.setGreen(true);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public final class CherubaelToken extends TokenImpl {
|
|||
public CherubaelToken() {
|
||||
super("Cherubael", "Cherubael, a legendary 4/4 black Demon creature token with flying");
|
||||
cardType.add(CardType.CREATURE);
|
||||
addSuperType(SuperType.LEGENDARY);
|
||||
this.supertype.add(SuperType.LEGENDARY);
|
||||
subtype.add(SubType.DEMON);
|
||||
color.setBlack(true);
|
||||
power = new MageInt(4);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public final class IcyManalithToken extends TokenImpl {
|
|||
|
||||
public IcyManalithToken() {
|
||||
super("Icy Manalith", "colorless snow artifact token named Icy Manalith with \"{T}: Add one mana of any color.\"");
|
||||
this.addSuperType(SuperType.SNOW);
|
||||
this.supertype.add(SuperType.SNOW);
|
||||
this.cardType.add(CardType.ARTIFACT);
|
||||
|
||||
this.addAbility(new AnyColorManaAbility());
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public final class KaldraToken extends TokenImpl {
|
|||
|
||||
public KaldraToken() {
|
||||
super("Kaldra", "Kaldra, a legendary 4/4 colorless Avatar creature token");
|
||||
addSuperType(SuperType.LEGENDARY);
|
||||
this.supertype.add(SuperType.LEGENDARY);
|
||||
cardType.add(CardType.CREATURE);
|
||||
subtype.add(SubType.AVATAR);
|
||||
power = new MageInt(4);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public final class KaroxBladewingDragonToken extends TokenImpl {
|
|||
super("Karox Bladewing Token", "legendary 4/4 red Dragon creature token with flying");
|
||||
this.power = new MageInt(4);
|
||||
this.toughness = new MageInt(4);
|
||||
this.addSuperType(SuperType.LEGENDARY);
|
||||
this.supertype.add(SuperType.LEGENDARY);
|
||||
this.cardType.add(CardType.CREATURE);
|
||||
this.subtype.add(SubType.DRAGON);
|
||||
this.color.setRed(true);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public final class MaritLageToken extends TokenImpl {
|
|||
super("Marit Lage", "Marit Lage, a legendary 20/20 black Avatar creature token with flying and indestructible");
|
||||
cardType.add(CardType.CREATURE);
|
||||
subtype.add(SubType.AVATAR);
|
||||
addSuperType(SuperType.LEGENDARY);
|
||||
this.supertype.add(SuperType.LEGENDARY);
|
||||
|
||||
color.setBlack(true);
|
||||
power = new MageInt(20);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public final class MechtitanToken extends TokenImpl {
|
|||
|
||||
public MechtitanToken() {
|
||||
super("Mechtitan", "Mechtitan, a legendary 10/10 Construct artifact creature token with flying, vigilance, trample, lifelink, and haste that's all colors");
|
||||
addSuperType(SuperType.LEGENDARY);
|
||||
this.supertype.add(SuperType.LEGENDARY);
|
||||
cardType.add(CardType.ARTIFACT);
|
||||
cardType.add(CardType.CREATURE);
|
||||
subtype.add(SubType.CONSTRUCT);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public final class MowuToken extends TokenImpl {
|
|||
super("Mowu", "Mowu, a legendary 3/3 green Dog creature token");
|
||||
cardType.add(CardType.CREATURE);
|
||||
color.setGreen(true);
|
||||
this.addSuperType(SuperType.LEGENDARY);
|
||||
this.supertype.add(SuperType.LEGENDARY);
|
||||
subtype.add(SubType.DOG);
|
||||
power = new MageInt(3);
|
||||
toughness = new MageInt(3);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public final class NighteyesTheDesecratorToken extends TokenImpl {
|
|||
|
||||
public NighteyesTheDesecratorToken() {
|
||||
super("Nighteyes the Desecrator Token", "");
|
||||
addSuperType(SuperType.LEGENDARY);
|
||||
this.supertype.add(SuperType.LEGENDARY);
|
||||
cardType.add(CardType.CREATURE);
|
||||
color.setBlack(true);
|
||||
subtype.add(SubType.RAT);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public final class ReplicatedRingToken extends TokenImpl {
|
|||
|
||||
public ReplicatedRingToken() {
|
||||
super("Replicated Ring", "colorless snow artifact token named Replicated Ring with \"{T}: Add one mana of any color.\"");
|
||||
this.addSuperType(SuperType.SNOW);
|
||||
this.supertype.add(SuperType.SNOW);
|
||||
cardType.add(CardType.ARTIFACT);
|
||||
|
||||
this.addAbility(new AnyColorManaAbility());
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public final class StanggTwinToken extends TokenImpl {
|
|||
public StanggTwinToken() {
|
||||
super("Stangg Twin", "Stangg Twin, a legendary 3/4 red and green Human Warrior creature token");
|
||||
this.cardType.add(CardType.CREATURE);
|
||||
addSuperType(SuperType.LEGENDARY);
|
||||
this.supertype.add(SuperType.LEGENDARY);
|
||||
this.subtype.add(SubType.HUMAN);
|
||||
this.subtype.add(SubType.WARRIOR);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public final class TamiyosNotebookToken extends TokenImpl {
|
|||
|
||||
public TamiyosNotebookToken() {
|
||||
super("Tamiyo's Notebook", "Tamiyo's Notebook, a legendary colorless artifact token with \"Spells you cast cost {2} less to cast\" and \"{T}: Draw a card.\"");
|
||||
addSuperType(SuperType.LEGENDARY);
|
||||
this.supertype.add(SuperType.LEGENDARY);
|
||||
this.cardType.add(CardType.ARTIFACT);
|
||||
this.addAbility(new SimpleStaticAbility(new SpellsCostReductionControllerEffect(filter, 2)));
|
||||
this.addAbility(new SimpleActivatedAbility(new DrawCardSourceControllerEffect(1), new TapSourceCost()));
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public final class TuktukTheReturnedToken extends TokenImpl {
|
|||
super("Tuktuk the Returned", "Tuktuk the Returned, a legendary 5/5 colorless Goblin Golem artifact creature token");
|
||||
cardType.add(CardType.ARTIFACT);
|
||||
cardType.add(CardType.CREATURE);
|
||||
addSuperType(SuperType.LEGENDARY);
|
||||
this.supertype.add(SuperType.LEGENDARY);
|
||||
subtype.add(SubType.GOBLIN);
|
||||
subtype.add(SubType.GOLEM);
|
||||
power = new MageInt(5);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public final class UramiToken extends TokenImpl {
|
|||
cardType.add(CardType.CREATURE);
|
||||
subtype.add(SubType.DEMON);
|
||||
subtype.add(SubType.SPIRIT);
|
||||
addSuperType(SuperType.LEGENDARY);
|
||||
this.supertype.add(SuperType.LEGENDARY);
|
||||
|
||||
color.setBlack(true);
|
||||
power = new MageInt(5);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public final class VojaFriendToElvesToken extends TokenImpl {
|
|||
public VojaFriendToElvesToken() {
|
||||
super("Voja, Friend to Elves", "Voja, Friend to Elves, a legendary 3/3 green and white Wolf creature token");
|
||||
this.cardType.add(CardType.CREATURE);
|
||||
addSuperType(SuperType.LEGENDARY);
|
||||
this.supertype.add(SuperType.LEGENDARY);
|
||||
this.subtype.add(SubType.WOLF);
|
||||
|
||||
this.color.setGreen(true);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public final class VojaToken extends TokenImpl {
|
|||
public VojaToken() {
|
||||
super("Voja", "Voja, a legendary 2/2 green and white Wolf creature token");
|
||||
this.cardType.add(CardType.CREATURE);
|
||||
addSuperType(SuperType.LEGENDARY);
|
||||
this.supertype.add(SuperType.LEGENDARY);
|
||||
this.subtype.add(SubType.WOLF);
|
||||
|
||||
this.color.setGreen(true);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public final class VolosJournalToken extends TokenImpl {
|
|||
|
||||
public VolosJournalToken() {
|
||||
super("Volo's Journal", "Volo's Journal, a legendary colorless artifact token with hexproof and \"Whenever you cast a creature spell, note one of its creature types that hasn't been noted for this artifact.\"");
|
||||
addSuperType(SuperType.LEGENDARY);
|
||||
this.supertype.add(SuperType.LEGENDARY);
|
||||
this.cardType.add(CardType.ARTIFACT);
|
||||
this.addAbility(HexproofAbility.getInstance());
|
||||
this.addAbility(new SpellCastControllerTriggeredAbility(
|
||||
|
|
|
|||
|
|
@ -1,106 +0,0 @@
|
|||
|
||||
package mage.target.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.FilterStackObject;
|
||||
import mage.game.Game;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.target.TargetObject;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TargetActivatedOrTriggeredAbilityOrLegendarySpell extends TargetObject {
|
||||
|
||||
protected final FilterStackObject filter;
|
||||
|
||||
public TargetActivatedOrTriggeredAbilityOrLegendarySpell() {
|
||||
this(new FilterStackObject("activated ability, triggered ability, or legendary spell"));
|
||||
}
|
||||
|
||||
public TargetActivatedOrTriggeredAbilityOrLegendarySpell(FilterStackObject filter) {
|
||||
this.minNumberOfTargets = 1;
|
||||
this.maxNumberOfTargets = 1;
|
||||
this.zone = Zone.STACK;
|
||||
this.targetName = filter.getMessage();
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
public TargetActivatedOrTriggeredAbilityOrLegendarySpell(final TargetActivatedOrTriggeredAbilityOrLegendarySpell target) {
|
||||
super(target);
|
||||
this.filter = target.filter.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
// rule 114.4. A spell or ability on the stack is an illegal target for itself.
|
||||
if (source != null && source.getId().equals(id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
StackObject stackObject = game.getStack().getStackObject(id);
|
||||
return isActivatedOrTriggeredAbilityOrLegendarySpell(stackObject) && source != null && filter.match(stackObject, source.getControllerId(), source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canChoose(UUID sourceControllerId, Ability source, Game game) {
|
||||
for (StackObject stackObject : game.getStack()) {
|
||||
if (isActivatedOrTriggeredAbilityOrLegendarySpell(stackObject)
|
||||
&& filter.match(stackObject, sourceControllerId, source, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||
return game.getStack()
|
||||
.stream()
|
||||
.anyMatch(TargetActivatedOrTriggeredAbilityOrLegendarySpell::isActivatedOrTriggeredAbilityOrLegendarySpell);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceControllerId, Ability source, Game game) {
|
||||
return possibleTargets(sourceControllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||
return game.getStack().stream()
|
||||
.filter(TargetActivatedOrTriggeredAbilityOrLegendarySpell::isActivatedOrTriggeredAbilityOrLegendarySpell)
|
||||
.map(stackObject -> stackObject.getStackAbility().getId())
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetActivatedOrTriggeredAbilityOrLegendarySpell copy() {
|
||||
return new TargetActivatedOrTriggeredAbilityOrLegendarySpell(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
static boolean isActivatedOrTriggeredAbilityOrLegendarySpell(StackObject stackObject) {
|
||||
if (stackObject == null) {
|
||||
return false;
|
||||
}
|
||||
if (stackObject instanceof Ability) {
|
||||
Ability ability = (Ability) stackObject;
|
||||
return ability.getAbilityType() == AbilityType.TRIGGERED
|
||||
|| ability.getAbilityType() == AbilityType.ACTIVATED;
|
||||
}
|
||||
if (stackObject instanceof Spell) {
|
||||
Spell spell = (Spell) stackObject;
|
||||
return spell.isLegendary();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue