This commit is contained in:
igoudt 2017-05-16 22:11:47 +02:00
parent 24ff9f7c5e
commit c44c301f5b
293 changed files with 2291 additions and 550 deletions

View file

@ -29,6 +29,8 @@
package mage.abilities.common;
import java.util.ArrayList;
import java.util.Set;
import mage.MageObject;
import mage.abilities.ActivatedAbilityImpl;
import mage.abilities.costs.common.PayLifeCost;
@ -37,6 +39,7 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.Predicate;
@ -51,11 +54,11 @@ import mage.target.common.TargetCardInLibrary;
*/
public class FetchLandActivatedAbility extends ActivatedAbilityImpl {
public FetchLandActivatedAbility(String[] subtypes) {
public FetchLandActivatedAbility(Set<SubType> subtypes) {
this(true, subtypes);
}
public FetchLandActivatedAbility(boolean withDamage, String[] subtypes) {
public FetchLandActivatedAbility(boolean withDamage, Set<SubType> subtypes) {
super(Zone.BATTLEFIELD, null);
addCost(new TapSourceCost());
if (withDamage) {
@ -65,7 +68,7 @@ public class FetchLandActivatedAbility extends ActivatedAbilityImpl {
FilterCard filter = new FilterCard(subTypeNames(subtypes));
filter.add(new CardTypePredicate(CardType.LAND));
ArrayList<Predicate<MageObject>> subtypePredicates = new ArrayList<>();
for (String subtype : subtypes) {
for (SubType subtype : subtypes) {
subtypePredicates.add(new SubtypePredicate(subtype));
}
filter.add(Predicates.or(subtypePredicates));
@ -77,9 +80,9 @@ public class FetchLandActivatedAbility extends ActivatedAbilityImpl {
super(ability);
}
private String subTypeNames(String[] subTypes) {
private String subTypeNames(Set<SubType> subTypes) {
StringBuilder sb = new StringBuilder();
for (String subType: subTypes) {
for (SubType subType: subTypes) {
sb.append(subType).append(" or ");
}
return sb.substring(0, sb.length() - 4);

View file

@ -29,6 +29,7 @@ package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.constants.SubType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -43,7 +44,7 @@ public class EnchantedCreatureSubtypeCondition implements Condition {
private final FilterPermanent filter = new FilterCreaturePermanent();
public EnchantedCreatureSubtypeCondition(String string) {
public EnchantedCreatureSubtypeCondition(SubType string) {
filter.add(new SubtypePredicate(string));
}

View file

@ -3,6 +3,7 @@ package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.constants.SubType;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
@ -18,24 +19,24 @@ public class UrzaTerrainValue implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
FilterControlledPermanent pp = new FilterControlledPermanent("Urza's Power Plant");
pp.add(new SubtypePredicate("Urza's"));
pp.add(new SubtypePredicate("Power-Plant"));
pp.add(new SubtypePredicate(SubType.URZAS));
pp.add(new SubtypePredicate(SubType.POWER_PLANT));
PermanentsOnBattlefieldCount ppP = new PermanentsOnBattlefieldCount(pp);
if (ppP.calculate(game, sourceAbility, effect) < 1) {
return 1;
}
FilterControlledPermanent to = new FilterControlledPermanent("Urza's Tower");
to.add(new SubtypePredicate("Urza's"));
to.add(new SubtypePredicate("Tower"));
to.add(new SubtypePredicate(SubType.URZAS));
to.add(new SubtypePredicate(SubType.TOWER));
PermanentsOnBattlefieldCount toP = new PermanentsOnBattlefieldCount(to);
if (toP.calculate(game, sourceAbility, effect) < 1) {
return 1;
}
FilterControlledPermanent mi = new FilterControlledPermanent("Urza's Mine");
mi.add(new SubtypePredicate("Urza's"));
mi.add(new SubtypePredicate("Mine"));
mi.add(new SubtypePredicate(SubType.URZAS));
mi.add(new SubtypePredicate(SubType.MINE));
PermanentsOnBattlefieldCount miP = new PermanentsOnBattlefieldCount(mi);
if (miP.calculate(game, sourceAbility, effect) < 1) {
return 1;

View file

@ -14,6 +14,7 @@ import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.counters.CounterType;
import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.Predicates;
@ -101,7 +102,7 @@ public class AmplifyEffect extends ReplacementEffectImpl {
FilterCreatureCard filter = new FilterCreatureCard("creatures cards to reveal");
List<SubtypePredicate> filterSubtypes = new ArrayList<>();
for (String subtype : sourceCreature.getSubtype(game)) {
filterSubtypes.add(new SubtypePredicate((subtype)));
filterSubtypes.add(new SubtypePredicate(SubType.byDescription(subtype)));
}
if (filterSubtypes.size() > 1) {
filter.add(Predicates.or(filterSubtypes));

View file

@ -31,6 +31,7 @@ import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardsImpl;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledLandPermanent;
@ -47,12 +48,12 @@ import mage.util.CardUtil;
*/
public class SweepEffect extends OneShotEffect {
private final String sweepSubtype;
private final SubType sweepSubtype;
public SweepEffect(String sweepSubtype) {
public SweepEffect(SubType sweepSubtype) {
super(Outcome.Benefit);
this.sweepSubtype = sweepSubtype;
this.staticText = "<i>Sweep</i> - Return any number of " + sweepSubtype + (sweepSubtype.endsWith("s") ? "" : "s") + " you control to their owner's hand";
this.staticText = "<i>Sweep</i> - Return any number of " + sweepSubtype + (sweepSubtype.getDescription().endsWith("s") ? "" : "s") + " you control to their owner's hand";
}
public SweepEffect(final SweepEffect effect) {

View file

@ -32,6 +32,7 @@ import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.AdjustingSourceCosts;
import mage.abilities.effects.common.AffinityEffect;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -48,9 +49,9 @@ public class AffinityForLandTypeAbility extends SimpleStaticAbility implements A
private final FilterControlledPermanent filter;
String text;
String landType;
SubType landType;
public AffinityForLandTypeAbility(String landType, String text) {
public AffinityForLandTypeAbility(SubType landType, String text) {
super(Zone.OUTSIDE, new AffinityEffect(getFilter(landType)));
this.filter = getFilter(landType);
setRuleAtTheTop(true);
@ -58,7 +59,7 @@ public class AffinityForLandTypeAbility extends SimpleStaticAbility implements A
this.landType = landType;
}
private static FilterControlledPermanent getFilter(String landType) {
private static FilterControlledPermanent getFilter(SubType landType) {
FilterControlledPermanent affinityfilter = new FilterControlledPermanent();
affinityfilter.add(new SubtypePredicate(landType));
return affinityfilter;

View file

@ -33,6 +33,7 @@ import mage.abilities.costs.mana.ManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -88,7 +89,7 @@ class AuraSwapEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
FilterCard filterCardToCheck = new FilterCard();
filterCardToCheck.add(new SubtypePredicate("Aura"));
filterCardToCheck.add(new SubtypePredicate(SubType.AURA));
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent auraSourcePermanent = game.getPermanent(source.getSourceId());

View file

@ -28,6 +28,7 @@
package mage.abilities.keyword;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
@ -41,6 +42,7 @@ import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.Predicate;
@ -74,11 +76,15 @@ import mage.util.CardUtil;
*/
public class ChampionAbility extends StaticAbility {
protected String[] subtypes;
protected EnumSet<SubType> subtypes;
protected String objectDescription;
public ChampionAbility(Card card, String subtype, boolean requiresCreature) {
this(card, new String[]{subtype}, requiresCreature);
public ChampionAbility(Card card, SubType subtype, boolean requiresCreature) {
this(card, EnumSet.of(subtype), requiresCreature);
}
public ChampionAbility(Card card, boolean requiresCreature) {
this(card, EnumSet.noneOf(SubType.class), requiresCreature);
}
/**
@ -91,15 +97,15 @@ public class ChampionAbility extends StaticAbility {
* @param requiresCreature for cards that specifically require championing
* another creature
*/
public ChampionAbility(Card card, String[] subtypes, boolean requiresCreature) {
public ChampionAbility(Card card, EnumSet<SubType> subtypes, boolean requiresCreature) {
super(Zone.BATTLEFIELD, null);
this.subtypes = subtypes;
StringBuilder sb = new StringBuilder("another ");
ArrayList<Predicate<MageObject>> subtypesPredicates = new ArrayList<>();
if (!subtypes[0].isEmpty()) {
if (!subtypes.isEmpty()) {
int i = 0;
for (String subtype : this.subtypes) {
for (SubType subtype : this.subtypes) {
subtypesPredicates.add(new SubtypePredicate(subtype));
if (i == 0) {
sb.append(subtype);

View file

@ -29,6 +29,7 @@
package mage.abilities.keyword;
import mage.abilities.costs.mana.ManaCosts;
import mage.constants.SubType;
import mage.filter.common.FilterLandCard;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -40,7 +41,7 @@ public class ForestcyclingAbility extends CyclingAbility{
private static final FilterLandCard filter = new FilterLandCard("Forest card");
private static final String text = "Forestcycling";
static{
filter.add(new SubtypePredicate("Forest"));
filter.add(new SubtypePredicate(SubType.FOREST));
}
public ForestcyclingAbility(ManaCosts costs) {

View file

@ -27,6 +27,7 @@
*/
package mage.abilities.keyword;
import mage.constants.SubType;
import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -39,7 +40,7 @@ public class ForestwalkAbility extends LandwalkAbility {
private static final FilterLandPermanent filter = new FilterLandPermanent("forest");
static {
filter.add(new SubtypePredicate("Forest"));
filter.add(new SubtypePredicate(SubType.FOREST));
}
public ForestwalkAbility() {

View file

@ -29,6 +29,7 @@
package mage.abilities.keyword;
import mage.abilities.costs.mana.ManaCosts;
import mage.constants.SubType;
import mage.filter.common.FilterLandCard;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -40,7 +41,7 @@ public class IslandcyclingAbility extends CyclingAbility{
private static final FilterLandCard filter = new FilterLandCard("Island card");
private static final String text = "Islandcycling";
static{
filter.add(new SubtypePredicate("Island"));
filter.add(new SubtypePredicate(SubType.ISLAND));
}
public IslandcyclingAbility(ManaCosts costs) {

View file

@ -27,6 +27,7 @@
*/
package mage.abilities.keyword;
import mage.constants.SubType;
import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -39,7 +40,7 @@ public class IslandwalkAbility extends LandwalkAbility {
private static final FilterLandPermanent filter = new FilterLandPermanent("island");
static {
filter.add(new SubtypePredicate("Island"));
filter.add(new SubtypePredicate(SubType.ISLAND));
}
public IslandwalkAbility() {

View file

@ -29,6 +29,7 @@
package mage.abilities.keyword;
import mage.abilities.costs.mana.ManaCosts;
import mage.constants.SubType;
import mage.filter.common.FilterLandCard;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -40,7 +41,7 @@ public class MountaincyclingAbility extends CyclingAbility{
private static final FilterLandCard filter = new FilterLandCard("Mountain card");
private static final String text = "Mountaincycling";
static{
filter.add(new SubtypePredicate("Mountain"));
filter.add(new SubtypePredicate(SubType.MOUNTAIN));
}
public MountaincyclingAbility(ManaCosts costs) {

View file

@ -27,6 +27,7 @@
*/
package mage.abilities.keyword;
import mage.constants.SubType;
import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -39,7 +40,7 @@ public class MountainwalkAbility extends LandwalkAbility {
private static final FilterLandPermanent filter = new FilterLandPermanent("mountain");
static {
filter.add(new SubtypePredicate("Mountain"));
filter.add(new SubtypePredicate(SubType.MOUNTAIN));
}
public MountainwalkAbility() {

View file

@ -35,11 +35,7 @@ import mage.abilities.StaticAbility;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.cards.Card;
import mage.constants.AsThoughEffectType;
import mage.constants.CostModificationType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
@ -80,10 +76,10 @@ public class OfferingAbility extends StaticAbility {
*
* @param subtype name of the subtype that can be offered
*/
public OfferingAbility(String subtype) {
public OfferingAbility(SubType subtype) {
super(Zone.ALL, null);
filter.add(new SubtypePredicate(subtype));
filter.setMessage(subtype);
filter.setMessage(subtype.getDescription());
this.addEffect(new OfferingAsThoughEffect());
}

View file

@ -29,6 +29,7 @@
package mage.abilities.keyword;
import mage.abilities.costs.mana.ManaCosts;
import mage.constants.SubType;
import mage.filter.common.FilterLandCard;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -40,7 +41,7 @@ public class PlainscyclingAbility extends CyclingAbility{
private static final FilterLandCard filter = new FilterLandCard("Plains card");
private static final String text = "Plainscycling";
static{
filter.add(new SubtypePredicate("Plains"));
filter.add(new SubtypePredicate(SubType.PLAINS));
}
public PlainscyclingAbility(ManaCosts costs) {

View file

@ -27,6 +27,7 @@
*/
package mage.abilities.keyword;
import mage.constants.SubType;
import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -39,7 +40,7 @@ public class PlainswalkAbility extends LandwalkAbility {
private static final FilterLandPermanent filter = new FilterLandPermanent("plains");
static {
filter.add(new SubtypePredicate("Plains"));
filter.add(new SubtypePredicate(SubType.PLAINS));
}
public PlainswalkAbility() {

View file

@ -33,6 +33,7 @@ import mage.abilities.common.DiesTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.common.ReturnToHandTargetEffect;
import mage.constants.SubType;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -77,7 +78,7 @@ public class SoulshiftAbility extends DiesTriggeredAbility {
int intValue = amount.calculate(game, this, null);
FilterCard filter = new FilterCard("Spirit card with converted mana cost " + intValue + " or less from your graveyard");
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, intValue + 1));
filter.add(new SubtypePredicate("Spirit"));
filter.add(new SubtypePredicate(SubType.SPIRIT));
this.addTarget(new TargetCardInYourGraveyard(filter));
super.trigger(game, controllerId); //To change body of generated methods, choose Tools | Templates.
}

View file

@ -29,6 +29,7 @@
package mage.abilities.keyword;
import mage.abilities.costs.mana.ManaCosts;
import mage.constants.SubType;
import mage.filter.common.FilterLandCard;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -41,7 +42,7 @@ public class SwampcyclingAbility extends CyclingAbility{
private static final FilterLandCard filter = new FilterLandCard("Swamp card");
private static final String text = "Swampcycling";
static{
filter.add(new SubtypePredicate("Swamp"));
filter.add(new SubtypePredicate(SubType.SWAMP));
}
public SwampcyclingAbility(ManaCosts costs) {
super(costs, filter, text);

View file

@ -27,6 +27,7 @@
*/
package mage.abilities.keyword;
import mage.constants.SubType;
import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -39,7 +40,7 @@ public class SwampwalkAbility extends LandwalkAbility {
private static final FilterLandPermanent filter = new FilterLandPermanent("swamp");
static {
filter.add(new SubtypePredicate("Swamp"));
filter.add(new SubtypePredicate(SubType.SWAMP));
}
public SwampwalkAbility() {

View file

@ -0,0 +1,127 @@
package mage.constants;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;
public enum SubType {
ARCANE("Arcane", SubTypeSet.SpellType),
TRAP("Trap", SubTypeSet.SpellType),
FOREST("Forest", SubTypeSet.BasicLandType),
ISLAND("Island", SubTypeSet.BasicLandType),
MOUNTAIN("Mountain", SubTypeSet.BasicLandType),
PLAINS("Plains", SubTypeSet.BasicLandType),
SWAMP("Swamp", SubTypeSet.BasicLandType),
DESERT("Desert", SubTypeSet.NonBasicLandType),
GATE("Gate", SubTypeSet.NonBasicLandType),
LOCUS("Locus", SubTypeSet.NonBasicLandType),
URZAS("Urza's", SubTypeSet.NonBasicLandType),
MINE("Mine", SubTypeSet.NonBasicLandType),
POWER_PLANT("Power-Plant", SubTypeSet.NonBasicLandType),
TOWER("Tower", SubTypeSet.NonBasicLandType),
AURA("Aura", SubTypeSet.EchanemtType),
CARTOUCHE("Cartouche", SubTypeSet.EchanemtType),
SHRINE("Shrine", SubTypeSet.EchanemtType),
EQUIPMENT("Equipment", SubTypeSet.ArtifactType),
FORTIFICATION("Fortification", SubTypeSet.ArtifactType),
VEHICLE("Vehicle", SubTypeSet.ArtifactType),
ALLY("Ally", SubTypeSet.CreatureType),
ARTIFICER("Artificer", SubTypeSet.CreatureType),
ASSASSIN("Assassin", SubTypeSet.CreatureType),
BARBARION("Barbarian", SubTypeSet.CreatureType),
BEAST("Beast", SubTypeSet.CreatureType),
BERSERKER("Berserker", SubTypeSet.CreatureType),
BIRD("Bird", SubTypeSet.CreatureType),
CAT("Cat", SubTypeSet.CreatureType),
CEPHALID("Cephalid", SubTypeSet.CreatureType),
CLERIC("Cleric", SubTypeSet.CreatureType),
DEMON("Demon", SubTypeSet.CreatureType),
DRAGON("Dragon", SubTypeSet.CreatureType),
DROID("Droid", SubTypeSet.CreatureType),
DWARF("Dwarf", SubTypeSet.CreatureType),
ELDRAZI("Eldrazi", SubTypeSet.CreatureType),
ELEMENTAL("Elemental", SubTypeSet.CreatureType),
ELF("Elf", SubTypeSet.CreatureType),
FAERIE("Faerie", SubTypeSet.CreatureType),
FOX("Fox", SubTypeSet.CreatureType),
FUNGUS("Fungus", SubTypeSet.CreatureType),
GIANT("Giant", SubTypeSet.CreatureType),
GOAT("Goat", SubTypeSet.CreatureType),
GOBLIN("Goblin", SubTypeSet.CreatureType),
GORGON("Gorgon", SubTypeSet.CreatureType),
HUMAN("Human", SubTypeSet.CreatureType),
KITHKIN("Kithkin", SubTypeSet.CreatureType),
KNIGHT("Knight", SubTypeSet.CreatureType),
KOBOLD("Kobold", SubTypeSet.CreatureType),
GOLEM("Golem", SubTypeSet.CreatureType),
KAVU("Kavu", SubTypeSet.CreatureType),
MERCENARY("Mercenary", SubTypeSet.CreatureType),
MERFOLK("Merfolk", SubTypeSet.CreatureType),
MINION("Minion", SubTypeSet.CreatureType),
MYR("Myr", SubTypeSet.CreatureType),
NINJA("Ninja",SubTypeSet.CreatureType),
OGRE("Ogre", SubTypeSet.CreatureType),
ORC("Orc", SubTypeSet.CreatureType),
PENTAVITE("Pentavite", SubTypeSet.CreatureType),
PRISM("Prism", SubTypeSet.CreatureType),
RAT("Rat", SubTypeSet.CreatureType),
REBEL("Rebel", SubTypeSet.CreatureType),
SAPROLING("Saproling", SubTypeSet.CreatureType),
SCION("Scion", SubTypeSet.CreatureType),
SERVO("Servo", SubTypeSet.CreatureType),
SHAMAN("Shaman", SubTypeSet.CreatureType),
SKELETON("Skeleton", SubTypeSet.CreatureType),
SLIVER("Sliver", SubTypeSet.CreatureType),
SNAKE("Snake", SubTypeSet.CreatureType),
SOLDIER("Soldier", SubTypeSet.CreatureType),
SPIRIT("Spirit", SubTypeSet.CreatureType),
SQUIRREL("Squirrel", SubTypeSet.CreatureType),
THOPTER("Thopter", SubTypeSet.CreatureType),
THRULL("Thrull", SubTypeSet.CreatureType),
TREEFOLK("Treefolk", SubTypeSet.CreatureType),
TROOPER("Trooper", SubTypeSet.CreatureType),
VAMPIRE("Vampire", SubTypeSet.CreatureType),
WALL("Wall", SubTypeSet.CreatureType),
WARRIOR("Warrior", SubTypeSet.CreatureType),
WEREWOLF("Werewolf", SubTypeSet.CreatureType),
WIZARD("Wizard", SubTypeSet.CreatureType),
WOLF("Wolf", SubTypeSet.CreatureType),
ZOMBIE("Zombie", SubTypeSet.CreatureType);
private final SubTypeSet subTypeSet;
public String getDescription() {
return description;
}
private final String description;
SubType(String description, SubTypeSet subTypeSet) {
this.description = description;
this.subTypeSet = subTypeSet;
}
public static SubType byDescription(String subtype) {
for (SubType s : values()) {
if (s.getDescription().equals(subtype)) {
return s;
}
}
throw new IllegalArgumentException("no subtype for " + subtype + " exists");
}
public SubTypeSet getSubTypeSet() {
return subTypeSet;
}
public static Set<String> getCreatureTypes() {
return Arrays.stream(values()).filter(p -> p.getSubTypeSet() == SubTypeSet.CreatureType).map(SubType::getDescription).collect(Collectors.toSet());
}
}

View file

@ -0,0 +1,10 @@
package mage.constants;
public enum SubTypeSet {
CreatureType,
SpellType,
BasicLandType,
NonBasicLandType,
EchanemtType,
ArtifactType
}

View file

@ -30,6 +30,8 @@ package mage.filter;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.constants.SubType;
import mage.filter.predicate.ObjectPlayer;
import mage.filter.predicate.ObjectPlayerPredicate;
import mage.filter.predicate.ObjectSourcePlayer;
@ -59,7 +61,7 @@ public class FilterPermanent extends FilterObject<Permanent> implements FilterIn
super(name);
}
public FilterPermanent(String subtype, String name) {
public FilterPermanent(SubType subtype, String name) {
super(name);
this.add(new SubtypePredicate(subtype));
}

View file

@ -6,6 +6,7 @@
package mage.filter;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.filter.common.FilterArtifactCard;
import mage.filter.common.FilterArtifactCreaturePermanent;
import mage.filter.common.FilterControlledArtifactPermanent;
@ -37,8 +38,8 @@ public final class StaticFilters {
public static final FilterCreaturePermanent FILTER_PERMANENT_CREATURE = new FilterCreaturePermanent();
public static final FilterCreaturePermanent FILTER_PERMANENT_A_CREATURE = new FilterCreaturePermanent("a creature");
public static final FilterCreaturePermanent FILTER_PERMANENT_CREATURES = new FilterCreaturePermanent("creatures");
public static final FilterCreaturePermanent FILTER_PERMANENT_CREATURE_GOBLINS = new FilterCreaturePermanent("Goblin", "Goblin creatures");
public static final FilterCreaturePermanent FILTER_PERMANENT_CREATURE_SLIVERS = new FilterCreaturePermanent("Sliver", "Sliver creatures");
public static final FilterCreaturePermanent FILTER_PERMANENT_CREATURE_GOBLINS = new FilterCreaturePermanent(SubType.GOBLIN, "Goblin creatures");
public static final FilterCreaturePermanent FILTER_PERMANENT_CREATURE_SLIVERS = new FilterCreaturePermanent(SubType.SLIVER, "Sliver creatures");
public static final FilterCreatureSpell FILTER_SPELL_A_CREATURE = new FilterCreatureSpell("a creature spell");
public static final FilterSpell FILTER_SPELL_NON_CREATURE

View file

@ -28,6 +28,7 @@
package mage.filter.common;
import mage.constants.SubType;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -38,7 +39,7 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
public class FilterBySubtypeCard extends FilterCard {
public FilterBySubtypeCard(String subtype) {
public FilterBySubtypeCard(SubType subtype) {
super(subtype + " card");
this.add(new SubtypePredicate(subtype));
}

View file

@ -29,6 +29,7 @@
package mage.filter.common;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -48,7 +49,7 @@ public class FilterControlledCreaturePermanent extends FilterControlledPermanent
}
public FilterControlledCreaturePermanent(String subtype, String name) {
public FilterControlledCreaturePermanent(SubType subtype, String name) {
super(name);
this.add(new CardTypePredicate(CardType.CREATURE));
this.add(new SubtypePredicate(subtype));

View file

@ -29,6 +29,7 @@
package mage.filter.common;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.filter.FilterPermanent;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -48,7 +49,7 @@ public class FilterCreaturePermanent extends FilterPermanent {
this.add(new CardTypePredicate(CardType.CREATURE));
}
public FilterCreaturePermanent(String subtype, String name) {
public FilterCreaturePermanent(SubType subtype, String name) {
super(name);
this.add(new CardTypePredicate(CardType.CREATURE));
this.add(new SubtypePredicate(subtype));

View file

@ -29,6 +29,7 @@
package mage.filter.common;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.filter.FilterPermanent;
import mage.filter.predicate.Predicates;
@ -50,7 +51,7 @@ public class FilterLandPermanent extends FilterPermanent {
this.add(new CardTypePredicate(CardType.LAND));
}
public FilterLandPermanent(String subtype, String name) {
public FilterLandPermanent(SubType subtype, String name) {
super(name);
this.add(new CardTypePredicate(CardType.LAND));
this.add(new SubtypePredicate(subtype));

View file

@ -1,5 +1,6 @@
package mage.filter.common;
import mage.constants.SubType;
import mage.constants.TargetController;
import mage.filter.predicate.permanent.ControllerPredicate;
@ -24,7 +25,7 @@ public class FilterOpponentsCreaturePermanent extends FilterCreaturePermanent {
}
public FilterOpponentsCreaturePermanent(String subtype, String name) {
public FilterOpponentsCreaturePermanent(SubType subtype, String name) {
super(subtype, name);
this.add(new ControllerPredicate(TargetController.OPPONENT));
}

View file

@ -1,5 +1,6 @@
package mage.filter.common;
import mage.constants.SubType;
import mage.filter.FilterSpell;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -12,7 +13,7 @@ public class FilterSpiritOrArcaneCard extends FilterSpell {
public FilterSpiritOrArcaneCard(String name) {
super(name);
this.add(Predicates.or(new SubtypePredicate("Spirit"),new SubtypePredicate("Arcane")));
this.add(Predicates.or(new SubtypePredicate(SubType.SPIRIT),new SubtypePredicate(SubType.ARCANE)));
}
public FilterSpiritOrArcaneCard(final FilterSpiritOrArcaneCard filter) {

View file

@ -28,6 +28,7 @@
package mage.filter.predicate.mageobject;
import mage.MageObject;
import mage.constants.SubType;
import mage.filter.predicate.Predicate;
import mage.game.Game;
@ -37,15 +38,15 @@ import mage.game.Game;
*/
public class SubtypePredicate implements Predicate<MageObject> {
private final String subtype;
private final SubType subtype;
public SubtypePredicate(String subtype) {
public SubtypePredicate(SubType subtype) {
this.subtype = subtype;
}
@Override
public boolean apply(MageObject input, Game game) {
return input.hasSubtype(subtype, game);
return input.hasSubtype(subtype.getDescription(), game);
}
@Override

View file

@ -27,6 +27,7 @@
*/
package mage.filter.predicate.permanent;
import mage.constants.SubType;
import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.Predicate;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -42,7 +43,7 @@ public class ControllerControlsIslandPredicate implements Predicate<Permanent> {
public static final FilterLandPermanent filter = new FilterLandPermanent("Island");
static {
filter.add(new SubtypePredicate("Island"));
filter.add(new SubtypePredicate(SubType.ISLAND));
}
@Override

View file

@ -109,13 +109,13 @@ public abstract class GameImpl implements Game, Serializable {
static {
FILTER_AURA.add(new CardTypePredicate(CardType.ENCHANTMENT));
FILTER_AURA.add(new SubtypePredicate("Aura"));
FILTER_AURA.add(new SubtypePredicate(SubType.AURA));
FILTER_EQUIPMENT.add(new CardTypePredicate(CardType.ARTIFACT));
FILTER_EQUIPMENT.add(new SubtypePredicate("Equipment"));
FILTER_EQUIPMENT.add(new SubtypePredicate(SubType.EQUIPMENT));
FILTER_FORTIFICATION.add(new CardTypePredicate(CardType.ARTIFACT));
FILTER_FORTIFICATION.add(new SubtypePredicate("Fortification"));
FILTER_FORTIFICATION.add(new SubtypePredicate(SubType.FORTIFICATION));
FILTER_LEGENDARY.add(new SupertypePredicate(SuperType.LEGENDARY));
}
@ -1945,7 +1945,7 @@ public abstract class GameImpl implements Game, Serializable {
for (Permanent planeswalker : planeswalkers) {
for (String planeswalkertype : planeswalker.getSubtype(this)) {
FilterPlaneswalkerPermanent filterPlaneswalker = new FilterPlaneswalkerPermanent();
filterPlaneswalker.add(new SubtypePredicate(planeswalkertype));
filterPlaneswalker.add(new SubtypePredicate(SubType.byDescription(planeswalkertype)));
filterPlaneswalker.add(new ControllerIdPredicate(planeswalker.getControllerId()));
if (getBattlefield().contains(filterPlaneswalker, planeswalker.getControllerId(), this, 2)) {
Player controller = this.getPlayer(planeswalker.getControllerId());

View file

@ -33,6 +33,7 @@ import java.util.UUID;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.RevealTargetFromHandCost;
import mage.constants.SubType;
import mage.constants.WatcherScope;
import mage.filter.FilterPermanent;
import mage.game.Game;
@ -46,7 +47,7 @@ import mage.watchers.Watcher;
*/
public class DragonOnTheBattlefieldWhileSpellWasCastWatcher extends Watcher {
private static final FilterPermanent filter = new FilterPermanent("Dragon", "Dragons");
private static final FilterPermanent filter = new FilterPermanent(SubType.DRAGON, "Dragons");
private final Set<UUID> castWithDragonOnTheBattlefield = new HashSet<>();