Expand description
Shared card/player filter matching used across triggers, static abilities, replacement effects, and combat. Consolidates 34 duplicate implementations.
This module provides canonical implementations for matching cards and players against filter expressions like “Creature.YouCtrl” or “Opponent”.
Filter Syntax:
Card filters are dot-separated: “Creature.YouCtrl.nonToken”
- Comma separates OR conditions: “Creature,Artifact” matches either
- Dot separates qualifiers: “Creature.YouCtrl” matches creatures you control
- Plus separates compound conditions: “YouCtrl+kicked” matches both
Type parts:
- Card, Permanent, Creature, Land, Artifact, Enchantment, Planeswalker, Instant, Sorcery
- Subtypes: “Zombie”, “Wall”, “Forest”, etc.
Qualifiers:
- Controller: YouCtrl, OppCtrl, YouControl, OpponentCtrl
- Self: Self, Other, StrictlyOther
- Token: token, nonToken
- Type negation: nonCreature, nonLand
- State: tapped, untapped, kicked
- Counters: counters_GE3_P1P1, counters_EQ1_Charge
- CMC: cmcEQ1, cmcLE3, cmcGE5
- Color: White, Blue, Black, Red, Green, Colorless, multicolor
- Combat: DamagedBy
- Attachment: EnchantedBy
Structs§
- Card
Trait Requirements Ir - Typed requirement bag for Java
CardTraitBase.meetsCommonRequirements(params). - Match
Context
Functions§
- check_
svar_ requirement - matches_
valid - Mirrors Java’s
CardTraitBase.matchesValid(Object, String[], Card, Player). - matches_
valid_ card - Check if a card matches a filter expression like “Creature.YouCtrl”.
Returns true if
validis empty or the card satisfies all parts. - matches_
valid_ card_ opt - Convenience wrapper: None means “no filter” → always matches.
- matches_
valid_ card_ selector - Match a precompiled selector against a card without reparsing the comma/dot/plus selector structure.
- matches_
valid_ card_ selector_ in_ game - matches_
valid_ card_ selector_ opt - Convenience wrapper: None means “no filter” -> always matches.
- matches_
valid_ card_ selector_ opt_ in_ game - matches_
valid_ card_ selector_ opt_ with_ context - matches_
valid_ card_ selector_ with_ context - Match a precompiled selector with explicit contextual state for predicates
like
Attacking,TopLibrary, andExiledWithSource. - matches_
valid_ player - Check if a player matches a filter expression like “You”, “Opponent”, “Each”.
- matches_
valid_ player_ opt - Convenience wrapper: None means “no filter” → always matches.
- matches_
valid_ player_ selector - Match a precompiled selector against a player without reparsing the comma-separated alternatives.
- matches_
valid_ player_ selector_ opt - Convenience wrapper: None means “no filter” -> always matches.