mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08:00
moved SubTypePredicate into SubType
This commit is contained in:
parent
409aaf31b4
commit
3b8298e7c2
1 changed files with 31 additions and 4 deletions
|
|
@ -1,5 +1,8 @@
|
||||||
package mage.constants;
|
package mage.constants;
|
||||||
|
|
||||||
|
import mage.MageObject;
|
||||||
|
import mage.filter.predicate.Predicate;
|
||||||
|
import mage.game.Game;
|
||||||
import mage.util.SubTypeList;
|
import mage.util.SubTypeList;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
@ -439,7 +442,30 @@ public enum SubType {
|
||||||
YANLING("Yanling", SubTypeSet.PlaneswalkerType),
|
YANLING("Yanling", SubTypeSet.PlaneswalkerType),
|
||||||
YODA("Yoda", SubTypeSet.PlaneswalkerType, true); // Star Wars
|
YODA("Yoda", SubTypeSet.PlaneswalkerType, true); // Star Wars
|
||||||
|
|
||||||
|
public static class SubTypePredicate implements Predicate<MageObject> {
|
||||||
|
|
||||||
|
private final SubType subtype;
|
||||||
|
|
||||||
|
private SubTypePredicate(SubType subtype) {
|
||||||
|
this.subtype = subtype;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(MageObject input, Game game) {
|
||||||
|
return input.hasSubtype(subtype, game);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Subtype(" + subtype + ')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final SubTypeSet subTypeSet;
|
private final SubTypeSet subTypeSet;
|
||||||
|
private final String description;
|
||||||
|
private final boolean customSet;
|
||||||
|
private final SubTypePredicate predicate;
|
||||||
|
|
||||||
SubType(String description, SubTypeSet subTypeSet) {
|
SubType(String description, SubTypeSet subTypeSet) {
|
||||||
this(description, subTypeSet, false);
|
this(description, subTypeSet, false);
|
||||||
|
|
@ -449,21 +475,22 @@ public enum SubType {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.subTypeSet = subTypeSet;
|
this.subTypeSet = subTypeSet;
|
||||||
this.customSet = customSet;
|
this.customSet = customSet;
|
||||||
|
this.predicate = new SubTypePredicate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String description;
|
|
||||||
|
|
||||||
private final boolean customSet;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SubTypePredicate getPredicate() {
|
||||||
|
return predicate;
|
||||||
|
}
|
||||||
|
|
||||||
public static SubType fromString(String value) {
|
public static SubType fromString(String value) {
|
||||||
for (SubType st : SubType.values()) {
|
for (SubType st : SubType.values()) {
|
||||||
if (st.toString().equals(value)) {
|
if (st.toString().equals(value)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue