mnml/server/src/mob.rs
2019-05-25 15:20:38 +10:00

127 lines
3.4 KiB
Rust

use uuid::Uuid;
use rand::prelude::*;
use rand::distributions::Alphanumeric;
use std::iter;
use construct::{Construct};
use skill::{Skill};
pub fn generate_mob() -> Construct {
let mut rng = thread_rng();
let name: String = iter::repeat(())
.map(|()| rng.sample(Alphanumeric))
.take(8)
.collect();
let mob = Construct::new()
.named(&name);
return mob;
}
// fn quick_game(player_size: usize) -> Vec<Construct> {
// iter::repeat_with(||
// generate_mob()
// .set_account(Uuid::nil())
// .learn(Skill::Attack))
// .take(player_size)
// .collect::<Vec<Construct>>()
// }
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>>()
}
// fn zone_3v2_attack(player_lvl: u8) -> Vec<Construct> {
// let x = Construct::new()
// .named(&"hench".to_string())
// .learn(Skill::Attack);
// let y = Construct::new()
// .named(&"bench".to_string())
// .learn(Skill::Attack);
// return vec![x, y];
// }
// fn zone_2v2_caster(player_lvl: u8) -> Vec<Construct> {
// let x = Construct::new()
// .named(&"robe".to_string())
// .learn(Skill::Blast);
// let y = Construct::new()
// .named(&"wizard hat".to_string())
// .learn(Skill::Blast);
// return vec![x, y];
// }
// fn zone_3v3_melee_miniboss(player_lvl: u8) -> Vec<Construct> {
// let x = Construct::new()
// .named(&"jungle juice".to_string())
// .learn(Skill::Attack);
// let y = Construct::new()
// .named(&"bamboo basher".to_string())
// .learn(Skill::Attack)
// .learn(Skill::Stun);
// let z = Construct::new()
// .named(&"lemongrass tea".to_string())
// .learn(Skill::Attack);
// return vec![x, y, z];
// }
// fn zone_3v3_healer_boss(player_lvl: u8) -> Vec<Construct> {
// let x = Construct::new()
// .named(&"coinage".to_string())
// .learn(Skill::Attack)
// .learn(Skill::Parry)
// .learn(Skill::Block);
// let y = Construct::new()
// .named(&"wololo".to_string())
// // big strong
// // .learn(Skill::Blast)
// .learn(Skill::Heal)
// .learn(Skill::Triage);
// let z = Construct::new()
// .named(&"quarry".to_string())
// .learn(Skill::Attack)
// .learn(Skill::Parry)
// .learn(Skill::Stun);
// return vec![x, y, z];
// }
// pub fn generate_mob_player(mode: GameMode, constructs: &Vec<Construct>) -> Player {
// let mut mob_player = Player::new(Uuid::nil());
// let construct_lvl = constructs.iter().max_by_key(|c| c.lvl).unwrap().lvl;
// let player_size = constructs.len();
// let mobs = match mode {
// GameMode::Normal => quick_game(construct_lvl, player_size),
// GameMode::Zone3v2Attack => zone_3v2_attack(construct_lvl),
// GameMode::Zone2v2Caster => zone_2v2_caster(construct_lvl),
// GameMode::Zone3v3MeleeMiniboss => zone_3v3_melee_miniboss(construct_lvl),
// GameMode::Zone3v3HealerBoss => zone_3v3_healer_boss(construct_lvl),
// _ => panic!("{:?} not handled for pve mobs", mode),
// };
// mob_player.set_constructs(mobs);
// return mob_player;
// }