pub struct AttackRequirement {
pub attacker: CardId,
pub must_attack_any: bool,
pub must_attack_defender: Option<PlayerId>,
pub goaded_by: Option<PlayerId>,
pub defender_specific: HashMap<DefenderId, i32>,
}Expand description
Represents a requirement for a creature to attack.
Mirrors Java’s AttackRequirement.java.
Fields§
§attacker: CardIdThe creature that must attack.
must_attack_any: boolTrue if the creature must attack any legal defender.
must_attack_defender: Option<PlayerId>If set, the creature must attack this specific defender (if able).
goaded_by: Option<PlayerId>The player that goaded this creature (it can’t attack that player).
defender_specific: HashMap<DefenderId, i32>Per-defender requirement counts: defender → number of reasons to attack it.
Mirrors Java’s defenderSpecific map.
Implementations§
Source§impl AttackRequirement
impl AttackRequirement
Sourcepub fn has_requirement(&self) -> bool
pub fn has_requirement(&self) -> bool
Mirrors Java’s hasRequirement().
Returns true if this creature has any reason it must attack.
Sourcepub fn count_violations(&self, defender: Option<DefenderId>) -> i32
pub fn count_violations(&self, defender: Option<DefenderId>) -> i32
Mirrors Java’s countViolations().
Count how many attack requirements are violated if this creature is
attacking defender (or None if not attacking at all).
Sourcepub fn get_sorted_requirements(&self) -> Vec<(DefenderId, i32)>
pub fn get_sorted_requirements(&self) -> Vec<(DefenderId, i32)>
Get sorted requirements: (defender, count) pairs sorted ascending.
Mirrors Java’s getSortedRequirements().
Trait Implementations§
Source§impl Clone for AttackRequirement
impl Clone for AttackRequirement
Source§fn clone(&self) -> AttackRequirement
fn clone(&self) -> AttackRequirement
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more