finally made DustOfMoments to work, CounterPredicate didn't see counters for Chronozoa (permanent). why the hell is PermanentImpl.getCounters() and CardImpl.getCounters(game) don't return the same value for the same card

This commit is contained in:
glerman 2015-07-03 02:10:06 +03:00 committed by Gal Lerman
parent 45e269de77
commit afe9c27aa5
3 changed files with 225 additions and 18 deletions

View file

@ -0,0 +1,36 @@
package mage.filter.predicate.permanent;
import mage.cards.Card;
import mage.counters.CounterType;
import mage.filter.predicate.Predicate;
import mage.game.Game;
/**
* Created by glerman on 3/7/15.
*/
public class CardCounterPredicate implements Predicate<Card>{
private final CounterType counter;
/**
*
* @param counter if null any counter selects the permanent
*/
public CardCounterPredicate(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() + ')';
}
}