// TODO: simplify
/// Ticks and kills all the lasting effects.
simplify
Ticks and kills all the lasting effects.
simplify Ticks and kills all the lasting effects .
fn execute_effects(state: &mut State, cb: Cb) {
    let phase = Phase::from_player_id(state.player_id());
    for id in state.parts().effects.ids_collected() {
        for effect in &state.parts().effects.get(id).0.clone() {
            if effect.phase != phase {
                continue;
            }
            assert!(state.parts().is_exist(id));
            {
                let active_event = event::EffectTick {
                    id,
                    effect: effect.effect,
                };
                let mut target_effects = Vec::new();
                match effect.effect {
                    effect::Lasting::Poison => {
                        let strength = state.parts().strength.get(id).strength;
                        if strength > battle::Strength(1) {
                            let damage = battle::Strength(1);
                            target_effects.push(wound_or_kill(state, id, damage));
                        }
                    }
                    effect::Lasting::Stun => {
                        target_effects.push(Effect::Stun);
                    }
                    effect::Lasting::Bloodlust => target_effects.push(Effect::Bloodlust),
                }
                let instant_effects = vec![(id, target_effects)];
                let event = Event {
                    active_event: ActiveEvent::EffectTick(active_event),
                    actor_ids: vec![id],
                    instant_effects,
                    timed_effects: Vec::new(),
                    scheduled_abilities: Vec::new(),
                };
                do_event(state, cb, &event);
            }
            if !state.parts().is_exist(id) {
                break;
            }
            if state::is_lasting_effect_over(state, id, effect) {
                let active_event = event::EffectEnd {
                    id,
                    effect: effect.effect,
                };
                let event = Event {
                    active_event: ActiveEvent::EffectEnd(active_event),
                    actor_ids: vec![id],
                    instant_effects: Vec::new(),
                    timed_effects: Vec::new(),
                    scheduled_abilities: Vec::new(),
                };
                do_event(state, cb, &event);
            }
        }
        if !state.parts().is_exist(id) {
            continue;
        }
    }
}
fn execute_effects ( state : & mut State , cb : Cb ) { let phase = Phase :: from_player_id ( state . player_id ( ) ) ; for id in state . parts ( ) . effects . ids_collected ( ) { for effect in & state . parts ( ) . effects . get ( id ) . 0 . clone ( ) { if effect . phase != phase { continue ; } assert ! ( state parts ( ) is_exist ( id ) ) ; { let active_event = event :: EffectTick { id , effect : effect . effect , } ; let mut target_effects = Vec :: new ( ) ; match effect . effect { effect :: Lasting :: Poison => { let strength = state . parts ( ) . strength . get ( id ) . strength ; if strength > battle :: Strength ( 1 ) { let damage = battle :: Strength ( 1 ) ; target_effects . push ( wound_or_kill ( state , id , damage ) ) ; } } effect :: Lasting :: Stun => { target_effects . push ( Effect :: Stun ) ; } effect :: Lasting :: Bloodlust => target_effects . push ( Effect :: Bloodlust ) , } let instant_effects = vec ! [ ( id target_effects ) ] ; let event = Event { active_event : ActiveEvent :: EffectTick ( active_event ) , actor_ids : vec ! [ id ] , instant_effects , timed_effects : Vec :: new ( ) , scheduled_abilities : Vec :: new ( ) , } ; do_event ( state , cb , & event ) ; } if ! state . parts ( ) . is_exist ( id ) { break ; } if state :: is_lasting_effect_over ( state , id , effect ) { let active_event = event :: EffectEnd { id , effect : effect . effect , } ; let event = Event { active_event : ActiveEvent :: EffectEnd ( active_event ) , actor_ids : vec ! [ id ] , instant_effects : Vec :: new ( ) , timed_effects : Vec :: new ( ) , scheduled_abilities : Vec :: new ( ) , } ; do_event ( state , cb , & event ) ; } } if ! state . parts ( ) . is_exist ( id ) { continue ; } } }
TODO: simplify
Ticks and kills all the lasting effects.
TODO : simplify Ticks and kills all the lasting effects .
state
&mut State
cb
Cb