pub struct TargetRestrictions {
pub valid_tgts: Vec<String>,
pub valid_tgts_selector: CompiledSelector,
pub target_kind: TargetKind,
pub target_type_filter: Option<String>,
pub min_targets: String,
pub max_targets: String,
pub tgt_zone: Vec<ZoneType>,
}Expand description
Targeting restrictions for a spell ability.
Mirrors Java’s TargetRestrictions — defines valid targets, min/max counts,
and which zones to search for targets.
Fields§
§valid_tgts: Vec<String>Raw valid target strings (e.g. [“Creature.OppCtrl”])
valid_tgts_selector: CompiledSelectorCompiled ValidTgts selector used for card target filtering.
target_kind: TargetKindParsed target kind
target_type_filter: Option<String>Additional target type filter (e.g. “Spell” from TargetType$ parameter)
min_targets: StringMinimum number of targets expression (default “1”).
Mirrors Java storing raw TargetMin and resolving dynamically.
max_targets: StringMaximum number of targets expression (default “1”).
Mirrors Java storing raw TargetMax and resolving dynamically.
tgt_zone: Vec<ZoneType>Zones to search for targets (default [Battlefield])
Implementations§
Source§impl TargetRestrictions
impl TargetRestrictions
pub fn new_from_parsed( parsed: &ParsedParams<'_>, params: &Params, ) -> Option<Self>
Sourcepub fn new(params: &Params) -> Option<Self>
pub fn new(params: &Params) -> Option<Self>
Construct from parsed pipe params. Returns None if no ValidTgts$
parameter exists (mirrors Java: null targetRestrictions means no targeting).
Sourcepub fn has_candidates(
&self,
game: &GameState,
player: PlayerId,
source_card: Option<CardId>,
) -> bool
pub fn has_candidates( &self, game: &GameState, player: PlayerId, source_card: Option<CardId>, ) -> bool
Check if there is at least one valid target candidate.
Accounts for Hexproof, Shroud, and Protection when source_card is provided.
Mirrors Java’s TargetRestrictions.hasCandidates().
Sourcepub fn get_min_targets(&self, game: &GameState, sa: &SpellAbility) -> i32
pub fn get_min_targets(&self, game: &GameState, sa: &SpellAbility) -> i32
Resolve Java-style TargetMin expression for this SA.
Sourcepub fn get_max_targets(&self, game: &GameState, sa: &SpellAbility) -> i32
pub fn get_max_targets(&self, game: &GameState, sa: &SpellAbility) -> i32
Resolve Java-style TargetMax expression for this SA.
Sourcepub fn can_only_tgt_opponent(&self) -> bool
pub fn can_only_tgt_opponent(&self) -> bool
Whether targeting is restricted to opponents only.
Mirrors Java’s TargetRestrictions.canOnlyTgtOpponent().
Sourcepub fn can_tgt_player(&self) -> bool
pub fn can_tgt_player(&self) -> bool
Whether this can target a player.
Mirrors Java’s TargetRestrictions.canTgtPlayer().
Sourcepub fn can_tgt_permanent(&self) -> bool
pub fn can_tgt_permanent(&self) -> bool
Whether this can target a permanent.
Mirrors Java’s TargetRestrictions.canTgtPermanent().
Sourcepub fn can_tgt_creature(&self) -> bool
pub fn can_tgt_creature(&self) -> bool
Whether this can target a creature.
Mirrors Java’s TargetRestrictions.canTgtCreature().
Sourcepub fn can_tgt_planeswalker(&self) -> bool
pub fn can_tgt_planeswalker(&self) -> bool
Whether this can target a planeswalker.
Mirrors Java’s TargetRestrictions.canTgtPlaneswalker().
Sourcepub fn can_tgt_creature_and_player(&self) -> bool
pub fn can_tgt_creature_and_player(&self) -> bool
Whether this can target both a creature and a player.
Mirrors Java’s TargetRestrictions.canTgtCreatureAndPlayer().
Sourcepub fn copy(&self) -> Self
pub fn copy(&self) -> Self
Clone this target restriction.
Mirrors Java’s TargetRestrictions.copy().
Sourcepub fn apply_target_text_changes(&mut self, changes: &[(&str, &str)])
pub fn apply_target_text_changes(&mut self, changes: &[(&str, &str)])
Apply text changes to the target restriction strings.
Mirrors Java’s TargetRestrictions.applyTargetTextChanges(Map).
Trait Implementations§
Source§impl Clone for TargetRestrictions
impl Clone for TargetRestrictions
Source§fn clone(&self) -> TargetRestrictions
fn clone(&self) -> TargetRestrictions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more