87 lines
2.2 KiB
Rust
87 lines
2.2 KiB
Rust
use uuid::Uuid;
|
|
|
|
use std::iter;
|
|
use rand::prelude::*;
|
|
|
|
use construct::{Construct};
|
|
use names::{name};
|
|
use player::{Player};
|
|
use game::{Game};
|
|
use skill::{Skill, Cast};
|
|
|
|
pub fn generate_mob() -> Construct {
|
|
let mob = Construct::new()
|
|
.named(&name());
|
|
|
|
return mob;
|
|
}
|
|
|
|
pub fn instance_mobs(player_id: Uuid) -> Vec<Construct> {
|
|
iter::repeat_with(||
|
|
generate_mob()
|
|
.set_account(player_id))
|
|
// .learn(Skill::Attack))
|
|
.take(3)
|
|
.collect::<Vec<Construct>>()
|
|
}
|
|
|
|
pub fn bot_player() -> Player {
|
|
let bot_id = Uuid::new_v4();
|
|
let constructs = instance_mobs(bot_id);
|
|
Player::new(bot_id, None, &name(), constructs).set_bot(true)
|
|
}
|
|
|
|
pub fn anon_player(id: Uuid) -> Player {
|
|
let constructs = instance_mobs(id);
|
|
Player::new(id, None, &"player".to_string(), constructs)
|
|
}
|
|
|
|
pub fn anim_test_game(skill: Skill) -> Game {
|
|
let mut rng = thread_rng();
|
|
let mut game = Game::new();
|
|
|
|
game
|
|
.set_player_num(2)
|
|
.set_player_constructs(3);
|
|
|
|
let x_id = Uuid::parse_str("8552e0bf-340d-4fc8-b6fc-cccccccccccc").unwrap();
|
|
let constructs = iter::repeat_with(||
|
|
generate_mob()
|
|
.set_account(x_id)
|
|
.learn(Skill::Attack))
|
|
.take(3)
|
|
.collect::<Vec<Construct>>();
|
|
let x_player = Player::new(x_id, None, &name(), constructs);
|
|
|
|
let id = Uuid::new_v4();
|
|
let constructs = iter::repeat_with(||
|
|
generate_mob()
|
|
.set_account(id)
|
|
.learn(Skill::Attack))
|
|
.take(3)
|
|
.collect::<Vec<Construct>>();
|
|
let y_player = Player::new(id, None, &name(), constructs);
|
|
|
|
game
|
|
.player_add(x_player).unwrap()
|
|
.player_add(y_player).unwrap();
|
|
|
|
game = game.start();
|
|
|
|
let x_id = game.players[0].id;
|
|
let x_construct = game.players[0].constructs[1].id;
|
|
|
|
let y_id = game.players[1].id;
|
|
let y_construct = game.players[1].constructs[1].id;
|
|
|
|
let cast = match rng.gen_bool(0.5) {
|
|
true => Cast::new(x_construct, x_id, y_construct, skill),
|
|
false => Cast::new(y_construct, y_id, x_construct, skill),
|
|
};
|
|
|
|
game.stack.push(cast);
|
|
game = game.resolve_phase_start();
|
|
return game;
|
|
}
|
|
|