Skip to main content

Module valid_filter

Module valid_filter 

Source
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§

CardTraitRequirementsIr
Typed requirement bag for Java CardTraitBase.meetsCommonRequirements(params).
MatchContext

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 valid is 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, and ExiledWithSource.
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.