mirror of
https://github.com/magefree/mage.git
synced 2025-12-27 05:52:06 -08:00
move CounterPredicate to be within CounterType class
This commit is contained in:
parent
b5370ecf32
commit
8876d39491
109 changed files with 162 additions and 277 deletions
|
|
@ -10,7 +10,6 @@ import mage.abilities.effects.Effect;
|
|||
import mage.constants.TargetController;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.permanent.CounterPredicate;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -22,7 +21,7 @@ public class BountyAbility extends DiesCreatureTriggeredAbility {
|
|||
|
||||
static {
|
||||
bountyCounterFilter.add(TargetController.OPPONENT.getControllerPredicate());
|
||||
bountyCounterFilter.add(new CounterPredicate(CounterType.BOUNTY));
|
||||
bountyCounterFilter.add(CounterType.BOUNTY.getPredicate());
|
||||
}
|
||||
|
||||
public BountyAbility(Effect effect) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package mage.counters;
|
||||
|
||||
import mage.abilities.keyword.*;
|
||||
import mage.cards.Card;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
* Enum for counters, names and instances.
|
||||
|
|
@ -160,10 +163,35 @@ public enum CounterType {
|
|||
WIND("wind"),
|
||||
WISH("wish");
|
||||
|
||||
private static class CounterPredicate implements Predicate<Card> {
|
||||
|
||||
private final CounterType counter;
|
||||
|
||||
private CounterPredicate(CounterType counter) {
|
||||
this.counter = counter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Card input, Game game) {
|
||||
if (counter == null) {
|
||||
return !input.getCounters(game).keySet().isEmpty();
|
||||
} else {
|
||||
return input.getCounters(game).containsKey(counter);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CounterType(" + counter.getName() + ')';
|
||||
}
|
||||
}
|
||||
|
||||
private final String name;
|
||||
private final CounterPredicate predicate;
|
||||
|
||||
CounterType(String name) {
|
||||
this.name = name;
|
||||
this.predicate = new CounterPredicate(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -249,4 +277,8 @@ public enum CounterType {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public CounterPredicate getPredicate() {
|
||||
return predicate;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
package mage.filter.predicate.permanent;
|
||||
|
||||
import mage.cards.Card;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public class CounterPredicate implements Predicate<Card> {
|
||||
|
||||
private final CounterType counter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param counter if null any counter selects the permanent
|
||||
*/
|
||||
public CounterPredicate(CounterType counter) {
|
||||
this.counter = counter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Card input, Game game) {
|
||||
if (counter == null) {
|
||||
return !input.getCounters(game).keySet().isEmpty();
|
||||
} else {
|
||||
return input.getCounters(game).containsKey(counter);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CounterType(" + counter.getName() + ')';
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue