sleep test
This commit is contained in:
parent
ff8e3aaa71
commit
905693a415
@ -1021,6 +1021,39 @@ mod tests {
|
||||
return game.start();
|
||||
}
|
||||
|
||||
fn create_cd_test_game() -> Game {
|
||||
let mut x = Construct::new()
|
||||
.named(&"pronounced \"creeep\"".to_string())
|
||||
.learn(Skill::Sleep)
|
||||
.learn(Skill::Decay);
|
||||
|
||||
let mut y = Construct::new()
|
||||
.named(&"lemongrass tea".to_string())
|
||||
.learn(Skill::Buff);
|
||||
|
||||
let mut game = Game::new();
|
||||
|
||||
game
|
||||
.set_player_num(2)
|
||||
.set_player_constructs(1);
|
||||
|
||||
let x_player_id = Uuid::new_v4();
|
||||
x.account = x_player_id;
|
||||
let x_player = Player::new(x_player_id, &"ntr".to_string(), vec![x]);
|
||||
|
||||
let y_player_id = Uuid::new_v4();
|
||||
y.account = y_player_id;
|
||||
let y_player = Player::new(y_player_id, &"mash".to_string(), vec![y]);
|
||||
|
||||
game
|
||||
.player_add(x_player).unwrap()
|
||||
.player_add(y_player).unwrap();
|
||||
|
||||
assert!(game.can_start());
|
||||
|
||||
return game.start();
|
||||
}
|
||||
|
||||
fn create_2v2_test_game() -> Game {
|
||||
let mut i = Construct::new()
|
||||
.named(&"pretaliate".to_string())
|
||||
@ -1199,6 +1232,57 @@ mod tests {
|
||||
assert!(game.player_by_id(y_player.id).unwrap().constructs[0].skill_on_cd(Skill::Block).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sleep_cooldown_test() {
|
||||
let mut game = create_cd_test_game();
|
||||
|
||||
let x_player = game.players[0].clone();
|
||||
let y_player = game.players[1].clone();
|
||||
|
||||
let x_construct = x_player.constructs[0].clone();
|
||||
let y_construct = y_player.constructs[0].clone();
|
||||
|
||||
|
||||
for _n in 1..10 {
|
||||
// should auto progress back to skill phase
|
||||
assert!(game.phase == Phase::Skill);
|
||||
|
||||
// Sleep 2T CD
|
||||
assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Decay).is_none());
|
||||
assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Sleep).is_some());
|
||||
|
||||
game.player_ready(x_player.id).unwrap();
|
||||
game.player_ready(y_player.id).unwrap();
|
||||
game = game.resolve_phase_start();
|
||||
|
||||
// Sleep 1T CD
|
||||
assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Decay).is_none());
|
||||
assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Sleep).is_some());
|
||||
|
||||
game.add_skill(x_player.id, x_construct.id, y_construct.id, Skill::Decay).unwrap();
|
||||
game.player_ready(x_player.id).unwrap();
|
||||
game.player_ready(y_player.id).unwrap();
|
||||
game = game.resolve_phase_start();
|
||||
|
||||
// Sleep 0T CD (we use it here)
|
||||
assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Decay).is_none());
|
||||
assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Sleep).is_none());
|
||||
|
||||
game.add_skill(x_player.id, x_construct.id, y_construct.id, Skill::Sleep).unwrap();
|
||||
game.player_ready(x_player.id).unwrap();
|
||||
game.player_ready(y_player.id).unwrap();
|
||||
game = game.resolve_phase_start();
|
||||
|
||||
// Sleep back to 2T CD
|
||||
assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Decay).is_none());
|
||||
assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Sleep).is_some());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#[test]
|
||||
fn counter_test() {
|
||||
let mut game = create_test_game();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user