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