mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
tests: added verify test to check miss of controlled filter in equip abilities (related to #11473);
This commit is contained in:
parent
a4c90d9b71
commit
3a92d67d10
9 changed files with 68 additions and 9 deletions
|
|
@ -28,7 +28,10 @@ import mage.choices.Choice;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.game.command.Dungeon;
|
||||
import mage.game.command.Plane;
|
||||
import mage.game.draft.DraftCube;
|
||||
|
|
@ -2064,6 +2067,25 @@ public class VerifyCardDataTest {
|
|||
}
|
||||
}
|
||||
|
||||
// special check: equip abilities must have controlled predicate due rules
|
||||
List<EquipAbility> equipAbilities = card.getAbilities()
|
||||
.stream()
|
||||
.filter(a -> a instanceof EquipAbility)
|
||||
.map(a -> (EquipAbility) a)
|
||||
.collect(Collectors.toList());
|
||||
equipAbilities.forEach(a -> {
|
||||
List<Predicate> allPredicates = new ArrayList<>();
|
||||
a.getTargets().forEach(t -> Predicates.collectAllComponents(t.getFilter().getPredicates(), t.getFilter().getExtraPredicates(), allPredicates));
|
||||
boolean hasControlledFilter = allPredicates
|
||||
.stream()
|
||||
.filter(p -> p instanceof TargetController.ControllerPredicate)
|
||||
.map(p -> ((TargetController.ControllerPredicate) p).getController())
|
||||
.anyMatch(tc -> tc.equals(TargetController.YOU));
|
||||
if (!hasControlledFilter) {
|
||||
fail(card, "abilities", "card has equip ability, but it doesn't use controllered filter - " + a.getRule());
|
||||
}
|
||||
});
|
||||
|
||||
// spells have only 1 ability
|
||||
if (card.isInstantOrSorcery()) {
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue