From 2d4f5e0a70f8da87eb7005e39d812378f8e7af75 Mon Sep 17 00:00:00 2001 From: Mashy Date: Fri, 3 Jan 2020 11:46:19 +1000 Subject: [PATCH] hybrid test --- core/src/game.rs | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/core/src/game.rs b/core/src/game.rs index 59a83d52..d35292d4 100644 --- a/core/src/game.rs +++ b/core/src/game.rs @@ -2146,6 +2146,63 @@ mod tests { assert!(game.players[1].constructs[0].effects.len() == 2); } + #[test] + fn hybrid_test() { + let mut game = create_2v2_test_game(); + let player_id = game.players[0].id; + let source = game.players[0].constructs[0].id; + let target = game.players[1].constructs[0].id; + + game.players[1].constructs[0].blue_life.force(0); + + + game.resolve(Cast::new(source, player_id, source, Skill::Hybrid)); + game.resolve(Cast::new(source, player_id, target, Skill::Siphon)); + + let last = game.resolutions.len() - 1; + let resolutions = &game.resolutions[last]; + + assert!(resolutions.iter().any(|r| match r.skill { + Skill::HybridBlast => true, + _ => false + })); + + assert!(resolutions.iter().filter(|r| match r.event { + Event::Damage { construct: _, colour: _, amount: _, mitigation: _, display: _ } => true, + _ => false, + }).count() == 2); + + + let siphon_dmg = resolutions.iter().find_map(|r| match r.skill { + Skill::Siphon => { + match r.event { + Event::Damage { construct: _, colour: _, amount, mitigation: _, display: _ } => Some(amount), + _ => None, + } + }, + _ => None + }).expect("no siphon dmg"); + + let hybrid_dmg = resolutions.iter().find_map(|r| match r.skill { + Skill::HybridBlast => { + match r.event { + Event::Damage { construct: _, colour: _, amount, mitigation: _, display: _ } => Some(amount), + _ => None, + } + }, + _ => None + }).expect("no hybrid dmg"); + + assert!(resolutions.iter().any(|r| match r.event { + Event::Healing { construct, colour, amount, overhealing, display: _ } => { + construct == source && (amount + overhealing) == siphon_dmg && colour == Colour::Green + // this works + // construct == source && (amount + overhealing) == (siphon_dmg + hybrid_dmg) && colour == Colour::Green + }, + _ => false, + })); + } + #[test] fn reflect_test() { let mut game = create_2v2_test_game();