From 46e8da5ba91c0924bb63457d8030bf62663114aa Mon Sep 17 00:00:00 2001 From: Mashy Date: Fri, 13 Dec 2019 11:29:34 +1000 Subject: [PATCH] sustain test --- core/src/effect.rs | 8 ++++++-- core/src/game.rs | 25 ++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/core/src/effect.rs b/core/src/effect.rs index edc74998..3bb80b74 100644 --- a/core/src/effect.rs +++ b/core/src/effect.rs @@ -73,6 +73,7 @@ impl Effect { match self { Effect::Banish => true, + // delete sustain immunitiy??? Effect::Sustain => [ Skill::Stun, Skill::Silence, @@ -201,7 +202,10 @@ impl Effect { } } - pub fn colour(&self) -> Option { + // Old colour matching system for buffs / debuffs + // Had issues as some effects will be considered as both a buff and debuff e.g. invert, + // Ended up being confusing with mismatch skills that have red / blue e.g. amplify, haste, hybrid +/* pub fn colour(&self) -> Option { match self { // physical Effect::Stun => Some(Colour::Red), @@ -247,5 +251,5 @@ impl Effect { Effect::Siphoned => None, Effect::Ko => None, } - } + }*/ } diff --git a/core/src/game.rs b/core/src/game.rs index a56271b2..f36306ed 100644 --- a/core/src/game.rs +++ b/core/src/game.rs @@ -1963,7 +1963,30 @@ mod tests { construct == interceptor && (amount > 0 || mitigation > 0) && colour == Colour::Red, _ => false, })); -} + } + + #[test] + fn sustain_test() { + + // Standard case where construct gets ko from a big hit + let mut game = create_2v2_test_game(); + let player = game.players[0].id; + let source = game.players[0].constructs[0].id; + let target = game.players[1].constructs[0].id; + game.players[0].constructs[0].red_power.force(1000000); + game.resolve(Cast::new(source, player, target, Skill::Attack), vec![]); + assert!(game.players[1].constructs[0].is_ko() == true); + + // Sustain case where construct survives + let mut game = create_2v2_test_game(); + let player = game.players[0].id; + let source = game.players[0].constructs[0].id; + let target = game.players[1].constructs[0].id; + game.players[0].constructs[0].red_power.force(1000000); + game.resolve(Cast::new(source, player, target, Skill::Sustain), vec![]); + game.resolve(Cast::new(source, player, target, Skill::Attack), vec![]); + assert!(game.players[1].constructs[0].is_ko() == false); + } /* #[test]