sustain test

This commit is contained in:
Mashy 2019-12-13 11:29:34 +10:00
parent 1708e02057
commit 46e8da5ba9
2 changed files with 30 additions and 3 deletions

View File

@ -73,6 +73,7 @@ impl Effect {
match self { match self {
Effect::Banish => true, Effect::Banish => true,
// delete sustain immunitiy???
Effect::Sustain => [ Effect::Sustain => [
Skill::Stun, Skill::Stun,
Skill::Silence, Skill::Silence,
@ -201,7 +202,10 @@ impl Effect {
} }
} }
pub fn colour(&self) -> Option<Colour> { // 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<Colour> {
match self { match self {
// physical // physical
Effect::Stun => Some(Colour::Red), Effect::Stun => Some(Colour::Red),
@ -247,5 +251,5 @@ impl Effect {
Effect::Siphoned => None, Effect::Siphoned => None,
Effect::Ko => None, Effect::Ko => None,
} }
} }*/
} }

View File

@ -1963,7 +1963,30 @@ mod tests {
construct == interceptor && (amount > 0 || mitigation > 0) && colour == Colour::Red, construct == interceptor && (amount > 0 || mitigation > 0) && colour == Colour::Red,
_ => false, _ => 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] #[test]