better duplicate ko check

This commit is contained in:
Mashy 2019-11-13 19:04:25 +10:00
parent 7d253ab65d
commit c99f189c69

View File

@ -299,9 +299,9 @@ pub fn resolve(skill: Skill, source: &mut Construct, target: &mut Construct, mut
}
fn post_resolve(_skill: Skill, game: &mut Game, mut resolutions: Resolutions) -> Resolutions {
for Resolution { source, target, event, stages: _ } in resolutions.clone() {
for Resolution { source, target: event_target, event, stages: _ } in resolutions.clone() {
let mut source = game.construct_by_id(source.id).unwrap().clone();
let mut target = game.construct_by_id(target.id).unwrap().clone();
let mut target = game.construct_by_id(event_target.id).unwrap().clone();
match event {
Event::Damage { amount, skill, mitigation, colour: c } => {
@ -352,18 +352,14 @@ fn post_resolve(_skill: Skill, game: &mut Game, mut resolutions: Resolutions) ->
_ => (),
};
if target.is_ko() {
if target.is_ko() && event_target.green == 0 {
// Check target is actually ko if sending ko event
target.effects.clear();
resolutions.push(Resolution::new(&source, &target).event(Event::Ko()).stages(EventStages::PostOnly));
}
game.update_construct(&mut source);
game.update_construct(&mut target);
if target.is_ko() {
// Don't loop for multiple resolutions which led to KO
break;
}
};
return resolutions;