mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
refactor cards to use supertype enum
This commit is contained in:
parent
84559457d3
commit
0879298e92
6374 changed files with 17783 additions and 14013 deletions
|
|
@ -1,19 +1,20 @@
|
|||
package mage;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Abilities;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.cards.FrameStyle;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface MageObject extends MageItem, Serializable {
|
||||
|
||||
String getName();
|
||||
|
|
@ -32,16 +33,16 @@ public interface MageObject extends MageItem, Serializable {
|
|||
|
||||
boolean hasSubtype(String subtype, Game game);
|
||||
|
||||
List<String> getSupertype();
|
||||
EnumSet<SuperType> getSuperType();
|
||||
|
||||
Abilities<Ability> getAbilities();
|
||||
|
||||
boolean hasAbility(UUID abilityId, Game game);
|
||||
|
||||
ObjectColor getColor(Game game);
|
||||
|
||||
|
||||
ObjectColor getFrameColor(Game game);
|
||||
|
||||
|
||||
FrameStyle getFrameStyle();
|
||||
|
||||
ManaCosts<ManaCost> getManaCost();
|
||||
|
|
@ -51,10 +52,9 @@ public interface MageObject extends MageItem, Serializable {
|
|||
MageInt getPower();
|
||||
|
||||
MageInt getToughness();
|
||||
|
||||
|
||||
int getStartingLoyalty();
|
||||
|
||||
|
||||
|
||||
|
||||
void adjustCosts(Ability ability, Game game);
|
||||
|
||||
|
|
@ -83,33 +83,53 @@ public interface MageObject extends MageItem, Serializable {
|
|||
void setZoneChangeCounter(int value, Game game);
|
||||
|
||||
|
||||
|
||||
default boolean isCreature(){
|
||||
default boolean isCreature() {
|
||||
return getCardType().contains(CardType.CREATURE);
|
||||
}
|
||||
|
||||
default boolean isArtifact(){
|
||||
default boolean isArtifact() {
|
||||
return getCardType().contains(CardType.ARTIFACT);
|
||||
}
|
||||
|
||||
default boolean isLand(){
|
||||
default boolean isLand() {
|
||||
return getCardType().contains(CardType.LAND);
|
||||
}
|
||||
|
||||
default boolean isEnchantment(){
|
||||
default boolean isEnchantment() {
|
||||
return getCardType().contains(CardType.ENCHANTMENT);
|
||||
}
|
||||
|
||||
default boolean isInstant(){
|
||||
default boolean isInstant() {
|
||||
return getCardType().contains(CardType.INSTANT);
|
||||
}
|
||||
|
||||
default boolean isSorcery(){
|
||||
default boolean isSorcery() {
|
||||
return getCardType().contains(CardType.SORCERY);
|
||||
}
|
||||
|
||||
default boolean isPlaneswalker(){
|
||||
default boolean isPlaneswalker() {
|
||||
return getCardType().contains(CardType.PLANESWALKER);
|
||||
}
|
||||
|
||||
default boolean isPermanent() {
|
||||
return isCreature() || isArtifact() || isPlaneswalker() || isEnchantment() || isLand();
|
||||
}
|
||||
|
||||
default boolean isLegendary() {
|
||||
return getSuperType().contains(SuperType.LEGENDARY);
|
||||
}
|
||||
|
||||
default boolean isSnow() {
|
||||
return getSuperType().contains(SuperType.SNOW);
|
||||
}
|
||||
|
||||
default void addSuperType(SuperType superType){
|
||||
getSuperType().add(superType);
|
||||
}
|
||||
|
||||
default boolean isBasic() { return getSuperType().contains(SuperType.BASIC);}
|
||||
|
||||
default boolean isWorld() {
|
||||
return getSuperType().contains(SuperType.WORLD);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import mage.abilities.keyword.ChangelingAbility;
|
|||
import mage.abilities.mana.ActivatedManaAbilityImpl;
|
||||
import mage.cards.FrameStyle;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.util.CardUtil;
|
||||
|
|
@ -56,7 +57,7 @@ public abstract class MageObjectImpl implements MageObject {
|
|||
protected FrameStyle frameStyle;
|
||||
protected EnumSet<CardType> cardType = EnumSet.noneOf(CardType.class);
|
||||
protected List<String> subtype = new ArrayList<>();
|
||||
protected List<String> supertype = new ArrayList<>();
|
||||
protected EnumSet<SuperType> supertype = EnumSet.noneOf(SuperType.class);
|
||||
protected Abilities<Ability> abilities;
|
||||
protected String text;
|
||||
protected MageInt power;
|
||||
|
|
@ -91,7 +92,7 @@ public abstract class MageObjectImpl implements MageObject {
|
|||
abilities = object.abilities.copy();
|
||||
this.cardType.addAll(object.cardType);
|
||||
this.subtype.addAll(object.subtype);
|
||||
this.supertype.addAll(object.supertype);
|
||||
supertype.addAll(object.supertype);
|
||||
this.copy = object.copy;
|
||||
}
|
||||
|
||||
|
|
@ -136,7 +137,7 @@ public abstract class MageObjectImpl implements MageObject {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupertype() {
|
||||
public EnumSet<SuperType> getSuperType() {
|
||||
return supertype;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,10 +29,13 @@ package mage.abilities.condition.common;
|
|||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.constants.SuperType;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
|
|
@ -40,15 +43,15 @@ import mage.game.permanent.Permanent;
|
|||
|
||||
public class EquippedHasSupertypeCondition implements Condition {
|
||||
|
||||
private String superType;
|
||||
private String[] superTypes; // scope = Any
|
||||
private SuperType superType;
|
||||
private EnumSet<SuperType> superTypes = EnumSet.noneOf(SuperType.class); // scope = Any
|
||||
|
||||
public EquippedHasSupertypeCondition(String subType) {
|
||||
this.superType = subType;
|
||||
public EquippedHasSupertypeCondition(SuperType supertype) {
|
||||
this.superType = supertype;
|
||||
}
|
||||
|
||||
public EquippedHasSupertypeCondition(String... subTypes) {
|
||||
this.superTypes = subTypes;
|
||||
public EquippedHasSupertypeCondition(EnumSet<SuperType> superTypes) {
|
||||
this.superTypes = superTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -61,12 +64,12 @@ public class EquippedHasSupertypeCondition implements Condition {
|
|||
}
|
||||
if (attachedTo != null) {
|
||||
if (superType != null) {
|
||||
if (attachedTo.getSupertype().contains(this.superType)) {
|
||||
if (attachedTo.getSuperType().contains(this.superType)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
for (String s : superTypes) {
|
||||
if (attachedTo.getSupertype().contains(s)) {
|
||||
for (SuperType s : superTypes) {
|
||||
if (attachedTo.getSuperType().contains(s)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import mage.Mana;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.constants.ColoredManaSymbol;
|
||||
import mage.constants.SuperType;
|
||||
import mage.filter.FilterObject;
|
||||
import mage.filter.predicate.mageobject.SupertypePredicate;
|
||||
import mage.game.Game;
|
||||
|
|
@ -41,7 +42,7 @@ public class SnowManaCost extends ManaCostImpl {
|
|||
private static final FilterObject filter = new FilterObject("Snow object");
|
||||
|
||||
static {
|
||||
filter.add(new SupertypePredicate("Snow"));
|
||||
filter.add(new SupertypePredicate(SuperType.SNOW));
|
||||
}
|
||||
|
||||
public SnowManaCost() {
|
||||
|
|
|
|||
|
|
@ -33,13 +33,7 @@ import mage.MageObjectReference;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.Zone;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
|
|
@ -134,9 +128,9 @@ public class CopyEffect extends ContinuousEffectImpl {
|
|||
for (String type : copyFromObject.getSubtype(game)) {
|
||||
permanent.getSubtype(game).add(type);
|
||||
}
|
||||
permanent.getSupertype().clear();
|
||||
for (String type : copyFromObject.getSupertype()) {
|
||||
permanent.getSupertype().add(type);
|
||||
permanent.getSuperType().clear();
|
||||
for (SuperType type : copyFromObject.getSuperType()) {
|
||||
permanent.getSuperType().add(type);
|
||||
}
|
||||
|
||||
permanent.removeAllAbilities(source.getSourceId(), game);
|
||||
|
|
|
|||
|
|
@ -2,11 +2,7 @@ package mage.abilities.effects.common;
|
|||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.token.Token;
|
||||
|
|
@ -38,9 +34,9 @@ public class CopyTokenEffect extends ContinuousEffectImpl {
|
|||
for (String type: token.getSubtype(game)) {
|
||||
permanent.getSubtype(game).add(type);
|
||||
}
|
||||
permanent.getSupertype().clear();
|
||||
for (String type: token.getSupertype()) {
|
||||
permanent.getSupertype().add(type);
|
||||
permanent.getSuperType().clear();
|
||||
for (SuperType type: token.getSuperType()) {
|
||||
permanent.getSuperType().add(type);
|
||||
}
|
||||
permanent.getAbilities().clear();
|
||||
for (Ability ability: token.getAbilities()) {
|
||||
|
|
|
|||
|
|
@ -30,11 +30,7 @@ package mage.abilities.effects.common.continuous;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.token.Token;
|
||||
|
|
@ -85,10 +81,9 @@ public class BecomesCreatureAttachedEffect extends ContinuousEffectImpl {
|
|||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
for (String t : token.getSupertype()) {
|
||||
if (!permanent.getSupertype().contains(t)) {
|
||||
permanent.getSupertype().add(t);
|
||||
}
|
||||
for (SuperType t : token.getSuperType()) {
|
||||
permanent.addSuperType(t);
|
||||
|
||||
}
|
||||
// card type
|
||||
switch (loseType) {
|
||||
|
|
@ -167,9 +162,9 @@ public class BecomesCreatureAttachedEffect extends ContinuousEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean hasLayer(Layer layer) {
|
||||
return layer == Layer.PTChangingEffects_7
|
||||
|| layer == Layer.AbilityAddingRemovingEffects_6
|
||||
|| layer == Layer.ColorChangingEffects_5
|
||||
return layer == Layer.PTChangingEffects_7
|
||||
|| layer == Layer.AbilityAddingRemovingEffects_6
|
||||
|| layer == Layer.ColorChangingEffects_5
|
||||
|| layer == Layer.TypeChangingEffects_4;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ public class BecomesFaceDownCreatureAllEffect extends ContinuousEffectImpl imple
|
|||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
permanent.setName("");
|
||||
permanent.getSupertype().clear();
|
||||
permanent.getSuperType().clear();
|
||||
permanent.getCardType().clear();
|
||||
permanent.getCardType().add(CardType.CREATURE);
|
||||
permanent.getSubtype(game).clear();
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ public class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl implemen
|
|||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
permanent.setName("");
|
||||
permanent.getSupertype().clear();
|
||||
permanent.getSuperType().clear();
|
||||
permanent.getCardType().clear();
|
||||
permanent.getCardType().add(CardType.CREATURE);
|
||||
permanent.getSubtype(game).clear();
|
||||
|
|
|
|||
|
|
@ -301,7 +301,7 @@ public class MorphAbility extends StaticAbility implements AlternativeSourceCost
|
|||
mageObject.getCardType().clear();
|
||||
mageObject.getCardType().add(CardType.CREATURE);
|
||||
mageObject.getSubtype(null).clear();
|
||||
mageObject.getSupertype().clear();
|
||||
mageObject.getSuperType().clear();
|
||||
mageObject.getManaCost().clear();
|
||||
if (mageObject instanceof Permanent) {
|
||||
((Permanent) mageObject).setExpansionSetCode("");
|
||||
|
|
|
|||
|
|
@ -83,9 +83,9 @@ public class TransformAbility extends SimpleStaticAbility {
|
|||
for (String type : sourceCard.getSubtype(game)) {
|
||||
permanent.getSubtype(game).add(type);
|
||||
}
|
||||
permanent.getSupertype().clear();
|
||||
for (String type : sourceCard.getSupertype()) {
|
||||
permanent.getSupertype().add(type);
|
||||
permanent.getSuperType().clear();
|
||||
for (SuperType type : sourceCard.getSuperType()) {
|
||||
permanent.getSuperType().add(type);
|
||||
}
|
||||
permanent.setExpansionSetCode(sourceCard.getExpansionSetCode());
|
||||
permanent.getAbilities().clear();
|
||||
|
|
|
|||
|
|
@ -34,16 +34,16 @@ import mage.cards.CardSetInfo;
|
|||
import mage.constants.CardType;
|
||||
import mage.abilities.mana.ActivatedManaAbilityImpl;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.SuperType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public abstract class BasicLand extends CardImpl {
|
||||
|
||||
public BasicLand(UUID ownerId, CardSetInfo setInfo, ActivatedManaAbilityImpl mana) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.LAND}, null);
|
||||
this.supertype.add("Basic");
|
||||
addSuperType(SuperType.BASIC);
|
||||
this.subtype.add(name);
|
||||
this.addAbility(mana);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,10 +47,10 @@ import mage.cards.mock.MockSplitCard;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.SpellAbilityType;
|
||||
import mage.constants.SuperType;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author North
|
||||
*/
|
||||
@DatabaseTable(tableName = "card")
|
||||
|
|
@ -153,7 +153,7 @@ public class CardInfo {
|
|||
|
||||
this.setTypes(card.getCardType());
|
||||
this.setSubtypes(card.getSubtype(null));
|
||||
this.setSuperTypes(card.getSupertype());
|
||||
this.setSuperTypes(card.getSuperType());
|
||||
this.setManaCosts(card.getManaCost().getSymbols());
|
||||
|
||||
int length = 0;
|
||||
|
|
@ -249,6 +249,7 @@ public class CardInfo {
|
|||
if (list.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return Arrays.asList(list.split(SEPARATOR));
|
||||
}
|
||||
|
||||
|
|
@ -311,12 +312,23 @@ public class CardInfo {
|
|||
this.subtypes = joinList(subtypes);
|
||||
}
|
||||
|
||||
public final List<String> getSupertypes() {
|
||||
return parseList(supertypes);
|
||||
public final EnumSet<SuperType> getSupertypes() {
|
||||
EnumSet<SuperType> list = EnumSet.noneOf(SuperType.class);
|
||||
for (String type : this.types.split(SEPARATOR)) {
|
||||
try {
|
||||
list.add(SuperType.valueOf(type));
|
||||
} catch (IllegalArgumentException e) {
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public final void setSuperTypes(List<String> superTypes) {
|
||||
this.supertypes = joinList(superTypes);
|
||||
public final void setSuperTypes(Set<SuperType> superTypes) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (SuperType item : superTypes) {
|
||||
sb.append(item.name()).append(SEPARATOR);
|
||||
}
|
||||
this.supertypes = sb.toString();
|
||||
}
|
||||
|
||||
public String getToughness() {
|
||||
|
|
|
|||
|
|
@ -4,4 +4,12 @@ package mage.constants;
|
|||
* Created by IGOUDT on 26-3-2017.
|
||||
*/
|
||||
public enum SuperType {
|
||||
|
||||
BASIC,
|
||||
ELITE,
|
||||
LEGENDARY,
|
||||
ONGOING,
|
||||
SNOW,
|
||||
WORLD
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import mage.abilities.costs.mana.ManaCosts;
|
|||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.cards.FrameStyle;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.util.GameLog;
|
||||
|
|
@ -31,7 +32,7 @@ public abstract class Designation implements MageObject {
|
|||
private static EnumSet emptySet = EnumSet.noneOf(CardType.class);
|
||||
private static List emptyList = new ArrayList();
|
||||
private static ObjectColor emptyColor = new ObjectColor();
|
||||
private static ManaCosts<ManaCost> emptyCost = new ManaCostsImpl();
|
||||
private static ManaCostsImpl emptyCost = new ManaCostsImpl();
|
||||
|
||||
private String name;
|
||||
private UUID id;
|
||||
|
|
@ -133,8 +134,8 @@ public abstract class Designation implements MageObject {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupertype() {
|
||||
return emptyList;
|
||||
public EnumSet<SuperType> getSuperType() {
|
||||
return EnumSet.noneOf(SuperType.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
package mage.filter.common;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.filter.predicate.mageobject.SupertypePredicate;
|
||||
|
|
@ -45,7 +46,7 @@ public class FilterBasicLandCard extends FilterCard {
|
|||
public FilterBasicLandCard(String name) {
|
||||
super(name);
|
||||
this.add(new CardTypePredicate(CardType.LAND));
|
||||
this.add(new SupertypePredicate("Basic"));
|
||||
this.add(new SupertypePredicate(SuperType.BASIC));
|
||||
}
|
||||
|
||||
public FilterBasicLandCard(final FilterBasicLandCard filter) {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
package mage.filter.common;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.filter.predicate.mageobject.SupertypePredicate;
|
||||
|
|
@ -50,7 +51,7 @@ public class FilterLandCard extends FilterCard {
|
|||
|
||||
public static FilterLandCard basicLandCard() {
|
||||
FilterLandCard filter = new FilterLandCard("basic land card");
|
||||
filter.add(new SupertypePredicate("Basic"));
|
||||
filter.add(new SupertypePredicate(SuperType.BASIC));
|
||||
return filter;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
package mage.filter.common;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
|
|
@ -57,13 +58,13 @@ public class FilterLandPermanent extends FilterPermanent {
|
|||
|
||||
public static FilterLandPermanent nonbasicLand() {
|
||||
FilterLandPermanent filter = new FilterLandPermanent("nonbasic land");
|
||||
filter.add(Predicates.not(new SupertypePredicate("Basic")));
|
||||
filter.add(Predicates.not(new SupertypePredicate(SuperType.BASIC)));
|
||||
return filter;
|
||||
}
|
||||
|
||||
public static FilterLandPermanent nonbasicLands() {
|
||||
FilterLandPermanent filter = new FilterLandPermanent("nonbasic lands");
|
||||
filter.add(Predicates.not(new SupertypePredicate("Basic")));
|
||||
filter.add(Predicates.not(new SupertypePredicate(SuperType.BASIC)));
|
||||
return filter;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
package mage.filter.predicate.mageobject;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.constants.SuperType;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
|
||||
|
|
@ -37,15 +38,19 @@ import mage.game.Game;
|
|||
*/
|
||||
public class SupertypePredicate implements Predicate<MageObject> {
|
||||
|
||||
private final String supertype;
|
||||
private final SuperType supertype;
|
||||
|
||||
public SupertypePredicate(String supertype) {
|
||||
public SupertypePredicate(SuperType supertype) {
|
||||
this.supertype = supertype;
|
||||
}
|
||||
|
||||
public SupertypePredicate(String supertype){
|
||||
this.supertype = SuperType.valueOf(supertype.trim().toUpperCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(MageObject input, Game game) {
|
||||
return input.getSupertype().contains(supertype);
|
||||
return input.getSuperType().contains(supertype);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
FILTER_FORTIFICATION.add(new CardTypePredicate(CardType.ARTIFACT));
|
||||
FILTER_FORTIFICATION.add(new SubtypePredicate("Fortification"));
|
||||
|
||||
FILTER_LEGENDARY.add(new SupertypePredicate("Legendary"));
|
||||
FILTER_LEGENDARY.add(new SupertypePredicate(SuperType.LEGENDARY));
|
||||
}
|
||||
|
||||
private transient Object customData;
|
||||
|
|
@ -1733,7 +1733,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
planeswalkers.add(perm);
|
||||
}
|
||||
if (perm.getSupertype().contains("World")) {
|
||||
if (perm.isWorld()) {
|
||||
worldEnchantment.add(perm);
|
||||
}
|
||||
if (FILTER_AURA.match(perm, this)) {
|
||||
|
|
@ -1931,7 +1931,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
if (legendary.size() > 1) { //don't bother checking if less than 2 legends in play
|
||||
for (Permanent legend : legendary) {
|
||||
FilterPermanent filterLegendName = new FilterPermanent();
|
||||
filterLegendName.add(new SupertypePredicate("Legendary"));
|
||||
filterLegendName.add(new SupertypePredicate(SuperType.LEGENDARY));
|
||||
filterLegendName.add(new NamePredicate(legend.getName()));
|
||||
filterLegendName.add(new ControllerIdPredicate(legend.getControllerId()));
|
||||
if (getBattlefield().contains(filterLegendName, legend.getControllerId(), this, 2)) {
|
||||
|
|
|
|||
|
|
@ -41,12 +41,7 @@ import mage.cards.CardImpl;
|
|||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.MultiplayerAttackOption;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.RangeOfInfluence;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.constants.*;
|
||||
import mage.game.turn.TurnMod;
|
||||
import mage.players.Player;
|
||||
import mage.watchers.common.CommanderInfoWatcher;
|
||||
|
|
@ -166,7 +161,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.supertype.add("Legendary");
|
||||
this.addSuperType(SuperType.LEGENDARY);
|
||||
|
||||
if (manaString.contains("{G}")) {
|
||||
this.color.setGreen(true);
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ import mage.abilities.costs.mana.ManaCosts;
|
|||
import mage.cards.Card;
|
||||
import mage.cards.FrameStyle;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.util.GameLog;
|
||||
|
|
@ -127,8 +128,8 @@ public class Commander implements CommandObject {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupertype() {
|
||||
return sourceObject.getSupertype();
|
||||
public EnumSet<SuperType> getSuperType() {
|
||||
return sourceObject.getSuperType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import mage.abilities.costs.mana.ManaCostsImpl;
|
|||
import mage.cards.Card;
|
||||
import mage.cards.FrameStyle;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.util.GameLog;
|
||||
|
|
@ -163,8 +164,8 @@ public class Emblem implements CommandObject {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupertype() {
|
||||
return emptyList;
|
||||
public EnumSet<SuperType> getSuperType() {
|
||||
return EnumSet.noneOf(SuperType.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ public class PermanentCard extends PermanentImpl {
|
|||
this.subtype.clear();
|
||||
this.subtype.addAll(card.getSubtype(game));
|
||||
this.supertype.clear();
|
||||
this.supertype.addAll(card.getSupertype());
|
||||
supertype.addAll(card.getSuperType());
|
||||
this.expansionSetCode = card.getExpansionSetCode();
|
||||
this.rarity = card.getRarity();
|
||||
this.cardNumber = card.getCardNumber();
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public class PermanentToken extends PermanentImpl {
|
|||
this.color = token.getColor(game).copy();
|
||||
this.frameColor = token.getFrameColor(game);
|
||||
this.frameStyle = token.getFrameStyle();
|
||||
this.supertype = token.getSupertype();
|
||||
this.supertype = token.getSuperType();
|
||||
this.subtype = token.getSubtype(game);
|
||||
this.tokenDescriptor = token.getTokenDescriptor();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,10 +27,8 @@
|
|||
*/
|
||||
package mage.game.stack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.Mana;
|
||||
|
|
@ -49,12 +47,7 @@ import mage.cards.Card;
|
|||
import mage.cards.CardsImpl;
|
||||
import mage.cards.FrameStyle;
|
||||
import mage.cards.SplitCard;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.SpellAbilityType;
|
||||
import mage.constants.Zone;
|
||||
import mage.constants.ZoneDetail;
|
||||
import mage.constants.*;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.Counters;
|
||||
import mage.game.Game;
|
||||
|
|
@ -499,8 +492,8 @@ public class Spell extends StackObjImpl implements Card {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupertype() {
|
||||
return card.getSupertype();
|
||||
public EnumSet<SuperType> getSuperType() {
|
||||
return card.getSuperType();
|
||||
}
|
||||
|
||||
public List<SpellAbility> getSpellAbilities() {
|
||||
|
|
|
|||
|
|
@ -49,13 +49,7 @@ import mage.abilities.effects.Effect;
|
|||
import mage.abilities.effects.Effects;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.FrameStyle;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.AbilityWord;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.EffectType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.constants.ZoneDetail;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
|
|
@ -174,8 +168,8 @@ public class StackAbility extends StackObjImpl implements Ability {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupertype() {
|
||||
return emptyString;
|
||||
public EnumSet<SuperType> getSuperType() {
|
||||
return EnumSet.noneOf(SuperType.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
package mage.target.common;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.filter.predicate.mageobject.SupertypePredicate;
|
||||
|
|
@ -42,7 +43,7 @@ public class TargetBasicLandCard extends TargetCard {
|
|||
|
||||
public TargetBasicLandCard(Zone zone) {
|
||||
super(zone);
|
||||
filter.add(new SupertypePredicate("Basic"));
|
||||
filter.add(new SupertypePredicate(SuperType.BASIC));
|
||||
filter.add(new CardTypePredicate(CardType.LAND));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.target.common;
|
||||
|
||||
import mage.constants.SuperType;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.SupertypePredicate;
|
||||
|
||||
|
|
@ -38,7 +39,7 @@ import mage.filter.predicate.mageobject.SupertypePredicate;
|
|||
public class TargetNonBasicLandPermanent extends TargetLandPermanent {
|
||||
|
||||
public TargetNonBasicLandPermanent() {
|
||||
filter.add(Predicates.not(new SupertypePredicate("Basic")));
|
||||
filter.add(Predicates.not(new SupertypePredicate(SuperType.BASIC)));
|
||||
this.targetName = "nonbasic land";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -414,18 +414,6 @@ public final class CardUtil {
|
|||
return new CopyTokenFunction(target);
|
||||
}
|
||||
|
||||
public static boolean isPermanentCard(Card card) {
|
||||
boolean permanent = false;
|
||||
|
||||
permanent |= card.isArtifact();
|
||||
permanent |= card.isCreature();
|
||||
permanent |= card.isEnchantment();
|
||||
permanent |= card.isLand();
|
||||
permanent |= card.isPlaneswalker();
|
||||
|
||||
return permanent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an integer number to string Numbers > 20 will be returned as
|
||||
* digits
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.keyword.MorphAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
import mage.game.permanent.PermanentToken;
|
||||
import mage.game.permanent.token.Token;
|
||||
|
|
@ -98,9 +99,9 @@ public class CopyTokenFunction implements Function<Token, Card> {
|
|||
for (String type : sourceObj.getSubtype(null)) {
|
||||
target.getSubtype(null).add(type);
|
||||
}
|
||||
target.getSupertype().clear();
|
||||
for (String type : sourceObj.getSupertype()) {
|
||||
target.getSupertype().add(type);
|
||||
target.getSuperType().clear();
|
||||
for (SuperType type : sourceObj.getSuperType()) {
|
||||
target.getSuperType().add(type);
|
||||
}
|
||||
|
||||
target.getAbilities().clear();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue