manabrew_engine/staticability/
static_ability_cant_transform.rs1use crate::card::{valid_filter, Card};
2use crate::spellability::SpellAbility;
3use crate::staticability::StaticMode;
4
5pub fn cant_transform(cards: &[Card], card: &Card, cause: Option<&SpellAbility>) -> bool {
6 for source in cards.iter().filter(|c| c.zone.is_static_ability_source()) {
7 for st_ab in source
8 .static_abilities
9 .iter()
10 .filter(|sa| sa.check_mode(&StaticMode::CantTransform) && sa.zones_check(source.zone))
11 {
12 if apply_cant_transform_ability(st_ab, card, source, cause) {
13 return true;
14 }
15 }
16 }
17 false
18}
19
20pub fn apply_cant_transform_ability(
21 st_ab: &crate::staticability::StaticAbility,
22 card: &Card,
23 source: &Card,
24 cause: Option<&SpellAbility>,
25) -> bool {
26 if !valid_filter::matches_valid_card_selector_opt(st_ab.ir.valid_card.as_ref(), card, source) {
27 return false;
28 }
29 if let Some(except_cause) = st_ab.ir.except_cause_text.as_deref() {
31 if let Some(cause) = cause {
32 if matches_except_cause(except_cause, cause) {
33 return false;
34 }
35 }
36 }
37 true
38}
39
40fn matches_except_cause(except_cause: &str, cause: &SpellAbility) -> bool {
45 super::static_ability_cant_sacrifice::matches_valid_cause(Some(except_cause), Some(cause))
46}