mirror of
https://github.com/correl/mage.git
synced 2024-11-29 03:00:12 +00:00
Tests: added check that filter card must not contain controller predicate;
This commit is contained in:
parent
8a7f31b215
commit
69e52815b6
1 changed files with 14 additions and 4 deletions
|
@ -1,10 +1,8 @@
|
||||||
package mage.filter;
|
package mage.filter;
|
||||||
|
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.filter.predicate.ObjectPlayer;
|
import mage.constants.TargetController;
|
||||||
import mage.filter.predicate.ObjectPlayerPredicate;
|
import mage.filter.predicate.*;
|
||||||
import mage.filter.predicate.ObjectSourcePlayer;
|
|
||||||
import mage.filter.predicate.Predicates;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -71,6 +69,9 @@ public class FilterCard extends FilterObject<Card> {
|
||||||
if (isLockedFilter()) {
|
if (isLockedFilter()) {
|
||||||
throw new UnsupportedOperationException("You may not modify a locked filter");
|
throw new UnsupportedOperationException("You may not modify a locked filter");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkPredicateIsSuitableForCardFilter(predicate);
|
||||||
|
|
||||||
extraPredicates.add(predicate);
|
extraPredicates.add(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,4 +87,13 @@ public class FilterCard extends FilterObject<Card> {
|
||||||
public FilterCard copy() {
|
public FilterCard copy() {
|
||||||
return new FilterCard(this);
|
return new FilterCard(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void checkPredicateIsSuitableForCardFilter(Predicate predicate) {
|
||||||
|
// card filter can't contain controller predicate (only permanents on battlefield have controller)
|
||||||
|
List<Predicate> list = new ArrayList<>();
|
||||||
|
Predicates.collectAllComponents(predicate, list);
|
||||||
|
if (list.stream().anyMatch(p -> p instanceof TargetController.ControllerPredicate)) {
|
||||||
|
throw new IllegalArgumentException("Card filter doesn't support controller predicate");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue