fix tests
This commit is contained in:
parent
c54c6f00e7
commit
25cd70bce1
@ -17,7 +17,7 @@ use rpc::{InstanceLobbyParams, InstanceJoinParams, InstanceReadyParams, Instance
|
|||||||
use account::Account;
|
use account::Account;
|
||||||
use player::{Player, player_create};
|
use player::{Player, player_create};
|
||||||
use construct::{Construct, construct_get};
|
use construct::{Construct, construct_get};
|
||||||
use mob::{bot_player};
|
use mob::{bot_player, instance_mobs};
|
||||||
use game::{Game, Phase, game_get, game_write};
|
use game::{Game, Phase, game_get, game_write};
|
||||||
use item::{Item};
|
use item::{Item};
|
||||||
use rpc::{RpcResult};
|
use rpc::{RpcResult};
|
||||||
@ -793,13 +793,19 @@ mod tests {
|
|||||||
fn instance_pve_test() {
|
fn instance_pve_test() {
|
||||||
let mut instance = Instance::new();
|
let mut instance = Instance::new();
|
||||||
|
|
||||||
let player = bot_player();
|
let bot_player = bot_player();
|
||||||
let player_account = player.id;
|
let bot = bot_player.id;
|
||||||
|
instance.add_player(bot_player).unwrap();
|
||||||
|
|
||||||
|
let player_account = Uuid::new_v4();
|
||||||
|
let constructs = instance_mobs(player_account);
|
||||||
|
let player = Player::new(player_account, &"test".to_string(), constructs).set_bot(true);
|
||||||
|
|
||||||
instance.add_player(player).expect("could not add player");
|
instance.add_player(player).expect("could not add player");
|
||||||
|
|
||||||
assert_eq!(instance.phase, InstancePhase::Lobby);
|
assert_eq!(instance.phase, InstancePhase::Lobby);
|
||||||
instance.player_ready(player_account).unwrap();
|
instance.player_ready(player_account).unwrap();
|
||||||
|
instance.player_ready(bot).unwrap();
|
||||||
|
|
||||||
assert_eq!(instance.phase, InstancePhase::Finished);
|
assert_eq!(instance.phase, InstancePhase::Finished);
|
||||||
// assert!(instance.players.iter().any(|p| p.wins as usize == instance.max_rounds / 2 + 1));
|
// assert!(instance.players.iter().any(|p| p.wins as usize == instance.max_rounds / 2 + 1));
|
||||||
@ -808,7 +814,9 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn instance_bot_vbox_test() {
|
fn instance_bot_vbox_test() {
|
||||||
let _instance = Instance::new();
|
let _instance = Instance::new();
|
||||||
let player = bot_player();
|
let player_account = Uuid::new_v4();
|
||||||
|
let constructs = instance_mobs(player_account);
|
||||||
|
let _player = Player::new(player_account, &"test".to_string(), constructs).set_bot(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -817,13 +825,17 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(instance.max_players, 2);
|
assert_eq!(instance.max_players, 2);
|
||||||
|
|
||||||
let player = bot_player();
|
let player_account = Uuid::new_v4();
|
||||||
|
let constructs = instance_mobs(player_account);
|
||||||
|
let player = Player::new(player_account, &"a".to_string(), constructs);
|
||||||
let a_id = player.id;
|
let a_id = player.id;
|
||||||
|
|
||||||
instance.add_player(player).expect("could not add player");
|
instance.add_player(player).expect("could not add player");
|
||||||
assert!(!instance.can_start());
|
assert!(!instance.can_start());
|
||||||
|
|
||||||
let player = bot_player();
|
let player_account = Uuid::new_v4();
|
||||||
|
let constructs = instance_mobs(player_account);
|
||||||
|
let player = Player::new(player_account, &"b".to_string(), constructs);
|
||||||
let b_id = player.id;
|
let b_id = player.id;
|
||||||
|
|
||||||
instance.add_player(player).expect("could not add player");
|
instance.add_player(player).expect("could not add player");
|
||||||
@ -850,13 +862,17 @@ mod tests {
|
|||||||
fn instance_upkeep_test() {
|
fn instance_upkeep_test() {
|
||||||
let mut instance = Instance::new();
|
let mut instance = Instance::new();
|
||||||
|
|
||||||
let player = bot_player();
|
let player_account = Uuid::new_v4();
|
||||||
|
let constructs = instance_mobs(player_account);
|
||||||
|
let player = Player::new(player_account, &"a".to_string(), constructs);
|
||||||
let a_id = player.id;
|
let a_id = player.id;
|
||||||
|
|
||||||
instance.add_player(player).expect("could not add player");
|
instance.add_player(player).expect("could not add player");
|
||||||
assert!(!instance.can_start());
|
assert!(!instance.can_start());
|
||||||
|
|
||||||
let player = bot_player();
|
let player_account = Uuid::new_v4();
|
||||||
|
let constructs = instance_mobs(player_account);
|
||||||
|
let player = Player::new(player_account, &"b".to_string(), constructs);
|
||||||
let b_id = player.id;
|
let b_id = player.id;
|
||||||
instance.add_player(player).expect("could not add player");
|
instance.add_player(player).expect("could not add player");
|
||||||
|
|
||||||
@ -886,7 +902,9 @@ mod tests {
|
|||||||
fn instance_upkeep_idle_lobby_test() {
|
fn instance_upkeep_idle_lobby_test() {
|
||||||
let mut instance = Instance::new();
|
let mut instance = Instance::new();
|
||||||
|
|
||||||
let player = bot_player();
|
let player_account = Uuid::new_v4();
|
||||||
|
let constructs = instance_mobs(player_account);
|
||||||
|
let player = Player::new(player_account, &"a".to_string(), constructs);
|
||||||
let _a_id = player.id;
|
let _a_id = player.id;
|
||||||
|
|
||||||
instance.add_player(player).expect("could not add player");
|
instance.add_player(player).expect("could not add player");
|
||||||
|
|||||||
@ -25,8 +25,5 @@ pub fn instance_mobs(player_id: Uuid) -> Vec<Construct> {
|
|||||||
pub fn bot_player() -> Player {
|
pub fn bot_player() -> Player {
|
||||||
let bot_id = Uuid::new_v4();
|
let bot_id = Uuid::new_v4();
|
||||||
let constructs = instance_mobs(bot_id);
|
let constructs = instance_mobs(bot_id);
|
||||||
let mut p = Player::new(bot_id, &name(), constructs).set_bot(true);
|
Player::new(bot_id, &name(), constructs).set_bot(true)
|
||||||
p.set_ready(true);
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user