mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 12:02:01 -08:00
[filters][refactoring] Minor changes to Predicates
This commit is contained in:
parent
2198cae333
commit
dcfd5ece0c
11 changed files with 23 additions and 23 deletions
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
package mage.filter;
|
package mage.filter;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.filter.predicate.Predicate;
|
import mage.filter.predicate.Predicate;
|
||||||
|
|
@ -44,7 +44,7 @@ public abstract class FilterImpl<E, T extends FilterImpl<E, T>> implements Filte
|
||||||
protected static ListComparer<CardType> compCardType = new ListComparer<CardType>();
|
protected static ListComparer<CardType> compCardType = new ListComparer<CardType>();
|
||||||
protected static ListComparer<String> compString = new ListComparer<String>();
|
protected static ListComparer<String> compString = new ListComparer<String>();
|
||||||
|
|
||||||
protected List<Predicate> predicates = new LinkedList<Predicate>();
|
protected List<Predicate> predicates = new ArrayList<Predicate>();
|
||||||
protected String message;
|
protected String message;
|
||||||
protected boolean notFilter = false;
|
protected boolean notFilter = false;
|
||||||
|
|
||||||
|
|
@ -58,7 +58,7 @@ public abstract class FilterImpl<E, T extends FilterImpl<E, T>> implements Filte
|
||||||
public FilterImpl(FilterImpl filter) {
|
public FilterImpl(FilterImpl filter) {
|
||||||
this.message = filter.message;
|
this.message = filter.message;
|
||||||
this.notFilter = filter.notFilter;
|
this.notFilter = filter.notFilter;
|
||||||
this.predicates = new LinkedList<Predicate>(filter.predicates);
|
this.predicates = new ArrayList<Predicate>(filter.predicates);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ import mage.game.Game;
|
||||||
*
|
*
|
||||||
* @author North
|
* @author North
|
||||||
*/
|
*/
|
||||||
public class AbilityPredicate<T extends MageObject> implements Predicate<T> {
|
public class AbilityPredicate implements Predicate<MageObject> {
|
||||||
|
|
||||||
private final Class<?> abilityClass;
|
private final Class<?> abilityClass;
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@ public class AbilityPredicate<T extends MageObject> implements Predicate<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(T input, Game game) {
|
public boolean apply(MageObject input, Game game) {
|
||||||
Abilities<Ability> abilities = input.getAbilities();
|
Abilities<Ability> abilities = input.getAbilities();
|
||||||
for (int i = 0; i < abilities.size(); i++) {
|
for (int i = 0; i < abilities.size(); i++) {
|
||||||
if (abilityClass.equals(abilities.get(i).getClass())) {
|
if (abilityClass.equals(abilities.get(i).getClass())) {
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ import mage.game.Game;
|
||||||
*
|
*
|
||||||
* @author North
|
* @author North
|
||||||
*/
|
*/
|
||||||
public class CardTypePredicate<T extends MageObject> implements Predicate<T> {
|
public class CardTypePredicate implements Predicate<MageObject> {
|
||||||
|
|
||||||
private final CardType cardType;
|
private final CardType cardType;
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ public class CardTypePredicate<T extends MageObject> implements Predicate<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(T input, Game game) {
|
public boolean apply(MageObject input, Game game) {
|
||||||
return input.getCardType().contains(cardType);
|
return input.getCardType().contains(cardType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ import mage.game.Game;
|
||||||
*
|
*
|
||||||
* @author North
|
* @author North
|
||||||
*/
|
*/
|
||||||
public class ColorPredicate<T extends MageObject> implements Predicate<T> {
|
public class ColorPredicate implements Predicate<MageObject> {
|
||||||
|
|
||||||
private final ObjectColor color;
|
private final ObjectColor color;
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ public class ColorPredicate<T extends MageObject> implements Predicate<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(T input, Game game) {
|
public boolean apply(MageObject input, Game game) {
|
||||||
return input.getColor().contains(color);
|
return input.getColor().contains(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,10 +35,10 @@ import mage.game.Game;
|
||||||
*
|
*
|
||||||
* @author North
|
* @author North
|
||||||
*/
|
*/
|
||||||
public class ColorlessPredicate<T extends MageObject> implements Predicate<T> {
|
public class ColorlessPredicate implements Predicate<MageObject> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(T input, Game game) {
|
public boolean apply(MageObject input, Game game) {
|
||||||
return input.getColor().isColorless();
|
return input.getColor().isColorless();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,14 @@ import mage.filter.predicate.IntComparePredicate;
|
||||||
*
|
*
|
||||||
* @author North
|
* @author North
|
||||||
*/
|
*/
|
||||||
public class ConvertedManaCostPredicate<T extends MageObject> extends IntComparePredicate<T> {
|
public class ConvertedManaCostPredicate extends IntComparePredicate<MageObject> {
|
||||||
|
|
||||||
public ConvertedManaCostPredicate(Filter.ComparisonType type, int value) {
|
public ConvertedManaCostPredicate(Filter.ComparisonType type, int value) {
|
||||||
super(type, value);
|
super(type, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getInputValue(T input) {
|
protected int getInputValue(MageObject input) {
|
||||||
return input.getManaCost().convertedManaCost();
|
return input.getManaCost().convertedManaCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ import mage.game.Game;
|
||||||
*
|
*
|
||||||
* @author North
|
* @author North
|
||||||
*/
|
*/
|
||||||
public class NamePredicate<T extends MageObject> implements Predicate<T> {
|
public class NamePredicate implements Predicate<MageObject> {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@ public class NamePredicate<T extends MageObject> implements Predicate<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(T input, Game game) {
|
public boolean apply(MageObject input, Game game) {
|
||||||
return name.equals(input.getName());
|
return name.equals(input.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,14 @@ import mage.filter.predicate.IntComparePredicate;
|
||||||
*
|
*
|
||||||
* @author North
|
* @author North
|
||||||
*/
|
*/
|
||||||
public class PowerPredicate<T extends MageObject> extends IntComparePredicate<T> {
|
public class PowerPredicate extends IntComparePredicate<MageObject> {
|
||||||
|
|
||||||
public PowerPredicate(Filter.ComparisonType type, int value) {
|
public PowerPredicate(Filter.ComparisonType type, int value) {
|
||||||
super(type, value);
|
super(type, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getInputValue(T input) {
|
protected int getInputValue(MageObject input) {
|
||||||
return input.getPower().getValue();
|
return input.getPower().getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ import mage.game.Game;
|
||||||
*
|
*
|
||||||
* @author North
|
* @author North
|
||||||
*/
|
*/
|
||||||
public class SubtypePredicate<T extends MageObject> implements Predicate<T> {
|
public class SubtypePredicate implements Predicate<MageObject> {
|
||||||
|
|
||||||
private final String subtype;
|
private final String subtype;
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@ public class SubtypePredicate<T extends MageObject> implements Predicate<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(T input, Game game) {
|
public boolean apply(MageObject input, Game game) {
|
||||||
return input.getSubtype().contains(subtype);
|
return input.getSubtype().contains(subtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ import mage.game.Game;
|
||||||
*
|
*
|
||||||
* @author North
|
* @author North
|
||||||
*/
|
*/
|
||||||
public class SupertypePredicate<T extends MageObject> implements Predicate<T> {
|
public class SupertypePredicate implements Predicate<MageObject> {
|
||||||
|
|
||||||
private final String supertype;
|
private final String supertype;
|
||||||
|
|
||||||
|
|
@ -44,7 +44,7 @@ public class SupertypePredicate<T extends MageObject> implements Predicate<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(T input, Game game) {
|
public boolean apply(MageObject input, Game game) {
|
||||||
return input.getSupertype().contains(supertype);
|
return input.getSupertype().contains(supertype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,14 @@ import mage.filter.predicate.IntComparePredicate;
|
||||||
*
|
*
|
||||||
* @author North
|
* @author North
|
||||||
*/
|
*/
|
||||||
public class ToughnessPredicate<T extends MageObject> extends IntComparePredicate<T> {
|
public class ToughnessPredicate extends IntComparePredicate<MageObject> {
|
||||||
|
|
||||||
public ToughnessPredicate(Filter.ComparisonType type, int value) {
|
public ToughnessPredicate(Filter.ComparisonType type, int value) {
|
||||||
super(type, value);
|
super(type, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getInputValue(T input) {
|
protected int getInputValue(MageObject input) {
|
||||||
return input.getToughness().getValue();
|
return input.getToughness().getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue