use crate::{
model::event::Event,
model::command::Command,
engine::core::GameEngine,
};
pub fn evaluate_triggers(
engine: &mut GameEngine,
event: &Event,
) -> Vec<Command> {
let mut commands = Vec::new();
let mut next_stack_id = engine.next_stack_id();
match event {
Event::CardMoved { card, to, .. } => {
if to.0.starts_with("field") {
if let Some(zone) = engine.state.zones.iter().find(|z| z.id == *to) {
if let Some(controller) = zone.owner {
let ability_commands = crate::engine::cards::generate_ability_commands(
*card,
"etb",
controller,
&engine.cards,
&mut next_stack_id,
);
commands.extend(ability_commands);
}
}
}
}
Event::CardPlayed { player, card } => {
let ability_commands = crate::engine::cards::generate_ability_commands(
*card,
"on_play",
*player,
&engine.cards,
&mut next_stack_id,
);
commands.extend(ability_commands);
}
_ => {
}
}
commands
}