Revert "roll specs into vars"
This reverts commit 0dad45ccb0ca864abd90972646dac586ebbb7cfc.
This commit is contained in:
parent
0dad45ccb0
commit
085db76001
@ -9,19 +9,18 @@
|
|||||||
|
|
||||||
# WORK WORK
|
# WORK WORK
|
||||||
## NOW
|
## NOW
|
||||||
|
be able to reclaim skills / specs from cryp
|
||||||
combo specs
|
combo specs
|
||||||
|
|
||||||
standardise cryps
|
|
||||||
randomise skill speed
|
randomise skill speed
|
||||||
|
|
||||||
generate svgs
|
|
||||||
|
|
||||||
scoreboard
|
scoreboard
|
||||||
|
|
||||||
constants
|
constants
|
||||||
|
|
||||||
round system for games
|
round system for games
|
||||||
|
join instance
|
||||||
|
is pve?
|
||||||
|
add cryps to player
|
||||||
level bots every round
|
level bots every round
|
||||||
buy out vbox
|
buy out vbox
|
||||||
find any combos
|
find any combos
|
||||||
|
|||||||
@ -10,8 +10,8 @@ use failure::err_msg;
|
|||||||
use account::{Account};
|
use account::{Account};
|
||||||
use rpc::{CrypSpawnParams, CrypLearnParams, CrypForgetParams, CrypUnspecParams};
|
use rpc::{CrypSpawnParams, CrypLearnParams, CrypForgetParams, CrypUnspecParams};
|
||||||
use skill::{Skill, Cooldown, Effect, Cast, Category, Immunity, Disable, ResolutionResult};
|
use skill::{Skill, Cooldown, Effect, Cast, Category, Immunity, Disable, ResolutionResult};
|
||||||
|
use spec::{Spec};
|
||||||
use game::{Log};
|
use game::{Log};
|
||||||
use vbox::{Var};
|
|
||||||
|
|
||||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||||
pub struct CrypSkill {
|
pub struct CrypSkill {
|
||||||
@ -64,17 +64,17 @@ pub struct CrypStat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CrypStat {
|
impl CrypStat {
|
||||||
pub fn set(&mut self, v: u64, specs: &Vec<Var>) -> &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<Var>) -> &mut CrypStat {
|
pub fn recalculate(&mut self, specs: &Vec<Spec>) -> &mut CrypStat {
|
||||||
let specs = specs
|
let specs = specs
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|s| s.affects().contains(&self.stat))
|
.filter(|s| s.affects().contains(&self.stat))
|
||||||
.map(|s| *s)
|
.map(|s| *s)
|
||||||
.collect::<Vec<Var>>();
|
.collect::<Vec<Spec>>();
|
||||||
|
|
||||||
// applied with fold because it can be zeroed or multiplied
|
// applied with fold because it can be zeroed or multiplied
|
||||||
// but still needs access to the base amount
|
// but still needs access to the base amount
|
||||||
@ -127,7 +127,7 @@ pub struct Cryp {
|
|||||||
pub lvl: u8,
|
pub lvl: u8,
|
||||||
pub skills: Vec<CrypSkill>,
|
pub skills: Vec<CrypSkill>,
|
||||||
pub effects: Vec<CrypEffect>,
|
pub effects: Vec<CrypEffect>,
|
||||||
pub specs: Vec<Var>,
|
pub specs: Vec<Spec>,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub ko_logged: bool,
|
pub ko_logged: bool,
|
||||||
}
|
}
|
||||||
@ -250,20 +250,18 @@ impl Cryp {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn spec_add(&mut self, spec: Var) -> 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());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn spec_remove(&mut self, spec: Var) -> Result<Var, Error> {
|
pub fn spec_remove(&mut self, spec: Spec) -> Result<&mut Cryp, Error> {
|
||||||
let spec = match self.specs.iter().position(|s| *s == spec) {
|
match self.specs.iter().position(|s| *s == spec) {
|
||||||
Some(p) => self.specs.remove(p),
|
Some(p) => self.specs.remove(p),
|
||||||
None => return Err(err_msg("spec not found")),
|
None => return Err(err_msg("spec not found")),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.recalculate_stats();
|
Ok(self.recalculate_stats())
|
||||||
|
|
||||||
Ok(spec)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -625,6 +623,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)
|
||||||
|
.learn(Skill::Attack)
|
||||||
.level(1)
|
.level(1)
|
||||||
.set_account(account.id)
|
.set_account(account.id)
|
||||||
.create();
|
.create();
|
||||||
@ -647,6 +646,25 @@ pub fn cryp_spawn(params: CrypSpawnParams, tx: &mut Transaction, account: &Accou
|
|||||||
return Ok(cryp);
|
return Ok(cryp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn cryp_learn(params: CrypLearnParams, tx: &mut Transaction, account: &Account) -> Result<Cryp, Error> {
|
||||||
|
let mut cryp = cryp_get(tx, params.id, account.id)?;
|
||||||
|
|
||||||
|
// done here because i teach them a tonne of skills for tests
|
||||||
|
let max_skills = 4;
|
||||||
|
if cryp.skills.len() >= max_skills {
|
||||||
|
return Err(format_err!("cryp at max skills ({:?})", max_skills));
|
||||||
|
}
|
||||||
|
|
||||||
|
cryp = cryp.learn(params.skill);
|
||||||
|
return cryp_write(cryp, tx);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn cryp_forget(params: CrypForgetParams, tx: &mut Transaction, account: &Account) -> Result<Cryp, Error> {
|
||||||
|
let mut cryp = cryp_get(tx, params.id, account.id)?;
|
||||||
|
cryp = cryp.forget(params.skill)?;
|
||||||
|
return cryp_write(cryp, tx);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn cryp_unspec(params: CrypUnspecParams, tx: &mut Transaction, account: &Account) -> Result<Cryp, Error> {
|
pub fn cryp_unspec(params: CrypUnspecParams, tx: &mut Transaction, account: &Account) -> Result<Cryp, Error> {
|
||||||
let mut cryp = cryp_get(tx, params.id, account.id)?;
|
let mut cryp = cryp_get(tx, params.id, account.id)?;
|
||||||
cryp.spec_remove(params.spec)?;
|
cryp.spec_remove(params.spec)?;
|
||||||
|
|||||||
@ -22,6 +22,7 @@ mod cryp;
|
|||||||
mod game;
|
mod game;
|
||||||
mod net;
|
mod net;
|
||||||
mod skill;
|
mod skill;
|
||||||
|
mod spec;
|
||||||
// mod passives;
|
// mod passives;
|
||||||
mod rpc;
|
mod rpc;
|
||||||
mod account;
|
mod account;
|
||||||
|
|||||||
@ -20,9 +20,10 @@ use game::{Game, game_state, game_pve, 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};
|
||||||
|
use spec::{Spec};
|
||||||
use player::{player_state, player_cryps_set, Player};
|
use player::{player_state, player_cryps_set, Player};
|
||||||
use instance::{instance_join, instance_ready};
|
use instance::{instance_join, instance_ready};
|
||||||
use vbox::{Var, vbox_accept, vbox_apply, vbox_discard, vbox_combine, vbox_reclaim};
|
use vbox::{vbox_accept, vbox_apply, vbox_discard, vbox_combine, vbox_reclaim};
|
||||||
|
|
||||||
pub struct Rpc;
|
pub struct Rpc;
|
||||||
|
|
||||||
@ -432,7 +433,7 @@ struct CrypForgetMsg {
|
|||||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||||
pub struct CrypUnspecParams {
|
pub struct CrypUnspecParams {
|
||||||
pub id: Uuid,
|
pub id: Uuid,
|
||||||
pub spec: Var,
|
pub spec: Spec,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||||
|
|||||||
64
server/src/spec.rs
Normal file
64
server/src/spec.rs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
use rand::prelude::*;
|
||||||
|
|
||||||
|
use cryp::{Stat};
|
||||||
|
|
||||||
|
#[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)]
|
||||||
|
pub enum Spec {
|
||||||
|
SpeedI,
|
||||||
|
|
||||||
|
// Pure redShield has to come first as it applies the base amount
|
||||||
|
// that is multiplied
|
||||||
|
LifeI,
|
||||||
|
RedShieldI,
|
||||||
|
BlueShieldI,
|
||||||
|
LRSI,
|
||||||
|
LBSI,
|
||||||
|
RBSI,
|
||||||
|
|
||||||
|
RedDamageI,
|
||||||
|
GreenDamageI,
|
||||||
|
BlueDamageI,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Spec {
|
||||||
|
pub fn affects(&self) -> Vec<Stat> {
|
||||||
|
match *self {
|
||||||
|
Spec::RedDamageI => vec![Stat::RedDamage],
|
||||||
|
Spec::GreenDamageI => vec![Stat::GreenDamage],
|
||||||
|
Spec::BlueDamageI => vec![Stat::BlueDamage],
|
||||||
|
|
||||||
|
Spec::SpeedI => vec![Stat::Speed],
|
||||||
|
|
||||||
|
Spec::RedShieldI => vec![Stat::RedShield],
|
||||||
|
Spec::BlueShieldI => vec![Stat::BlueShield],
|
||||||
|
Spec::LifeI => vec![Stat::Hp],
|
||||||
|
Spec::LRSI => vec![Stat::Hp, Stat::RedShield],
|
||||||
|
Spec::LBSI => vec![Stat::Hp, Stat::BlueShield],
|
||||||
|
Spec::RBSI => vec![Stat::BlueShield, Stat::RedShield],
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn apply(&self, modified: u64, base: u64) -> u64 {
|
||||||
|
let mut rng = thread_rng();
|
||||||
|
|
||||||
|
let i_min = 32;
|
||||||
|
let i_max = 64;
|
||||||
|
|
||||||
|
match *self {
|
||||||
|
Spec::RedDamageI => modified + (base * 5 / 100),
|
||||||
|
Spec::GreenDamageI => modified + (base * 5 / 100),
|
||||||
|
Spec::BlueDamageI => modified + (base * 5 / 100),
|
||||||
|
|
||||||
|
Spec::SpeedI => modified + (base * 5 / 100),
|
||||||
|
|
||||||
|
Spec::LifeI => modified + (base * 5 / 100),
|
||||||
|
Spec::RedShieldI => modified + rng.gen_range(i_min, i_max),
|
||||||
|
Spec::BlueShieldI => modified + rng.gen_range(i_min, i_max),
|
||||||
|
Spec::LRSI => modified + (base * 5 / 100),
|
||||||
|
Spec::LBSI => modified + (base * 5 / 100),
|
||||||
|
Spec::RBSI => modified + (base * 5 / 100),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -14,8 +14,8 @@ use failure::err_msg;
|
|||||||
use account::Account;
|
use account::Account;
|
||||||
use rpc::{VboxAcceptParams, VboxDiscardParams, VboxCombineParams, VboxApplyParams, VboxReclaimParams};
|
use rpc::{VboxAcceptParams, VboxDiscardParams, VboxCombineParams, VboxApplyParams, VboxReclaimParams};
|
||||||
use skill::{Skill};
|
use skill::{Skill};
|
||||||
|
use spec::{Spec};
|
||||||
use player::{Player, player_get, player_update};
|
use player::{Player, player_get, player_update};
|
||||||
use cryp::{Stat};
|
|
||||||
|
|
||||||
#[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)]
|
#[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)]
|
||||||
pub enum Var {
|
pub enum Var {
|
||||||
@ -110,7 +110,7 @@ impl Var {
|
|||||||
if let Some(_skill) = self.skill() {
|
if let Some(_skill) = self.skill() {
|
||||||
return Some(VarEffect::Skill);
|
return Some(VarEffect::Skill);
|
||||||
}
|
}
|
||||||
if self.spec() {
|
if let Some(_spec) = self.spec() {
|
||||||
return Some(VarEffect::Spec);
|
return Some(VarEffect::Spec);
|
||||||
}
|
}
|
||||||
return None;
|
return None;
|
||||||
@ -147,63 +147,22 @@ impl Var {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spec(&self) -> bool {
|
fn spec(&self) -> Option<Spec> {
|
||||||
match *self {
|
match *self {
|
||||||
Var::Speed => true,
|
Var::Speed => Some(Spec::SpeedI),
|
||||||
|
|
||||||
Var::RedDamageI => true,
|
Var::RedDamageI => Some(Spec::RedDamageI),
|
||||||
Var::BlueDamageI => true,
|
Var::BlueDamageI => Some(Spec::BlueDamageI),
|
||||||
Var::GreenDamageI => true,
|
Var::GreenDamageI => Some(Spec::GreenDamageI),
|
||||||
|
|
||||||
Var::LifeI => true,
|
Var::LifeI => Some(Spec::LifeI),
|
||||||
Var::LRSI => true,
|
Var::LRSI => Some(Spec::LRSI),
|
||||||
Var::LBSI => true,
|
Var::LBSI => Some(Spec::LBSI),
|
||||||
Var::RBSI => true,
|
Var::RBSI => Some(Spec::RBSI),
|
||||||
Var::RedShieldI => true,
|
Var::RedShieldI => Some(Spec::RedShieldI),
|
||||||
Var::BlueShieldI => true,
|
Var::BlueShieldI => Some(Spec::BlueShieldI),
|
||||||
|
|
||||||
_ => false,
|
_ => None,
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn affects(&self) -> Vec<Stat> {
|
|
||||||
match self {
|
|
||||||
Var::RedDamageI => vec![Stat::RedDamage],
|
|
||||||
Var::GreenDamageI => vec![Stat::GreenDamage],
|
|
||||||
Var::BlueDamageI => vec![Stat::BlueDamage],
|
|
||||||
|
|
||||||
Var::Speed => vec![Stat::Speed],
|
|
||||||
|
|
||||||
Var::RedShieldI => vec![Stat::RedShield],
|
|
||||||
Var::BlueShieldI => vec![Stat::BlueShield],
|
|
||||||
Var::LifeI => vec![Stat::Hp],
|
|
||||||
Var::LRSI => vec![Stat::Hp, Stat::RedShield],
|
|
||||||
Var::LBSI => vec![Stat::Hp, Stat::BlueShield],
|
|
||||||
Var::RBSI => vec![Stat::BlueShield, Stat::RedShield],
|
|
||||||
_ => panic!("{:?} is not a spec item", self),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn apply(&self, modified: u64, base: u64) -> u64 {
|
|
||||||
let mut rng = thread_rng();
|
|
||||||
|
|
||||||
let i_min = 32;
|
|
||||||
let i_max = 64;
|
|
||||||
|
|
||||||
match self {
|
|
||||||
Var::RedDamageI => modified + (base * 5 / 100),
|
|
||||||
Var::GreenDamageI => modified + (base * 5 / 100),
|
|
||||||
Var::BlueDamageI => modified + (base * 5 / 100),
|
|
||||||
|
|
||||||
Var::Speed => modified + (base * 5 / 100),
|
|
||||||
|
|
||||||
Var::LifeI => modified + (base * 5 / 100),
|
|
||||||
Var::RedShieldI => modified + rng.gen_range(i_min, i_max),
|
|
||||||
Var::BlueShieldI => modified + rng.gen_range(i_min, i_max),
|
|
||||||
Var::LRSI => modified + (base * 5 / 100),
|
|
||||||
Var::LBSI => modified + (base * 5 / 100),
|
|
||||||
Var::RBSI => modified + (base * 5 / 100),
|
|
||||||
_ => panic!("{:?} is not a spec item", self),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -466,8 +425,9 @@ pub fn vbox_apply(params: VboxApplyParams, tx: &mut Transaction, account: &Accou
|
|||||||
cryp.learn_mut(skill);
|
cryp.learn_mut(skill);
|
||||||
},
|
},
|
||||||
Some(VarEffect::Spec) => {
|
Some(VarEffect::Spec) => {
|
||||||
|
let spec = var.spec().ok_or(format_err!("var {:?} has no associated spec", var))?;
|
||||||
let cryp = player.cryp_get(params.cryp_id)?;
|
let cryp = player.cryp_get(params.cryp_id)?;
|
||||||
cryp.spec_add(var)?;
|
cryp.spec_add(spec)?;
|
||||||
|
|
||||||
},
|
},
|
||||||
None => return Err(err_msg("var has no effect on cryps")),
|
None => return Err(err_msg("var has no effect on cryps")),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user