simplify cryps
This commit is contained in:
parent
fac6191c2e
commit
5c3ad25fe0
@ -64,10 +64,10 @@ pub struct CrypStat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CrypStat {
|
impl CrypStat {
|
||||||
pub fn set(&mut self, v: u64, specs: &Vec<Spec>) -> &mut CrypStat {
|
// pub fn set(&mut self, v: u64, specs: &Vec<Spec>) -> &mut CrypStat {
|
||||||
self.base = v;
|
// self.base = v;
|
||||||
self.recalculate(specs)
|
// self.recalculate(specs)
|
||||||
}
|
// }
|
||||||
|
|
||||||
pub fn recalculate(&mut self, specs: &Vec<Spec>) -> &mut CrypStat {
|
pub fn recalculate(&mut self, specs: &Vec<Spec>) -> &mut CrypStat {
|
||||||
let specs = specs
|
let specs = specs
|
||||||
@ -108,7 +108,6 @@ pub struct CrypRecover {
|
|||||||
pub id: Uuid,
|
pub id: Uuid,
|
||||||
pub account: Uuid,
|
pub account: Uuid,
|
||||||
pub xp: u64,
|
pub xp: u64,
|
||||||
pub lvl: u8,
|
|
||||||
pub name: String,
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,8 +122,6 @@ pub struct Cryp {
|
|||||||
pub speed: CrypStat,
|
pub speed: CrypStat,
|
||||||
pub hp: CrypStat,
|
pub hp: CrypStat,
|
||||||
pub evasion: CrypStat,
|
pub evasion: CrypStat,
|
||||||
pub xp: u64,
|
|
||||||
pub lvl: u8,
|
|
||||||
pub skills: Vec<CrypSkill>,
|
pub skills: Vec<CrypSkill>,
|
||||||
pub effects: Vec<CrypEffect>,
|
pub effects: Vec<CrypEffect>,
|
||||||
pub specs: Vec<Spec>,
|
pub specs: Vec<Spec>,
|
||||||
@ -132,26 +129,19 @@ pub struct Cryp {
|
|||||||
pub ko_logged: bool,
|
pub ko_logged: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_lvl(lvl: u8) -> u8 {
|
|
||||||
if lvl > 64 { return 64; }
|
|
||||||
return lvl;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Cryp {
|
impl Cryp {
|
||||||
pub fn new() -> Cryp {
|
pub fn new() -> Cryp {
|
||||||
let id = Uuid::new_v4();
|
let id = Uuid::new_v4();
|
||||||
return Cryp {
|
return Cryp {
|
||||||
id,
|
id,
|
||||||
account: id,
|
account: id,
|
||||||
red_damage: CrypStat { base: 0, value: 0, max: 0, stat: Stat::RedDamage },
|
red_damage: CrypStat { base: 256, value: 256, max: 256, stat: Stat::RedDamage },
|
||||||
red_shield: CrypStat { base: 0, value: 0, max: 0, stat: Stat::RedShield },
|
red_shield: CrypStat { base: 0, value: 0, max: 0, stat: Stat::RedShield },
|
||||||
blue_damage: CrypStat { base: 0, value: 0, max: 0, stat: Stat::BlueDamage },
|
blue_damage: CrypStat { base: 256, value: 256, max: 256, stat: Stat::BlueDamage },
|
||||||
blue_shield: CrypStat { base: 0, value: 0, max: 0, stat: Stat::BlueShield },
|
blue_shield: CrypStat { base: 0, value: 0, max: 0, stat: Stat::BlueShield },
|
||||||
speed: CrypStat { base: 0, value: 0, max: 0, stat: Stat::Speed },
|
speed: CrypStat { base: 128, value: 128, max: 128, stat: Stat::Speed },
|
||||||
hp: CrypStat { base: 0, value: 0, max: 0, stat: Stat::Hp },
|
hp: CrypStat { base: 1024, value: 1024, max: 1024, stat: Stat::Hp },
|
||||||
evasion: CrypStat { base: 0, value: 0, max: 0, stat: Stat::Evasion },
|
evasion: CrypStat { base: 0, value: 0, max: 0, stat: Stat::Evasion },
|
||||||
lvl: 0,
|
|
||||||
xp: 0,
|
|
||||||
skills: vec![],
|
skills: vec![],
|
||||||
effects: vec![],
|
effects: vec![],
|
||||||
specs: vec![],
|
specs: vec![],
|
||||||
@ -170,11 +160,6 @@ impl Cryp {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn level(mut self, lvl: u8) -> Cryp {
|
|
||||||
self.lvl = check_lvl(lvl);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn learn(mut self, s: Skill) -> Cryp {
|
pub fn learn(mut self, s: Skill) -> Cryp {
|
||||||
self.skills.push(CrypSkill::new(s));
|
self.skills.push(CrypSkill::new(s));
|
||||||
self
|
self
|
||||||
@ -195,22 +180,6 @@ impl Cryp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create(mut self) -> Cryp {
|
|
||||||
let xp = match self.lvl == 64 {
|
|
||||||
true => u64::max_value(),
|
|
||||||
false => 2_u64.pow(self.lvl.into()),
|
|
||||||
};
|
|
||||||
|
|
||||||
self.xp = xp;
|
|
||||||
|
|
||||||
self.red_damage.set(256, &self.specs);
|
|
||||||
self.blue_damage.set(256, &self.specs);
|
|
||||||
self.speed.set(128, &self.specs);
|
|
||||||
self.hp.set(1024, &self.specs);
|
|
||||||
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn spec_add(&mut self, spec: Spec) -> Result<&mut Cryp, Error> {
|
pub fn spec_add(&mut self, spec: Spec) -> Result<&mut Cryp, Error> {
|
||||||
self.specs.push(spec);
|
self.specs.push(spec);
|
||||||
return Ok(self.recalculate_stats());
|
return Ok(self.recalculate_stats());
|
||||||
@ -584,9 +553,7 @@ pub fn cryp_get(tx: &mut Transaction, id: Uuid, account_id: Uuid) -> Result<Cryp
|
|||||||
pub fn cryp_spawn(params: CrypSpawnParams, tx: &mut Transaction, account: &Account) -> Result<Cryp, Error> {
|
pub fn cryp_spawn(params: CrypSpawnParams, tx: &mut Transaction, account: &Account) -> Result<Cryp, Error> {
|
||||||
let cryp = Cryp::new()
|
let cryp = Cryp::new()
|
||||||
.named(¶ms.name)
|
.named(¶ms.name)
|
||||||
.level(1)
|
.set_account(account.id);
|
||||||
.set_account(account.id)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
let cryp_bytes = to_vec(&cryp)?;
|
let cryp_bytes = to_vec(&cryp)?;
|
||||||
|
|
||||||
@ -631,10 +598,7 @@ pub fn cryp_recover(cryp_bytes: Vec<u8>, tx: &mut Transaction) -> Result<Cryp, E
|
|||||||
|
|
||||||
let mut cryp = Cryp::new()
|
let mut cryp = Cryp::new()
|
||||||
.named(&c.name)
|
.named(&c.name)
|
||||||
.level(c.lvl)
|
.set_account(c.account);
|
||||||
.learn(Skill::Attack)
|
|
||||||
.set_account(c.account)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
cryp.id = c.id;
|
cryp.id = c.id;
|
||||||
|
|
||||||
@ -650,13 +614,10 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn create_cryp_test() {
|
fn create_cryp_test() {
|
||||||
let max_level = Cryp::new()
|
let cryp = Cryp::new()
|
||||||
.named(&"hatchling".to_string())
|
.named(&"hatchling".to_string());
|
||||||
.level(64)
|
|
||||||
// .learn(Skill::Stoney)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
assert_eq!(max_level.lvl, 64);
|
assert_eq!(cryp.name, "hatchling".to_string());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,10 +8,9 @@ use failure::Error;
|
|||||||
use failure::err_msg;
|
use failure::err_msg;
|
||||||
|
|
||||||
use account::Account;
|
use account::Account;
|
||||||
use rpc::{GameStateParams, GameSkillParams, GamePveParams};
|
use rpc::{GameStateParams, GameSkillParams};
|
||||||
use cryp::{Cryp, cryp_get};
|
use cryp::{Cryp};
|
||||||
use skill::{Skill, Cast, ResolutionResult};
|
use skill::{Skill, Cast, ResolutionResult};
|
||||||
use mob::{generate_mob_team};
|
|
||||||
use player::{Player};
|
use player::{Player};
|
||||||
use instance::{instance_game_finished};
|
use instance::{instance_game_finished};
|
||||||
|
|
||||||
@ -676,56 +675,56 @@ pub fn game_update(game: &Game, tx: &mut Transaction) -> Result<(), Error> {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn game_pve_new(cryp_ids: Vec<Uuid>, mode: GameMode, tx: &mut Transaction, account: &Account) -> Result<Game, Error> {
|
// pub fn game_pve_new(cryp_ids: Vec<Uuid>, mode: GameMode, tx: &mut Transaction, account: &Account) -> Result<Game, Error> {
|
||||||
if cryp_ids.len() == 0 {
|
// if cryp_ids.len() == 0 {
|
||||||
return Err(err_msg("no cryps selected"));
|
// return Err(err_msg("no cryps selected"));
|
||||||
}
|
// }
|
||||||
|
|
||||||
let cryps = cryp_ids
|
// let cryps = cryp_ids
|
||||||
.iter()
|
// .iter()
|
||||||
.map(|id| cryp_get(tx, *id, account.id))
|
// .map(|id| cryp_get(tx, *id, account.id))
|
||||||
.collect::<Result<Vec<Cryp>, Error>>()?;
|
// .collect::<Result<Vec<Cryp>, Error>>()?;
|
||||||
|
|
||||||
if cryps.len() > 3 {
|
// if cryps.len() > 3 {
|
||||||
return Err(err_msg("team size too large (3 max)"));
|
// return Err(err_msg("team size too large (3 max)"));
|
||||||
}
|
// }
|
||||||
|
|
||||||
// create the game
|
// // create the game
|
||||||
let mut game = Game::new();
|
// let mut game = Game::new();
|
||||||
// let game_id = game.id;
|
// // let game_id = game.id;
|
||||||
|
|
||||||
game
|
// game
|
||||||
.set_pve(true)
|
// .set_pve(true)
|
||||||
.set_team_num(2)
|
// .set_team_num(2)
|
||||||
.set_team_size(cryps.len())
|
// .set_team_size(cryps.len())
|
||||||
.set_mode(mode);
|
// .set_mode(mode);
|
||||||
|
|
||||||
// create the mob team
|
// // create the mob team
|
||||||
let mob_team = generate_mob_team(mode, &cryps);
|
// let mob_team = generate_mob_team(mode, &cryps);
|
||||||
|
|
||||||
// add the players
|
// // add the players
|
||||||
let mut plr_team = Team::new(account.id);
|
// let mut plr_team = Team::new(account.id);
|
||||||
plr_team
|
// plr_team
|
||||||
.set_cryps(cryps);
|
// .set_cryps(cryps);
|
||||||
|
|
||||||
|
|
||||||
game
|
// game
|
||||||
.team_add(plr_team)?
|
// .team_add(plr_team)?
|
||||||
.team_add(mob_team)?;
|
// .team_add(mob_team)?;
|
||||||
|
|
||||||
game.start();
|
// game.start();
|
||||||
|
|
||||||
return Ok(game);
|
// return Ok(game);
|
||||||
}
|
// }
|
||||||
|
|
||||||
pub fn game_pve(params: GamePveParams, tx: &mut Transaction, account: &Account) -> Result<Game, Error> {
|
// pub fn game_pve(params: GamePveParams, tx: &mut Transaction, account: &Account) -> Result<Game, Error> {
|
||||||
let game = game_pve_new(params.cryp_ids, GameMode::Normal, tx, account)?;
|
// let game = game_pve_new(params.cryp_ids, GameMode::Normal, tx, account)?;
|
||||||
|
|
||||||
// persist
|
// // persist
|
||||||
game_write(&game, tx)?;
|
// game_write(&game, tx)?;
|
||||||
|
|
||||||
Ok(game)
|
// Ok(game)
|
||||||
}
|
// }
|
||||||
|
|
||||||
pub fn game_instance_new(tx: &mut Transaction, player: Player, game_id: Uuid) -> Result<Game, Error> {
|
pub fn game_instance_new(tx: &mut Transaction, player: Player, game_id: Uuid) -> Result<Game, Error> {
|
||||||
// create the game
|
// create the game
|
||||||
@ -775,7 +774,6 @@ mod tests {
|
|||||||
fn create_test_game() -> Game {
|
fn create_test_game() -> Game {
|
||||||
let x = Cryp::new()
|
let x = Cryp::new()
|
||||||
.named(&"pronounced \"creeep\"".to_string())
|
.named(&"pronounced \"creeep\"".to_string())
|
||||||
.level(8)
|
|
||||||
.learn(Skill::Attack)
|
.learn(Skill::Attack)
|
||||||
.learn(Skill::TestStun)
|
.learn(Skill::TestStun)
|
||||||
.learn(Skill::TestTouch)
|
.learn(Skill::TestTouch)
|
||||||
@ -784,12 +782,10 @@ mod tests {
|
|||||||
.learn(Skill::TestSiphon)
|
.learn(Skill::TestSiphon)
|
||||||
.learn(Skill::Empower)
|
.learn(Skill::Empower)
|
||||||
.learn(Skill::Stun)
|
.learn(Skill::Stun)
|
||||||
.learn(Skill::Block)
|
.learn(Skill::Block);
|
||||||
.create();
|
|
||||||
|
|
||||||
let y = Cryp::new()
|
let y = Cryp::new()
|
||||||
.named(&"lemongrass tea".to_string())
|
.named(&"lemongrass tea".to_string())
|
||||||
.level(8)
|
|
||||||
.learn(Skill::Attack)
|
.learn(Skill::Attack)
|
||||||
.learn(Skill::TestStun)
|
.learn(Skill::TestStun)
|
||||||
.learn(Skill::TestTouch)
|
.learn(Skill::TestTouch)
|
||||||
@ -798,8 +794,7 @@ mod tests {
|
|||||||
.learn(Skill::TestSiphon)
|
.learn(Skill::TestSiphon)
|
||||||
.learn(Skill::Empower)
|
.learn(Skill::Empower)
|
||||||
.learn(Skill::Stun)
|
.learn(Skill::Stun)
|
||||||
.learn(Skill::Block)
|
.learn(Skill::Block);
|
||||||
.create();
|
|
||||||
|
|
||||||
let mut game = Game::new();
|
let mut game = Game::new();
|
||||||
|
|
||||||
@ -832,31 +827,23 @@ mod tests {
|
|||||||
fn create_2v2_test_game() -> Game {
|
fn create_2v2_test_game() -> Game {
|
||||||
let i = Cryp::new()
|
let i = Cryp::new()
|
||||||
.named(&"pretaliate".to_string())
|
.named(&"pretaliate".to_string())
|
||||||
.level(8)
|
|
||||||
.learn(Skill::Attack)
|
.learn(Skill::Attack)
|
||||||
.learn(Skill::TestTouch)
|
.learn(Skill::TestTouch);
|
||||||
.create();
|
|
||||||
|
|
||||||
let j = Cryp::new()
|
let j = Cryp::new()
|
||||||
.named(&"poy sian".to_string())
|
.named(&"poy sian".to_string())
|
||||||
.level(8)
|
|
||||||
.learn(Skill::Attack)
|
.learn(Skill::Attack)
|
||||||
.learn(Skill::TestTouch)
|
.learn(Skill::TestTouch);
|
||||||
.create();
|
|
||||||
|
|
||||||
let x = Cryp::new()
|
let x = Cryp::new()
|
||||||
.named(&"pronounced \"creeep\"".to_string())
|
.named(&"pronounced \"creeep\"".to_string())
|
||||||
.level(8)
|
|
||||||
.learn(Skill::Attack)
|
.learn(Skill::Attack)
|
||||||
.learn(Skill::TestTouch)
|
.learn(Skill::TestTouch);
|
||||||
.create();
|
|
||||||
|
|
||||||
let y = Cryp::new()
|
let y = Cryp::new()
|
||||||
.named(&"lemongrass tea".to_string())
|
.named(&"lemongrass tea".to_string())
|
||||||
.level(8)
|
|
||||||
.learn(Skill::Attack)
|
.learn(Skill::Attack)
|
||||||
.learn(Skill::TestTouch)
|
.learn(Skill::TestTouch);
|
||||||
.create();
|
|
||||||
|
|
||||||
let mut game = Game::new();
|
let mut game = Game::new();
|
||||||
|
|
||||||
|
|||||||
@ -5,10 +5,9 @@ use rand::distributions::Alphanumeric;
|
|||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
use cryp::{Cryp};
|
use cryp::{Cryp};
|
||||||
use game::{Team, GameMode};
|
|
||||||
use skill::{Skill};
|
use skill::{Skill};
|
||||||
|
|
||||||
pub fn generate_mob(lvl: u8) -> Cryp {
|
pub fn generate_mob() -> Cryp {
|
||||||
let mut rng = thread_rng();
|
let mut rng = thread_rng();
|
||||||
|
|
||||||
let name: String = iter::repeat(())
|
let name: String = iter::repeat(())
|
||||||
@ -16,140 +15,112 @@ pub fn generate_mob(lvl: u8) -> Cryp {
|
|||||||
.take(8)
|
.take(8)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
// rng panics on min == max
|
|
||||||
// let mob_lvl: u8 = match lvl {
|
|
||||||
// 1 => 1,
|
|
||||||
// _ => rng.gen_range(lvl.saturating_sub(2), lvl)
|
|
||||||
// };
|
|
||||||
|
|
||||||
let mob = Cryp::new()
|
let mob = Cryp::new()
|
||||||
.named(&name)
|
.named(&name);
|
||||||
.level(lvl)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
return mob;
|
return mob;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn quick_game(mob_lvl: u8, team_size: usize) -> Vec<Cryp> {
|
// fn quick_game(team_size: usize) -> Vec<Cryp> {
|
||||||
iter::repeat_with(||
|
// iter::repeat_with(||
|
||||||
generate_mob(mob_lvl)
|
// generate_mob()
|
||||||
.set_account(Uuid::nil())
|
// .set_account(Uuid::nil())
|
||||||
.learn(Skill::Attack))
|
// .learn(Skill::Attack))
|
||||||
.take(team_size)
|
// .take(team_size)
|
||||||
.collect::<Vec<Cryp>>()
|
// .collect::<Vec<Cryp>>()
|
||||||
}
|
// }
|
||||||
|
|
||||||
pub fn instance_mobs(team_id: Uuid) -> Vec<Cryp> {
|
pub fn instance_mobs(team_id: Uuid) -> Vec<Cryp> {
|
||||||
iter::repeat_with(||
|
iter::repeat_with(||
|
||||||
generate_mob(1)
|
generate_mob()
|
||||||
.set_account(team_id)
|
.set_account(team_id)
|
||||||
.learn(Skill::Attack))
|
.learn(Skill::Attack))
|
||||||
.take(3)
|
.take(3)
|
||||||
.collect::<Vec<Cryp>>()
|
.collect::<Vec<Cryp>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn zone_3v2_attack(player_lvl: u8) -> Vec<Cryp> {
|
// fn zone_3v2_attack(player_lvl: u8) -> Vec<Cryp> {
|
||||||
let x = Cryp::new()
|
// let x = Cryp::new()
|
||||||
.named(&"hench".to_string())
|
// .named(&"hench".to_string())
|
||||||
.level(player_lvl)
|
// .learn(Skill::Attack);
|
||||||
.learn(Skill::Attack)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
let y = Cryp::new()
|
// let y = Cryp::new()
|
||||||
.named(&"bench".to_string())
|
// .named(&"bench".to_string())
|
||||||
.level(player_lvl)
|
// .learn(Skill::Attack);
|
||||||
.learn(Skill::Attack)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
return vec![x, y];
|
// return vec![x, y];
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn zone_2v2_caster(player_lvl: u8) -> Vec<Cryp> {
|
// fn zone_2v2_caster(player_lvl: u8) -> Vec<Cryp> {
|
||||||
let x = Cryp::new()
|
// let x = Cryp::new()
|
||||||
.named(&"robe".to_string())
|
// .named(&"robe".to_string())
|
||||||
.level(player_lvl)
|
// .learn(Skill::Blast);
|
||||||
.learn(Skill::Blast)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
let y = Cryp::new()
|
// let y = Cryp::new()
|
||||||
.named(&"wizard hat".to_string())
|
// .named(&"wizard hat".to_string())
|
||||||
.level(player_lvl)
|
// .learn(Skill::Blast);
|
||||||
.learn(Skill::Blast)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
return vec![x, y];
|
// return vec![x, y];
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn zone_3v3_melee_miniboss(player_lvl: u8) -> Vec<Cryp> {
|
// fn zone_3v3_melee_miniboss(player_lvl: u8) -> Vec<Cryp> {
|
||||||
let x = Cryp::new()
|
// let x = Cryp::new()
|
||||||
.named(&"jungle juice".to_string())
|
// .named(&"jungle juice".to_string())
|
||||||
.level(player_lvl)
|
// .learn(Skill::Attack);
|
||||||
.learn(Skill::Attack)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
let y = Cryp::new()
|
// let y = Cryp::new()
|
||||||
.named(&"bamboo basher".to_string())
|
// .named(&"bamboo basher".to_string())
|
||||||
.level(player_lvl)
|
// .learn(Skill::Attack)
|
||||||
.learn(Skill::Attack)
|
// .learn(Skill::Stun);
|
||||||
.learn(Skill::Stun)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
let z = Cryp::new()
|
// let z = Cryp::new()
|
||||||
.named(&"lemongrass tea".to_string())
|
// .named(&"lemongrass tea".to_string())
|
||||||
.level(player_lvl)
|
// .learn(Skill::Attack);
|
||||||
.learn(Skill::Attack)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
return vec![x, y, z];
|
// return vec![x, y, z];
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn zone_3v3_healer_boss(player_lvl: u8) -> Vec<Cryp> {
|
// fn zone_3v3_healer_boss(player_lvl: u8) -> Vec<Cryp> {
|
||||||
let x = Cryp::new()
|
// let x = Cryp::new()
|
||||||
.named(&"coinage".to_string())
|
// .named(&"coinage".to_string())
|
||||||
.level(player_lvl)
|
// .learn(Skill::Attack)
|
||||||
.learn(Skill::Attack)
|
// .learn(Skill::Parry)
|
||||||
.learn(Skill::Parry)
|
// .learn(Skill::Block);
|
||||||
.learn(Skill::Block)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
let y = Cryp::new()
|
// let y = Cryp::new()
|
||||||
.named(&"wololo".to_string())
|
// .named(&"wololo".to_string())
|
||||||
.level(player_lvl + 1)
|
// // big strong
|
||||||
// big strong
|
// // .learn(Skill::Blast)
|
||||||
// .learn(Skill::Blast)
|
// .learn(Skill::Heal)
|
||||||
.learn(Skill::Heal)
|
// .learn(Skill::Triage);
|
||||||
.learn(Skill::Triage)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
let z = Cryp::new()
|
// let z = Cryp::new()
|
||||||
.named(&"quarry".to_string())
|
// .named(&"quarry".to_string())
|
||||||
.level(player_lvl)
|
// .learn(Skill::Attack)
|
||||||
.learn(Skill::Attack)
|
// .learn(Skill::Parry)
|
||||||
.learn(Skill::Parry)
|
// .learn(Skill::Stun);
|
||||||
.learn(Skill::Stun)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
return vec![x, y, z];
|
// return vec![x, y, z];
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
pub fn generate_mob_team(mode: GameMode, cryps: &Vec<Cryp>) -> Team {
|
// pub fn generate_mob_team(mode: GameMode, cryps: &Vec<Cryp>) -> Team {
|
||||||
let mut mob_team = Team::new(Uuid::nil());
|
// let mut mob_team = Team::new(Uuid::nil());
|
||||||
|
|
||||||
let cryp_lvl = cryps.iter().max_by_key(|c| c.lvl).unwrap().lvl;
|
// let cryp_lvl = cryps.iter().max_by_key(|c| c.lvl).unwrap().lvl;
|
||||||
let team_size = cryps.len();
|
// let team_size = cryps.len();
|
||||||
|
|
||||||
let mobs = match mode {
|
// let mobs = match mode {
|
||||||
GameMode::Normal => quick_game(cryp_lvl, team_size),
|
// GameMode::Normal => quick_game(cryp_lvl, team_size),
|
||||||
GameMode::Zone3v2Attack => zone_3v2_attack(cryp_lvl),
|
// GameMode::Zone3v2Attack => zone_3v2_attack(cryp_lvl),
|
||||||
GameMode::Zone2v2Caster => zone_2v2_caster(cryp_lvl),
|
// GameMode::Zone2v2Caster => zone_2v2_caster(cryp_lvl),
|
||||||
GameMode::Zone3v3MeleeMiniboss => zone_3v3_melee_miniboss(cryp_lvl),
|
// GameMode::Zone3v3MeleeMiniboss => zone_3v3_melee_miniboss(cryp_lvl),
|
||||||
GameMode::Zone3v3HealerBoss => zone_3v3_healer_boss(cryp_lvl),
|
// GameMode::Zone3v3HealerBoss => zone_3v3_healer_boss(cryp_lvl),
|
||||||
_ => panic!("{:?} not handled for pve mobs", mode),
|
// _ => panic!("{:?} not handled for pve mobs", mode),
|
||||||
};
|
// };
|
||||||
|
|
||||||
mob_team.set_cryps(mobs);
|
// mob_team.set_cryps(mobs);
|
||||||
|
|
||||||
return mob_team;
|
// return mob_team;
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|||||||
@ -16,7 +16,7 @@ use failure::err_msg;
|
|||||||
|
|
||||||
use net::Db;
|
use net::Db;
|
||||||
use cryp::{Cryp, cryp_spawn};
|
use cryp::{Cryp, cryp_spawn};
|
||||||
use game::{Game, game_state, game_pve, game_skill};
|
use game::{Game, game_state, game_skill};
|
||||||
use account::{Account, account_create, account_login, account_from_token, account_cryps, account_players};
|
use account::{Account, account_create, account_login, account_from_token, account_cryps, account_players};
|
||||||
use skill::{Skill};
|
use skill::{Skill};
|
||||||
// use zone::{Zone, zone_create, zone_join, zone_close};
|
// use zone::{Zone, zone_create, zone_join, zone_close};
|
||||||
@ -70,7 +70,7 @@ impl Rpc {
|
|||||||
"cryp_spawn" => Rpc::cryp_spawn(data, &mut tx, account.unwrap(), client),
|
"cryp_spawn" => Rpc::cryp_spawn(data, &mut tx, account.unwrap(), client),
|
||||||
|
|
||||||
"game_state" => Rpc::game_state(data, &mut tx, account.unwrap(), client),
|
"game_state" => Rpc::game_state(data, &mut tx, account.unwrap(), client),
|
||||||
"game_pve" => Rpc::game_pve(data, &mut tx, account.unwrap(), client),
|
// "game_pve" => Rpc::game_pve(data, &mut tx, account.unwrap(), client),
|
||||||
"game_skill" => Rpc::game_skill(data, &mut tx, account.unwrap(), client),
|
"game_skill" => Rpc::game_skill(data, &mut tx, account.unwrap(), client),
|
||||||
|
|
||||||
// "zone_create" => Rpc::zone_create(data, &mut tx, account.unwrap(), client),
|
// "zone_create" => Rpc::zone_create(data, &mut tx, account.unwrap(), client),
|
||||||
@ -122,16 +122,16 @@ impl Rpc {
|
|||||||
return Ok(game_response);
|
return Ok(game_response);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn game_pve(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
// fn game_pve(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
||||||
let msg = from_slice::<GamePveMsg>(&data).or(Err(err_msg("invalid params")))?;
|
// let msg = from_slice::<GamePveMsg>(&data).or(Err(err_msg("invalid params")))?;
|
||||||
|
|
||||||
let game_response = RpcResponse {
|
// let game_response = RpcResponse {
|
||||||
method: "game_state".to_string(),
|
// method: "game_state".to_string(),
|
||||||
params: RpcResult::GameState(game_pve(msg.params, tx, &account)?)
|
// params: RpcResult::GameState(game_pve(msg.params, tx, &account)?)
|
||||||
};
|
// };
|
||||||
|
|
||||||
return Ok(game_response);
|
// return Ok(game_response);
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn game_skill(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
fn game_skill(data: Vec<u8>, tx: &mut Transaction, account: Account, _client: &mut WebSocket<TcpStream>) -> Result<RpcResponse, Error> {
|
||||||
let msg = from_slice::<GameSkillMsg>(&data).or(Err(err_msg("invalid params")))?;
|
let msg = from_slice::<GameSkillMsg>(&data).or(Err(err_msg("invalid params")))?;
|
||||||
@ -471,16 +471,16 @@ pub struct GameStateParams {
|
|||||||
pub id: Uuid,
|
pub id: Uuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
// #[derive(Debug,Clone,Serialize,Deserialize)]
|
||||||
struct GamePveMsg {
|
// struct GamePveMsg {
|
||||||
method: String,
|
// method: String,
|
||||||
params: GamePveParams,
|
// params: GamePveParams,
|
||||||
}
|
// }
|
||||||
|
|
||||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
// #[derive(Debug,Clone,Serialize,Deserialize)]
|
||||||
pub struct GamePveParams {
|
// pub struct GamePveParams {
|
||||||
pub cryp_ids: Vec<Uuid>,
|
// pub cryp_ids: Vec<Uuid>,
|
||||||
}
|
// }
|
||||||
|
|
||||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||||
struct GameSkillMsg {
|
struct GameSkillMsg {
|
||||||
|
|||||||
@ -907,15 +907,11 @@ mod tests {
|
|||||||
fn heal_test() {
|
fn heal_test() {
|
||||||
let mut x = Cryp::new()
|
let mut x = Cryp::new()
|
||||||
.named(&"muji".to_string())
|
.named(&"muji".to_string())
|
||||||
.level(8)
|
.learn(Skill::Heal);
|
||||||
.learn(Skill::Heal)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
let mut y = Cryp::new()
|
let mut y = Cryp::new()
|
||||||
.named(&"camel".to_string())
|
.named(&"camel".to_string())
|
||||||
.level(8)
|
.learn(Skill::Heal);
|
||||||
.learn(Skill::Heal)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
x.deal_red_damage(Skill::Attack, 5);
|
x.deal_red_damage(Skill::Attack, 5);
|
||||||
|
|
||||||
@ -925,14 +921,10 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn decay_test() {
|
fn decay_test() {
|
||||||
let mut x = Cryp::new()
|
let mut x = Cryp::new()
|
||||||
.named(&"muji".to_string())
|
.named(&"muji".to_string());
|
||||||
.level(8)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
let mut y = Cryp::new()
|
let mut y = Cryp::new()
|
||||||
.named(&"camel".to_string())
|
.named(&"camel".to_string());
|
||||||
.level(8)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
let mut log = vec![];
|
let mut log = vec![];
|
||||||
decay(&mut x, &mut y, Resolution::new(Skill::Triage));
|
decay(&mut x, &mut y, Resolution::new(Skill::Triage));
|
||||||
@ -947,14 +939,10 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn block_test() {
|
fn block_test() {
|
||||||
let mut x = Cryp::new()
|
let mut x = Cryp::new()
|
||||||
.named(&"muji".to_string())
|
.named(&"muji".to_string());
|
||||||
.level(8)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
let mut y = Cryp::new()
|
let mut y = Cryp::new()
|
||||||
.named(&"camel".to_string())
|
.named(&"camel".to_string());
|
||||||
.level(8)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
// ensure it doesn't have 0 pd
|
// ensure it doesn't have 0 pd
|
||||||
x.red_damage.force(100);
|
x.red_damage.force(100);
|
||||||
@ -974,14 +962,10 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn triage_test() {
|
fn triage_test() {
|
||||||
let mut x = Cryp::new()
|
let mut x = Cryp::new()
|
||||||
.named(&"muji".to_string())
|
.named(&"muji".to_string());
|
||||||
.level(8)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
let mut y = Cryp::new()
|
let mut y = Cryp::new()
|
||||||
.named(&"pretaliation".to_string())
|
.named(&"pretaliation".to_string());
|
||||||
.level(8)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
// ensure it doesn't have 0 sd
|
// ensure it doesn't have 0 sd
|
||||||
x.blue_damage.force(50);
|
x.blue_damage.force(50);
|
||||||
@ -1008,9 +992,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn silence_test() {
|
fn silence_test() {
|
||||||
let mut x = Cryp::new()
|
let mut x = Cryp::new()
|
||||||
.named(&"muji".to_string())
|
.named(&"muji".to_string());
|
||||||
.level(8)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
silence(&mut x.clone(), &mut x, Resolution::new(Skill::Silence));
|
silence(&mut x.clone(), &mut x, Resolution::new(Skill::Silence));
|
||||||
assert!(x.effects.iter().any(|e| e.effect == Effect::Silence));
|
assert!(x.effects.iter().any(|e| e.effect == Effect::Silence));
|
||||||
@ -1020,9 +1002,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn amplify_test() {
|
fn amplify_test() {
|
||||||
let mut x = Cryp::new()
|
let mut x = Cryp::new()
|
||||||
.named(&"muji".to_string())
|
.named(&"muji".to_string());
|
||||||
.level(8)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
x.blue_damage.force(50);
|
x.blue_damage.force(50);
|
||||||
|
|
||||||
@ -1034,9 +1014,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn purify_test() {
|
fn purify_test() {
|
||||||
let mut x = Cryp::new()
|
let mut x = Cryp::new()
|
||||||
.named(&"muji".to_string())
|
.named(&"muji".to_string());
|
||||||
.level(8)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
decay(&mut x.clone(), &mut x, Resolution::new(Skill::Decay));
|
decay(&mut x.clone(), &mut x, Resolution::new(Skill::Decay));
|
||||||
assert!(x.effects.iter().any(|e| e.effect == Effect::Decay));
|
assert!(x.effects.iter().any(|e| e.effect == Effect::Decay));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user