mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00: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;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
import mage.util.SubTypeList;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -439,7 +442,30 @@ public enum SubType {
|
|||
YANLING("Yanling", SubTypeSet.PlaneswalkerType),
|
||||
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 String description;
|
||||
private final boolean customSet;
|
||||
private final SubTypePredicate predicate;
|
||||
|
||||
SubType(String description, SubTypeSet subTypeSet) {
|
||||
this(description, subTypeSet, false);
|
||||
|
@ -449,21 +475,22 @@ public enum SubType {
|
|||
this.description = description;
|
||||
this.subTypeSet = subTypeSet;
|
||||
this.customSet = customSet;
|
||||
this.predicate = new SubTypePredicate(this);
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
private final String description;
|
||||
|
||||
private final boolean customSet;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public SubTypePredicate getPredicate() {
|
||||
return predicate;
|
||||
}
|
||||
|
||||
public static SubType fromString(String value) {
|
||||
for (SubType st : SubType.values()) {
|
||||
if (st.toString().equals(value)) {
|
||||
|
|
Loading…
Reference in a new issue