From cf3dbaa6e9342350d35bccfba825ec46ded4f7c5 Mon Sep 17 00:00:00 2001 From: ntr Date: Thu, 14 Mar 2019 17:11:43 +1100 Subject: [PATCH 1/4] global join better --- server/src/instance.rs | 3 +-- server/src/player.rs | 18 +++++++++++------- server/src/rpc.rs | 7 +------ 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/server/src/instance.rs b/server/src/instance.rs index 896bb2ca..bba1b5ed 100644 --- a/server/src/instance.rs +++ b/server/src/instance.rs @@ -402,7 +402,7 @@ pub fn instance_join(params: InstanceJoinParams, tx: &mut Transaction, account: let mut player = Player::new(account.id, instance.id, cryps); player.vbox.fill(); - player_create(tx, &player, account)?; + let player = player_create(tx, player, account)?; instance.add_player(player.clone()); @@ -475,7 +475,6 @@ pub fn instance_game_finished(tx: &mut Transaction, game: &Game, instance_id: Uu true => player.add_win(), false => player.add_loss(), }; - println!("{:?}", player); player_update(tx, player, true)?; }, } diff --git a/server/src/player.rs b/server/src/player.rs index 099dfed8..c2efdb9d 100644 --- a/server/src/player.rs +++ b/server/src/player.rs @@ -94,7 +94,7 @@ pub fn player_get(tx: &mut Transaction, account_id: Uuid, instance_id: Uuid) -> return Ok(data); } -pub fn player_create(tx: &mut Transaction, player: &Player, account: &Account) -> Result<(), Error> { +pub fn player_create(tx: &mut Transaction, player: Player, account: &Account) -> Result { let player_bytes = to_vec(&player)?; let query = " @@ -110,7 +110,7 @@ pub fn player_create(tx: &mut Transaction, player: &Player, account: &Account) - println!("wrote player {:} joined instance: {:}", account.name, player.instance); - return Ok(()); + return Ok(player); } pub fn player_update(tx: &mut Transaction, player: Player, ignore_phase: bool) -> Result { @@ -168,14 +168,18 @@ pub fn player_cryps_set(params: PlayerCrypsSetParams, tx: &mut Transaction, acco return Err(err_msg("team size is 3")); } - let mut player = player_get(tx, account.id, Uuid::nil())?; - let cryps = params.cryp_ids .iter() .map(|id| cryp_get(tx, *id, account.id)) .collect::, Error>>()?; - player.cryps = cryps; - - player_update(tx, player, false) + match player_get(tx, account.id, Uuid::nil()) { + Ok(mut p) => { + p.cryps = cryps; + player_update(tx, p, false) + }, + Err(_) => { + return player_create(tx, Player::new(account.id, Uuid::nil(), cryps), &account) + } + } } diff --git a/server/src/rpc.rs b/server/src/rpc.rs index c888fe53..40887e1a 100644 --- a/server/src/rpc.rs +++ b/server/src/rpc.rs @@ -21,7 +21,7 @@ use account::{Account, account_create, account_login, account_from_token, accoun use skill::{Skill}; // use zone::{Zone, zone_create, zone_join, zone_close}; use spec::{Spec}; -use player::{player_state, player_create, player_cryps_set, Player}; +use player::{player_state, player_cryps_set, Player}; use instance::{instance_join, instance_ready}; use vbox::{vbox_accept, vbox_apply, vbox_discard, vbox_combine, vbox_drop}; @@ -163,8 +163,6 @@ impl Rpc { let msg = from_slice::(&data).or(Err(err_msg("invalid params")))?; let account = account_create(msg.params, tx)?; - let player = Player::new(account.id, Uuid::nil(), vec![]); - player_create(tx, &player, &account)?; Ok(RpcResponse { method: "account_create".to_string(), @@ -198,9 +196,6 @@ impl Rpc { let name: String = iter::repeat(()).map(|()| rng.sample(Alphanumeric)).take(8).collect(); cryp_spawn(CrypSpawnParams { name }, tx, &account)?; - let player = Player::new(account.id, Uuid::nil(), vec![]); - player_create(tx, &player, &account)?; - let res = RpcResponse { method: "account_create".to_string(), params: RpcResult::Account(account), From 9d02499c5aec62cd435a17ae4b07811f75ed8611 Mon Sep 17 00:00:00 2001 From: ntr Date: Thu, 14 Mar 2019 18:03:21 +1100 Subject: [PATCH 2/4] simplify spec and skill var checks --- client/src/scenes/statsheet.js | 2 +- server/src/vbox.rs | 136 +++++++++++++-------------------- 2 files changed, 56 insertions(+), 82 deletions(-) diff --git a/client/src/scenes/statsheet.js b/client/src/scenes/statsheet.js index 45515f53..2bca7e91 100644 --- a/client/src/scenes/statsheet.js +++ b/client/src/scenes/statsheet.js @@ -63,7 +63,7 @@ class StatSheet extends Phaser.Scene { const crypStat = (stat, i) => { const STAT_X = X; const STAT_Y = Y + (i + 2) * TEXT_MARGIN; - this.add.text(STAT_X, STAT_Y, `${stat.stat}: ${stat.value}`, TEXT.NORMAL); + this.add.text(STAT_X, STAT_Y, `${stat.stat}: ${stat.base} -> ${stat.value}`, TEXT.NORMAL); }; const CRYP_STATS = [ diff --git a/server/src/vbox.rs b/server/src/vbox.rs index d59b2d6b..10ffa762 100644 --- a/server/src/vbox.rs +++ b/server/src/vbox.rs @@ -35,7 +35,7 @@ pub enum Var { Damage, Protection, Speed, - Hp, + Stamina, StaminaI, RedDamageI, @@ -94,84 +94,57 @@ impl Var { } } - fn effect(&self) -> Result { + fn effect(&self) -> Option { + if let Some(_skill) = self.skill() { + return Some(VarEffect::Skill); + } + if let Some(_spec) = self.spec() { + return Some(VarEffect::Spec); + } + return None; + } + + fn skill(&self) -> Option { match self { - Var::Amplify | - Var::Banish | - Var::Blast | - Var::Curse | - Var::Empower | - Var::Haste | - Var::Heal | - Var::Hex | - Var::Parry | - Var::Purge | - Var::Purify | - // Var::Reflect | - Var::Ruin | - Var::Shield | - Var::Silence | - Var::Slay | - Var::Slow | - Var::Snare | - Var::Strangle | - Var::Strike | - // Var::Clutch | - // Var::Taunt | - Var::Throw | - // Var::Toxic | - Var::Triage => Ok(VarEffect::Skill), - - Var::StaminaI | - Var::RedShieldI | - Var::BlueShieldI | - Var::SpeedI => Ok(VarEffect::Spec), - - _ => Err(err_msg("var has no effect on cryps")) + Var::Amplify => Some(Skill::Amplify), + Var::Banish => Some(Skill::Banish), + Var::Blast => Some(Skill::Blast), + Var::Curse => Some(Skill::Curse), + Var::Empower => Some(Skill::Empower), + Var::Haste => Some(Skill::Haste), + Var::Heal => Some(Skill::Heal), + Var::Hex => Some(Skill::Hex), + Var::Parry => Some(Skill::Parry), + Var::Purge => Some(Skill::Purge), + Var::Purify => Some(Skill::Purify), + // Var::Reflect => Some(Skill::Reflect), + Var::Ruin => Some(Skill::Ruin), + Var::Shield => Some(Skill::Shield), + Var::Silence => Some(Skill::Silence), + Var::Slay => Some(Skill::Slay), + Var::Slow => Some(Skill::Slow), + Var::Snare => Some(Skill::Snare), + Var::Strangle => Some(Skill::Strangle), + Var::Strike => Some(Skill::Strike), + // Var::Clutch => Some(Skill::Clutch), + // Var::Taunt => Some(Skill::Taunt), + Var::Throw => Some(Skill::Throw), + // Var::Toxic => Some(Skill::Toxic), + Var::Triage => Some(Skill::Triage), + _ => None, } } - fn skill(&self) -> Skill { - match self { - Var::Amplify => Skill::Amplify, - Var::Banish => Skill::Banish, - Var::Blast => Skill::Blast, - Var::Curse => Skill::Curse, - Var::Empower => Skill::Empower, - Var::Haste => Skill::Haste, - Var::Heal => Skill::Heal, - Var::Hex => Skill::Hex, - Var::Parry => Skill::Parry, - Var::Purge => Skill::Purge, - Var::Purify => Skill::Purify, - // Var::Reflect => Skill::Reflect, - Var::Ruin => Skill::Ruin, - Var::Shield => Skill::Shield, - Var::Silence => Skill::Silence, - Var::Slay => Skill::Slay, - Var::Slow => Skill::Slow, - Var::Snare => Skill::Snare, - Var::Strangle => Skill::Strangle, - Var::Strike => Skill::Strike, - // Var::Clutch => Skill::Clutch, - // Var::Taunt => Skill::Taunt, - Var::Throw => Skill::Throw, - // Var::Toxic => Skill::Toxic, - Var::Triage => Skill::Triage, - _ => panic!("not a skill var"), - } - } - - fn spec(&self) -> Spec { + fn spec(&self) -> Option { match *self { - Var::StaminaI => Spec::StaminaI, - Var::SpeedI => Spec::SpeedI, - Var::RedDamageI => Spec::RedDamageI, - Var::BlueDamageI => Spec::BlueDamageI, - Var::GreenDamageI => Spec::GreenDamageI, - Var::RedShieldI => Spec::RedShieldI, - Var::BlueShieldI => Spec::BlueShieldI, - _ => panic!("not a spec var"), + Var::StaminaI => Some(Spec::StaminaI), + Var::SpeedI => Some(Spec::SpeedI), + Var::RedDamageI => Some(Spec::RedDamageI), + Var::BlueDamageI => Some(Spec::BlueDamageI), + Var::GreenDamageI => Some(Spec::GreenDamageI), + Var::RedShieldI => Some(Spec::RedShieldI), + Var::BlueShieldI => Some(Spec::BlueShieldI), + _ => None, } } } @@ -243,7 +216,7 @@ impl Vbox { (Var::Damage, 1), (Var::Protection, 1), (Var::Speed, 1), - (Var::Hp, 1), + (Var::Stamina, 1), ]; let mut rng = thread_rng(); @@ -387,7 +360,7 @@ impl Vbox { }, Var::Protection => match colour_code { ColourCode::RR => Var::RedShieldI, - ColourCode::GG => return Err(err_msg("unhandled skill combo")), + ColourCode::GG => Var::StaminaI, ColourCode::BB => Var::BlueShieldI, ColourCode::RG => return Err(err_msg("unhandled skill combo")), ColourCode::GB => return Err(err_msg("unhandled skill combo")), @@ -432,9 +405,9 @@ pub fn vbox_apply(params: VboxApplyParams, tx: &mut Transaction, account: &Accou let mut player = player_get(tx, account.id, params.instance_id)?; let var = player.vbox.bound.remove(params.index); - match var.effect()? { - VarEffect::Skill => { - let skill = var.skill(); + match var.effect() { + Some(VarEffect::Skill) => { + let skill = var.skill().ok_or(format_err!("var {:?} has no associated skill", var))?; let cryp = player.cryp_get(params.cryp_id)?; // done here because i teach them a tonne of skills for tests let max_skills = 4; @@ -444,12 +417,13 @@ pub fn vbox_apply(params: VboxApplyParams, tx: &mut Transaction, account: &Accou cryp.learn_mut(skill); }, - VarEffect::Spec => { - let spec = var.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)?; cryp.spec_add(spec)?; }, + None => return Err(err_msg("var has no effect on cryps")), } return player_update(tx, player, false); From 788c68c01504c671e2bd79cf8d361877dfa9876b Mon Sep 17 00:00:00 2001 From: ntr Date: Thu, 14 Mar 2019 18:57:44 +1100 Subject: [PATCH 3/4] stam -> hp --- client/src/scenes/elements/combat.statbar.js | 2 +- client/src/scenes/statsheet.js | 2 +- client/src/tutorial.js | 2 +- server/NODES.md | 2 +- server/README.md | 6 +-- server/SPECS.md | 43 ++++++++------------ server/src/cryp.rs | 41 +++++++------------ server/src/item.rs | 8 ++-- server/src/skill.rs | 2 +- server/src/spec.rs | 6 +-- server/src/vbox.rs | 27 ++++++------ 11 files changed, 61 insertions(+), 80 deletions(-) diff --git a/client/src/scenes/elements/combat.statbar.js b/client/src/scenes/elements/combat.statbar.js index e35500c9..e132b6e1 100644 --- a/client/src/scenes/elements/combat.statbar.js +++ b/client/src/scenes/elements/combat.statbar.js @@ -28,7 +28,7 @@ class StatBar extends Phaser.GameObjects.Graphics { if (type === 'HP') { this.val = this.crypObj.cryp.hp.value; - this.max = this.crypObj.cryp.stamina.value; + this.max = this.crypObj.cryp.hp.value; this.margin = 0; } else if (type === 'Red Shield') { this.val = this.crypObj.cryp.red_shield.value; diff --git a/client/src/scenes/statsheet.js b/client/src/scenes/statsheet.js index 2bca7e91..43b7bfbc 100644 --- a/client/src/scenes/statsheet.js +++ b/client/src/scenes/statsheet.js @@ -67,7 +67,7 @@ class StatSheet extends Phaser.Scene { }; const CRYP_STATS = [ - cryp.stamina, + cryp.hp, cryp.red_shield, cryp.blue_shield, cryp.evasion, diff --git a/client/src/tutorial.js b/client/src/tutorial.js index ecc092ed..a73ff00d 100644 --- a/client/src/tutorial.js +++ b/client/src/tutorial.js @@ -19,7 +19,7 @@ This homepage shows your cryps, joinable online games, PVE options and your item If you have no cryps yet, press SPAWN and give your cryp a name to create one. Once you have made a cryp, click on them to visit their stat page and teach them some SKILLS. The stat page also has descriptions of each skill and their effects. -cryps have 3 basic stats: stamina, red damage and magic damage. +cryps have 3 basic stats: hp, red damage and magic damage. Toggle whether a cryp is selected for your team by clicking the coloured stripes next to the cryp or press 1,2,3. Once you have a team ready press the New PVE Game button to start playing. `; diff --git a/server/NODES.md b/server/NODES.md index a6004f8e..887ee186 100644 --- a/server/NODES.md +++ b/server/NODES.md @@ -3,7 +3,7 @@ ### Defenses ### -Rare `Increased Stamina` +Rare `Increased Hp` Common `Increased Evasion rating` Common `Increased Blue Shield rating` diff --git a/server/README.md b/server/README.md index 5bca346a..19dbe7c4 100644 --- a/server/README.md +++ b/server/README.md @@ -76,7 +76,7 @@ Non-Violence Enhancement & Preservation -------------------------- -the philosophy of nonviolence teaches that the sanctity of life is above all else +the philosophy of nonviolence teaches that the sanctity of hp is above all else its adherants are defensive and gracious, seeking to minimise the damage done by others and doing no direct harm themselves. they seek to prevent damage in any way possible @@ -98,8 +98,8 @@ specialise in magical damage dealing * damage amplification * nukes -* life leach -* life exchange +* hp leach +* hp exchange * poison * aoe diff --git a/server/SPECS.md b/server/SPECS.md index 21b8656a..d71f9b2c 100644 --- a/server/SPECS.md +++ b/server/SPECS.md @@ -39,7 +39,7 @@ In your team Cryp #1 has `Strike`, Cryp #2 has `Slay` and `Heal`, Cryp #3 has `S - Cryp #2 Unequip Attack - Combine 2 Green + 'Attack' -> Heal - + - Cryp #3 Unequip Stun - Combine 2 Blue + 'Stun' -> Ruin @@ -74,7 +74,7 @@ In your team Cryp #1 has `Strike`, Cryp #2 has `Slay` and `Heal`, Cryp #3 has `S - Combine 'Strike' + 2 x Red Damage spec -> 'Increased Strike Damage spec' ### Note 'Increased Strike Damage spec' requires 8R on the cryp - + Cryp #1 Equip Increased Strike Damage spec -> Strike, Stun, Strangle, Empower + Increased Strike Damage Spec (14R) Cryp #2 -> 'No change' -> Heal Cryp #3 -> 'No change' -> Attack + Ruin + 2 x Basic Damage Spec @@ -85,17 +85,10 @@ In your team Cryp #1 has `Strike`, Cryp #2 has `Slay` and `Heal`, Cryp #3 has `S ### Generic Specs -(Base white skills not upgraded count as have 1 gem basic ?) - -# Basic Damage -`Base` -> 10% inc basic damage -`Team Bonus` -> 3 basic gems -> +10% // 6 basic gems -> +15% // 12 basic gems -> +25% -Maximum 60% inc basic damage - -# Basic % Life -`Base` -> 5% inc life +# Basic % Hp +`Base` -> 5% inc hp `Team Bonus` -> 3 basic gems -> +5% // 6 basic gems -> +10% // 12 basic gems -> +15% -Maximum 35% inc life +Maximum 35% inc hp # Basic Speed `Base` -> 5% inc speed @@ -110,15 +103,15 @@ Maximum 50% inc speed Generate by combining `Generic Spec (Basic Damage)` with respective RGB -# Red Damage (Dmg + RR) +# Red Damage (Dmg + RR) Add 2 `red gems` -`Base` -> 10% inc red dmg +`Base` -> 10% inc red dmg `Team Bonus` 5 red gems -> +10% // 10 red gems -> +15% // 20 red gems -> +25% Maximum +60% red damage # Blue Damage (Dmg + BB) # Add 2 `blue gems` -`Base` -> 10% inc blue dmg +`Base` -> 10% inc blue dmg `Team Bonus` 5 blue gems -> +10% // 10 blue gems -> +15% // 20 blue gems -> +25% Maximum +60% blue damage @@ -146,9 +139,9 @@ Add 1 blue and 1 green gem `Team Bonus` (2B + 2G gems) -> +5% + 5% // (5B + 5G gems) -> +10% + 10% % // (10B + 10G) gems -> +15% + 15% Maximum +35% inc blue damage and 35% inc healing -### Increased Life Combos ### +### Increased Hp Combos ### -Generate by combining `Generic Spec (Basic Life)` with respective RGB +Generate by combining `Generic Spec (Basic Hp)` with respective RGB # Increased % Red Shield (Basic %HP + 2R) Add 2 `red gems` @@ -156,11 +149,11 @@ Add 2 `red gems` `Team Bonus` 5 red gems -> +10% // 10 red gems -> +15% // 20 red gems -> +20% Maximum +55% inc red shield -# Increased % Red Shield and Life (Basic %HP + 1R1G) +# Increased % Red Shield and Hp (Basic %HP + 1R1G) Add 1 red 1 green gem -`Base` -> 5% inc red shield and 5% inc life +`Base` -> 5% inc red shield and 5% inc hp `Team Bonus` (2R + 2G gems) -> +5% + 5% // (5R + 5G gems) -> +10% + 10% % // (10R + 10G) gems -> +15% + 15% -Maximum +35% inc red shield and 35% inc life +Maximum +35% inc red shield and 35% inc hp # Increased % Blue Shield (Basic %HP + 2B) Add 2 `blue gems` @@ -168,13 +161,13 @@ Add 2 `blue gems` `Team Bonus` 5 blue gems -> +10% // 10 blue gems -> +15% // 20 blue gems -> +20% Maximum +55% inc blue shield -# Increased % Blue Shield and Life (Basic %HP + 1B1G) +# Increased % Blue Shield and Hp (Basic %HP + 1B1G) Add `1 blue and 1 green gems` -`Base` -> 5% inc red shield and 5% inc life +`Base` -> 5% inc red shield and 5% inc hp `Team Bonus` (2B + 2G gems) -> +5% + 5% // (5B + 5G gems) -> +10% + 10% % // (10B + 10G) gems -> +15% + 15% -Maximum +35% inc blue shield and 35% inc life +Maximum +35% inc blue shield and 35% inc hp -# Increased % Life (Basic %HP + 2G) +# Increased % Hp (Basic %HP + 2G) Add `2 green gems` `Base` -> 10% inc hp `Team Bonus` 5 green gems -> +10% // 10 green gems -> +15% // 20 green gems -> +20% @@ -182,7 +175,7 @@ Maximum +55% inc hp # Increased % Blue and Red Shield (Basic %HP + 1B1R) Add `1 blue and 1 red gem` -`Base` -> 5% inc red shield and 5% inc life +`Base` -> 5% inc red shield and 5% inc hp `Team Bonus` (2B + 2R gems) -> +5% + 5% // (5B + 5R gems) -> +10% + 10% % // (10B + 10R) gems -> +15% + 15% Maximum +35% inc blue shield and 35% inc red shield diff --git a/server/src/cryp.rs b/server/src/cryp.rs index 6d19e771..c087b45a 100644 --- a/server/src/cryp.rs +++ b/server/src/cryp.rs @@ -44,7 +44,6 @@ pub enum Stat { Int, Hp, Speed, - Stamina, RedDamage, RedDamageTaken, BlueDamage, @@ -60,6 +59,7 @@ pub enum Stat { pub struct CrypStat { base: u64, value: u64, + max: u64, pub stat: Stat, } @@ -80,6 +80,7 @@ impl CrypStat { // but still needs access to the base amount let value = specs.iter().fold(self.base, |acc, s| s.apply(acc, self.base)); self.value = value; + self.max = value; self } @@ -120,7 +121,6 @@ pub struct Cryp { pub blue_shield: CrypStat, pub blue_damage: CrypStat, pub speed: CrypStat, - pub stamina: CrypStat, pub hp: CrypStat, pub evasion: CrypStat, pub xp: u64, @@ -143,14 +143,13 @@ impl Cryp { return Cryp { id, account: id, - red_damage: CrypStat { base: 0, value: 0, stat: Stat::RedDamage }, - red_shield: CrypStat { base: 0, value: 0, stat: Stat::RedShield }, - blue_damage: CrypStat { base: 0, value: 0, stat: Stat::BlueDamage }, - blue_shield: CrypStat { base: 0, value: 0, stat: Stat::BlueShield }, - speed: CrypStat { base: 0, value: 0, stat: Stat::Speed }, - stamina: CrypStat { base: 0, value: 0, stat: Stat::Stamina }, - hp: CrypStat { base: 0, value: 0, stat: Stat::Hp }, - evasion: CrypStat { base: 0, value: 0, stat: Stat::Evasion }, + red_damage: CrypStat { base: 0, value: 0, max: 0, 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_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 }, + evasion: CrypStat { base: 0, value: 0, max: 0, stat: Stat::Evasion }, lvl: 0, xp: 0, skills: vec![], @@ -225,10 +224,7 @@ impl Cryp { Stat::RedDamage => self.red_damage.set(rng.gen_range(stat_min, stat_max), &self.specs), Stat::BlueDamage => self.blue_damage.set(rng.gen_range(stat_min, stat_max), &self.specs), Stat::Speed => self.speed.set(rng.gen_range(stat_min, stat_max), &self.specs), - Stat::Stamina => { - self.stamina.set(rng.gen_range(stam_min, stam_max), &self.specs); - self.hp.set(self.stamina.base, &self.specs) - }, + Stat::Hp => self.hp.set(rng.gen_range(stam_min, stam_max), &self.specs), Stat::BlueShield => self.blue_shield.set(rng.gen_range(stat_min, stat_max), &self.specs), Stat::RedShield => self.red_shield.set(rng.gen_range(stat_min, stat_max), &self.specs), Stat::Evasion => self.evasion.set(rng.gen_range(evasion_min, evasion_max), &self.specs), @@ -249,7 +245,7 @@ impl Cryp { self.roll_stat(Stat::RedDamage); self.roll_stat(Stat::BlueDamage); self.roll_stat(Stat::Speed); - self.roll_stat(Stat::Stamina); + self.roll_stat(Stat::Hp); self } @@ -276,10 +272,7 @@ impl Cryp { self.blue_shield.recalculate(&self.specs); self.evasion.recalculate(&self.specs); self.speed.recalculate(&self.specs); - - // special case where hp is tied to stam - self.stamina.recalculate(&self.specs); - self.hp.set(self.stamina.value, &self.specs); + self.hp.recalculate(&self.specs); self } @@ -406,7 +399,7 @@ impl Cryp { } // pub fn rez(&mut self) -> &mut Cryp { - // self.hp.set(self.stamina.base); + // self.hp.set(self.hp.base); // self // } @@ -449,10 +442,6 @@ impl Cryp { self.hp.value } - pub fn stamina(&self) -> u64 { - self.stamina.value - } - pub fn heal(&mut self, skill: Skill, amount: u64) -> ResolutionResult { let immunity = self.immune(skill); let immune = immunity.immune; @@ -478,7 +467,7 @@ impl Cryp { let current_hp = self.hp(); let new_hp = *[ self.hp().saturating_add(modified_healing), - self.stamina() + self.hp.max ].iter().min().unwrap(); let healing = new_hp - current_hp; @@ -597,7 +586,7 @@ impl Cryp { } let mut rng = thread_rng(); - let hp_pct = (self.hp.value * 100) / self.stamina.value; + let hp_pct = (self.hp.value * 100) / self.hp.value; let evasion_rating = (self.evasion.value * hp_pct) / 100; let roll = rng.gen_range(0, 100); println!("{:} < {:?}", roll, evasion_rating); diff --git a/server/src/item.rs b/server/src/item.rs index 4f499842..20459905 100644 --- a/server/src/item.rs +++ b/server/src/item.rs @@ -20,7 +20,7 @@ pub enum ItemAction { RerollRedDamage, RerollBlueDamage, RerollSpeed, - RerollStamina, + RerollHp, RerollRedShield, RerollBlueShield, RerollEvasion, @@ -52,7 +52,7 @@ impl Item { fn apply(&mut self, tx: &mut Transaction, target: Uuid) -> Result<(), Error> { match self.action { - ItemAction::RerollStamina => reroll(self, tx, target, Stat::Stamina), + ItemAction::RerollHp => reroll(self, tx, target, Stat::Hp), ItemAction::RerollRedDamage => reroll(self, tx, target, Stat::RedDamage), ItemAction::RerollBlueDamage => reroll(self, tx, target, Stat::BlueDamage), ItemAction::RerollSpeed => reroll(self, tx, target, Stat::Speed), @@ -85,7 +85,7 @@ fn reroll(item: &mut Item, tx: &mut Transaction, target: Uuid, stat: Stat) -> Re fn mode_drops(mode: GameMode) -> Vec<(ItemAction, usize)> { match mode { GameMode::Normal => vec![ - (ItemAction::RerollStamina, 1), + (ItemAction::RerollHp, 1), (ItemAction::RerollRedDamage, 1), (ItemAction::RerollBlueDamage, 1), ], @@ -103,7 +103,7 @@ fn mode_drops(mode: GameMode) -> Vec<(ItemAction, usize)> { (ItemAction::RerollSpeed, 1), ], // _ => vec![ - // (ItemAction::RerollStamina, 1), + // (ItemAction::RerollHp, 1), // (ItemAction::RerollRedDamage, 1), // (ItemAction::RerollBlueDamage, 1), // (ItemAction::RerollSpeed, 1), diff --git a/server/src/skill.rs b/server/src/skill.rs index 048d81a7..08c4e29c 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -1045,7 +1045,7 @@ mod tests { y.reduce_effect_durations(&mut log); let _decay = y.effects.iter().find(|e| e.effect == Effect::Decay); - // assert!(y.hp() == y.stamina().saturating_sub(decay.unwrap().tick.unwrap().amount)); + // assert!(y.hp() == y.hp().saturating_sub(decay.unwrap().tick.unwrap().amount)); } #[test] diff --git a/server/src/spec.rs b/server/src/spec.rs index ce5bee3a..03c3ab54 100644 --- a/server/src/spec.rs +++ b/server/src/spec.rs @@ -3,7 +3,7 @@ use cryp::{Stat}; #[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq)] pub enum Spec { SpeedI, - StaminaI, + HpI, RedDamageI, GreenDamageI, BlueDamageI, @@ -20,7 +20,7 @@ impl Spec { Spec::RedShieldI => Stat::RedShield, Spec::BlueShieldI => Stat::BlueShield, Spec::SpeedI => Stat::Speed, - Spec::StaminaI => Stat::Stamina, + Spec::HpI => Stat::Hp, } } @@ -30,7 +30,7 @@ impl Spec { Spec::GreenDamageI => modified + (base * 5 / 100), Spec::BlueDamageI => modified + (base * 5 / 100), Spec::SpeedI => modified + (base * 5 / 100), - Spec::StaminaI => modified + (base * 5 / 100), + Spec::HpI => modified + (base * 5 / 100), Spec::RedShieldI => modified + 50, Spec::BlueShieldI => modified + 50, } diff --git a/server/src/vbox.rs b/server/src/vbox.rs index 10ffa762..d31e9758 100644 --- a/server/src/vbox.rs +++ b/server/src/vbox.rs @@ -33,17 +33,15 @@ pub enum Var { // specs Damage, - Protection, + Hp, Speed, - Stamina, - StaminaI, + HpI, RedDamageI, BlueDamageI, GreenDamageI, RedShieldI, BlueShieldI, - SpeedI, Amplify, Banish, @@ -87,7 +85,7 @@ impl Var { Var::Debuff | Var::Buff => true, - Var::Protection | + Var::Hp | Var::Damage => true, _ => false, @@ -137,13 +135,16 @@ impl Var { fn spec(&self) -> Option { match *self { - Var::StaminaI => Some(Spec::StaminaI), - Var::SpeedI => Some(Spec::SpeedI), + Var::Speed => Some(Spec::SpeedI), + Var::RedDamageI => Some(Spec::RedDamageI), Var::BlueDamageI => Some(Spec::BlueDamageI), Var::GreenDamageI => Some(Spec::GreenDamageI), + + Var::HpI => Some(Spec::HpI), Var::RedShieldI => Some(Spec::RedShieldI), Var::BlueShieldI => Some(Spec::BlueShieldI), + _ => None, } } @@ -175,8 +176,8 @@ impl Vbox { Var::Attack, Var::Attack, Var::Attack, - Var::StaminaI, - Var::SpeedI, + Var::Hp, + Var::Speed, Var::Damage, Var::Red, Var::Green, @@ -214,9 +215,8 @@ impl Vbox { let specs = vec![ (Var::Damage, 1), - (Var::Protection, 1), + (Var::Hp, 1), (Var::Speed, 1), - (Var::Stamina, 1), ]; let mut rng = thread_rng(); @@ -358,16 +358,15 @@ impl Vbox { ColourCode::GB => return Err(err_msg("unhandled skill combo")), ColourCode::BR => return Err(err_msg("unhandled skill combo")), }, - Var::Protection => match colour_code { + Var::Hp => match colour_code { ColourCode::RR => Var::RedShieldI, - ColourCode::GG => Var::StaminaI, + ColourCode::GG => Var::HpI, ColourCode::BB => Var::BlueShieldI, ColourCode::RG => return Err(err_msg("unhandled skill combo")), ColourCode::GB => return Err(err_msg("unhandled skill combo")), ColourCode::BR => return Err(err_msg("unhandled skill combo")), }, - _ => panic!("wrong base {:?}", base), }; From e6986d57cd57e2243995139f35c2de9a658f234c Mon Sep 17 00:00:00 2001 From: ntr Date: Thu, 14 Mar 2019 19:29:31 +1100 Subject: [PATCH 4/4] shield specs --- client/src/scenes/statsheet.js | 2 +- server/src/cryp.rs | 2 +- server/src/spec.rs | 49 ++++++++++++++++++++++++---------- server/src/vbox.rs | 19 ++++++++----- 4 files changed, 50 insertions(+), 22 deletions(-) diff --git a/client/src/scenes/statsheet.js b/client/src/scenes/statsheet.js index 43b7bfbc..c5290a67 100644 --- a/client/src/scenes/statsheet.js +++ b/client/src/scenes/statsheet.js @@ -90,7 +90,7 @@ class StatSheet extends Phaser.Scene { this.add.text(X + WIDTH * 0.175, Y, 'Skills', TEXT.HEADER); this.add.text(X + WIDTH * 0.175, Y + HEIGHT * 0.25, 'Specs', TEXT.HEADER); - const knownSpec = (spec, i) => { + const knownSpec = (spec, i) => { const SKILL_X = X + WIDTH * 0.21 + WIDTH * 0.125 * i; const SKILL_Y = Y + HEIGHT * 0.4; const itemObj = new Item(this, spec, i, SKILL_X, SKILL_Y, SKILL_WIDTH, Math.floor(SKILL_WIDTH / 2)); diff --git a/server/src/cryp.rs b/server/src/cryp.rs index c087b45a..8c73152c 100644 --- a/server/src/cryp.rs +++ b/server/src/cryp.rs @@ -72,7 +72,7 @@ impl CrypStat { pub fn recalculate(&mut self, specs: &Vec) -> &mut CrypStat { let specs = specs .iter() - .filter(|s| s.affects() == self.stat) + .filter(|s| s.affects().contains(&self.stat)) .map(|s| *s) .collect::>(); diff --git a/server/src/spec.rs b/server/src/spec.rs index 03c3ab54..25a524a3 100644 --- a/server/src/spec.rs +++ b/server/src/spec.rs @@ -1,38 +1,59 @@ +use rand::prelude::*; + use cryp::{Stat}; #[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq)] pub enum Spec { SpeedI, - HpI, + + LifeI, + RedShieldI, + BlueShieldI, + LRSI, + LBSI, + RBSI, + RedDamageI, GreenDamageI, BlueDamageI, - RedShieldI, - BlueShieldI, } impl Spec { - pub fn affects(&self) -> Stat { + pub fn affects(&self) -> Vec { match *self { - Spec::RedDamageI => Stat::RedDamage, - Spec::GreenDamageI => Stat::GreenDamage, - Spec::BlueDamageI => Stat::BlueDamage, - Spec::RedShieldI => Stat::RedShield, - Spec::BlueShieldI => Stat::BlueShield, - Spec::SpeedI => Stat::Speed, - Spec::HpI => Stat::Hp, + Spec::RedDamageI => vec![Stat::RedDamage], + Spec::GreenDamageI => vec![Stat::GreenDamage], + Spec::BlueDamageI => vec![Stat::BlueDamage], + Spec::RedShieldI => vec![Stat::RedShield], + Spec::BlueShieldI => vec![Stat::BlueShield], + Spec::SpeedI => vec![Stat::Speed], + 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::HpI => modified + (base * 5 / 100), - Spec::RedShieldI => modified + 50, - Spec::BlueShieldI => modified + 50, + + 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), } } diff --git a/server/src/vbox.rs b/server/src/vbox.rs index d31e9758..6e6db1db 100644 --- a/server/src/vbox.rs +++ b/server/src/vbox.rs @@ -36,7 +36,11 @@ pub enum Var { Hp, Speed, - HpI, + LifeI, + LRSI, + LBSI, + RBSI, + RedDamageI, BlueDamageI, GreenDamageI, @@ -141,7 +145,10 @@ impl Var { Var::BlueDamageI => Some(Spec::BlueDamageI), Var::GreenDamageI => Some(Spec::GreenDamageI), - Var::HpI => Some(Spec::HpI), + Var::LifeI => Some(Spec::LifeI), + Var::LRSI => Some(Spec::LRSI), + Var::LBSI => Some(Spec::LBSI), + Var::RBSI => Some(Spec::RBSI), Var::RedShieldI => Some(Spec::RedShieldI), Var::BlueShieldI => Some(Spec::BlueShieldI), @@ -360,11 +367,11 @@ impl Vbox { }, Var::Hp => match colour_code { ColourCode::RR => Var::RedShieldI, - ColourCode::GG => Var::HpI, + ColourCode::GG => Var::LifeI, ColourCode::BB => Var::BlueShieldI, - ColourCode::RG => return Err(err_msg("unhandled skill combo")), - ColourCode::GB => return Err(err_msg("unhandled skill combo")), - ColourCode::BR => return Err(err_msg("unhandled skill combo")), + ColourCode::RG => Var::LRSI, + ColourCode::GB => Var::LBSI, + ColourCode::BR => Var::RBSI, }, _ => panic!("wrong base {:?}", base),