mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
clean ups, talk to interface rather than implementation
This commit is contained in:
parent
fe2ee5dfec
commit
89ac77e28a
90 changed files with 509 additions and 457 deletions
|
|
@ -1,9 +1,10 @@
|
|||
package mage.constants;
|
||||
|
||||
import mage.util.SubTypeList;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import mage.util.SubTypeList;
|
||||
|
||||
public enum SubType {
|
||||
|
||||
|
|
@ -427,8 +428,8 @@ public enum SubType {
|
|||
return subTypes;
|
||||
}
|
||||
|
||||
public static Set<String> getBasicLands(boolean customSet) {
|
||||
return Arrays.stream(values()).filter(s -> s.customSet == customSet).filter(p -> p.getSubTypeSet() == SubTypeSet.BasicLandType).map(SubType::getDescription).collect(Collectors.toSet());
|
||||
public static Set<SubType> getBasicLands(boolean customSet) {
|
||||
return Arrays.stream(values()).filter(s -> s.customSet == customSet).filter(p -> p.getSubTypeSet() == SubTypeSet.BasicLandType).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public static SubTypeList getLandTypes(boolean customSet) {
|
||||
|
|
|
|||
|
|
@ -7,9 +7,12 @@ package mage.filter;
|
|||
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.filter.common.*;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.filter.predicate.mageobject.SupertypePredicate;
|
||||
import mage.filter.predicate.permanent.AnotherPredicate;
|
||||
import mage.filter.predicate.permanent.AttackingPredicate;
|
||||
import mage.filter.predicate.permanent.TokenPredicate;
|
||||
|
|
@ -64,6 +67,26 @@ public final class StaticFilters {
|
|||
|
||||
public static final FilterPermanent FILTER_ATTACKING_CREATURES = new FilterCreaturePermanent("attacking creatures");
|
||||
|
||||
|
||||
|
||||
public static final FilterPermanent FILTER_AURA = new FilterPermanent();
|
||||
public static final FilterPermanent FILTER_EQUIPMENT = new FilterPermanent();
|
||||
public static final FilterPermanent FILTER_FORTIFICATION = new FilterPermanent();
|
||||
public static final FilterPermanent FILTER_LEGENDARY = new FilterPermanent();
|
||||
|
||||
static {
|
||||
FILTER_AURA.add(new CardTypePredicate(CardType.ENCHANTMENT));
|
||||
FILTER_AURA.add(new SubtypePredicate(SubType.AURA));
|
||||
|
||||
FILTER_EQUIPMENT.add(new CardTypePredicate(CardType.ARTIFACT));
|
||||
FILTER_EQUIPMENT.add(new SubtypePredicate(SubType.EQUIPMENT));
|
||||
|
||||
FILTER_FORTIFICATION.add(new CardTypePredicate(CardType.ARTIFACT));
|
||||
FILTER_FORTIFICATION.add(new SubtypePredicate(SubType.FORTIFICATION));
|
||||
|
||||
FILTER_LEGENDARY.add(new SupertypePredicate(SuperType.LEGENDARY));
|
||||
}
|
||||
|
||||
static {
|
||||
FILTER_CONTROLLED_PERMANENT_NON_LAND.add(
|
||||
Predicates.not(new CardTypePredicate(CardType.LAND)));
|
||||
|
|
|
|||
|
|
@ -54,9 +54,9 @@ import mage.designations.Monarch;
|
|||
import mage.filter.Filter;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.common.FilterPlaneswalkerPermanent;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.filter.predicate.mageobject.SupertypePredicate;
|
||||
|
|
@ -103,24 +103,6 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
|
||||
private static final Logger logger = Logger.getLogger(GameImpl.class);
|
||||
|
||||
private static final FilterPermanent FILTER_AURA = new FilterPermanent();
|
||||
private static final FilterPermanent FILTER_EQUIPMENT = new FilterPermanent();
|
||||
private static final FilterPermanent FILTER_FORTIFICATION = new FilterPermanent();
|
||||
private static final FilterPermanent FILTER_LEGENDARY = new FilterPermanent();
|
||||
|
||||
static {
|
||||
FILTER_AURA.add(new CardTypePredicate(CardType.ENCHANTMENT));
|
||||
FILTER_AURA.add(new SubtypePredicate(SubType.AURA));
|
||||
|
||||
FILTER_EQUIPMENT.add(new CardTypePredicate(CardType.ARTIFACT));
|
||||
FILTER_EQUIPMENT.add(new SubtypePredicate(SubType.EQUIPMENT));
|
||||
|
||||
FILTER_FORTIFICATION.add(new CardTypePredicate(CardType.ARTIFACT));
|
||||
FILTER_FORTIFICATION.add(new SubtypePredicate(SubType.FORTIFICATION));
|
||||
|
||||
FILTER_LEGENDARY.add(new SupertypePredicate(SuperType.LEGENDARY));
|
||||
}
|
||||
|
||||
private transient Object customData;
|
||||
protected boolean simulation = false;
|
||||
|
||||
|
|
@ -1784,7 +1766,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
if (perm.isWorld()) {
|
||||
worldEnchantment.add(perm);
|
||||
}
|
||||
if (FILTER_AURA.match(perm, this)) {
|
||||
if (StaticFilters.FILTER_AURA.match(perm, this)) {
|
||||
//20091005 - 704.5n, 702.14c
|
||||
if (perm.getAttachedTo() == null) {
|
||||
Card card = this.getCard(perm.getId());
|
||||
|
|
@ -1862,10 +1844,10 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (this.getState().isLegendaryRuleActive() && FILTER_LEGENDARY.match(perm, this)) {
|
||||
if (this.getState().isLegendaryRuleActive() && StaticFilters.FILTER_LEGENDARY.match(perm, this)) {
|
||||
legendary.add(perm);
|
||||
}
|
||||
if (FILTER_EQUIPMENT.match(perm, this)) {
|
||||
if (StaticFilters.FILTER_EQUIPMENT.match(perm, this)) {
|
||||
//20091005 - 704.5p, 702.14d
|
||||
if (perm.getAttachedTo() != null) {
|
||||
Permanent attachedTo = getPermanent(perm.getAttachedTo());
|
||||
|
|
@ -1890,7 +1872,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (FILTER_FORTIFICATION.match(perm, this)) {
|
||||
if (StaticFilters.FILTER_FORTIFICATION.match(perm, this)) {
|
||||
if (perm.getAttachedTo() != null) {
|
||||
Permanent land = getPermanent(perm.getAttachedTo());
|
||||
if (land == null || !land.getAttachments().contains(perm.getId())) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue