PlayerZone: rewrite the Filter to remove use of "May be played" keywords. "may look" keywords might be removed later too.

This commit is contained in:
Hanmac
2016-07-27 16:55:21 +00:00
parent 697e3ed123
commit 87270ec3db

View File

@@ -38,15 +38,16 @@ public class PlayerZone extends Zone {
private static final long serialVersionUID = -5687652485777639176L;
// the this is not the owner of the card
private final class AlienCardsActivationFilter implements Predicate<Card> {
private static Predicate<Card> alienCardsActivationFilter(final Player who) {
return new Predicate<Card>() {
@Override
public boolean apply(final Card c) {
if (c.hasStartOfKeyword("May be played by your opponent")
|| c.hasKeyword("Your opponent may look at this card.")) {
if (c.mayPlay(who) != null || c.hasKeyword("Your opponent may look at this card.")) {
return true;
}
return false;
}
};
}
private final class OwnCardsActivationFilter implements Predicate<Card> {
@@ -56,7 +57,7 @@ public class PlayerZone extends Zone {
return true;
}
if (c.isLand() && (c.hasKeyword("May be played") || c.hasKeyword("May be played without paying its mana cost"))) {
if (c.isLand() && (c.mayPlay(c.getController()) != null)) {
return true;
}
@@ -67,7 +68,7 @@ public class PlayerZone extends Zone {
}
if (sa.isSpell()
&& (c.hasKeyword("May be played") || c.hasKeyword("May be played without paying its mana cost")
&& (c.mayPlay(c.getController()) != null
|| (c.hasStartOfKeyword("Flashback") && PlayerZone.this.is(ZoneType.Graveyard)))
&& restrictZone.equals(ZoneType.Hand)) {
return true;
@@ -112,7 +113,7 @@ public class PlayerZone extends Zone {
cards = Iterables.limit(cards, 1);
}
final Predicate<Card> filterPredicate = checkingForOwner ? new OwnCardsActivationFilter() : new AlienCardsActivationFilter();
final Predicate<Card> filterPredicate = checkingForOwner ? new OwnCardsActivationFilter() : alienCardsActivationFilter(who);
return CardLists.filter(cl, filterPredicate);
}
}