use forge_foundation::ZoneType;
use crate::game::GameState;
use crate::spellability::SpellAbility;
pub fn can_play(sa: &SpellAbility, game: &GameState) -> bool {
if sa.ir.unpayable {
return false;
}
if !sa.is_mana_ability && super::has_split_second_on_stack(game) {
return false;
}
if is_suppressed(sa, game) {
return false;
}
if is_detained(sa, game) {
return false;
}
check_restrictions(sa, game)
}
pub fn is_possible_activated(sa: &SpellAbility, game: &GameState) -> bool {
let card_id = match sa.source {
Some(id) => id,
None => return false,
};
if !game.card_is_in_zone(card_id, ZoneType::Battlefield) {
return false;
}
let player = game.player(sa.activating_player);
if !player.is_alive() {
return false;
}
true
}
pub fn check_restrictions(sa: &SpellAbility, game: &GameState) -> bool {
sa.can_play(game)
}
pub fn prompt_if_only_possible_ability() -> bool {
false
}
pub fn is_suppressed(sa: &SpellAbility, game: &GameState) -> bool {
let card_id = match sa.source {
Some(id) => id,
None => return false,
};
let card = game.card(card_id);
let card_name = &card.card_name;
for &pid in &game.player_order {
if pid == sa.activating_player {
continue;
}
for &cid in game.cards_in_zone(ZoneType::Battlefield, pid) {
let perm = game.card(cid);
if let Some(named) = perm.get_s_var("ChosenName") {
if named.eq_ignore_ascii_case(card_name)
&& perm.has_keyword("Suppress activated abilities")
{
return true;
}
}
}
}
false
}
pub fn is_detained(sa: &SpellAbility, game: &GameState) -> bool {
let card_id = match sa.source {
Some(id) => id,
None => return false,
};
let card = game.card(card_id);
card.has_keyword("HIDDEN Detained")
}