From 25d5458eceabf57b4c4cfa849106365dfae0aaaa Mon Sep 17 00:00:00 2001 From: ntr Date: Thu, 21 Mar 2019 17:38:00 +1100 Subject: [PATCH] invert wip --- server/WORKLOG.md | 4 ++-- server/src/cryp.rs | 18 +++++++++--------- server/src/skill.rs | 22 +++++++++++++++++++--- server/src/vbox.rs | 7 +++++-- 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/server/WORKLOG.md b/server/WORKLOG.md index d4c9e26b..5e85983e 100644 --- a/server/WORKLOG.md +++ b/server/WORKLOG.md @@ -19,13 +19,13 @@ cryp vbox ensure all skills impl Skill::Reflect -> reflect incoming attacks back to opponent Skill::Ruin -> aoe stun - Skill::Slay -> red attack with bonus somethingorother for blue + Skill::Slay -> red attack with bonus somethingorother for blue / maim no healing Skill::Strangle -> stun + dot Skill::Clutch -> cannot go below 1hp Skill::Taunt -> redirect incomnig attacks to self Skill::Toxic -> apply debuff to attackers - recharge +colour speeds make parry semi-aggressive constants diff --git a/server/src/cryp.rs b/server/src/cryp.rs index 91d52950..c9505cce 100644 --- a/server/src/cryp.rs +++ b/server/src/cryp.rs @@ -122,7 +122,11 @@ impl CrypStat { } pub fn increase(&mut self, amt: u64) -> &mut CrypStat { - self.value = self.value.saturating_add(amt); + self.value = *[ + self.value.saturating_add(amt), + self.max + ].iter().min().unwrap(); + self } @@ -447,7 +451,7 @@ impl Cryp { ResolutionResult::Recharge { red, blue, immunity } } - pub fn heal(&mut self, skill: Skill, amount: u64) -> ResolutionResult { + pub fn deal_green_damage(&mut self, skill: Skill, amount: u64) -> ResolutionResult { let immunity = self.immune(skill); let immune = immunity.immune; @@ -469,15 +473,11 @@ impl Cryp { let modified_healing = healing_mods.iter().fold(amount, |acc, m| m.apply(acc)); let current_hp = self.hp(); - let new_hp = *[ - self.hp().saturating_add(modified_healing), - self.hp.max - ].iter().min().unwrap(); + self.hp.increase(modified_healing); + let new_hp = self.hp.value; let healing = new_hp - current_hp; - let overhealing = amount - healing; - - self.hp.increase(healing); + let overhealing = modified_healing - healing; return ResolutionResult::Healing { amount: healing, diff --git a/server/src/skill.rs b/server/src/skill.rs index ec4b49dc..cce686a3 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -102,6 +102,8 @@ pub enum Effect { Empower, + Invert, + // magic Hex, Curse, @@ -239,6 +241,7 @@ impl Effect { // magic immunity Effect::Shield => Category::BlueBuff, + Effect::Invert => Category::GreenBuff, // effects over time Effect::Triage => Category::BlueBuff, @@ -301,6 +304,8 @@ pub enum Category { BlueDebuff, BlueBuff, BlueTick, + Green, + GreenBuff, Ko, } @@ -323,6 +328,7 @@ pub enum Skill { Clutch, Taunt, Toxic, + Invert, Strike, Stun, @@ -390,6 +396,7 @@ impl Skill { Skill::Throw => Some(1), // no damage stun, adds vulnerable Skill::Blast => None, Skill::Amplify => Some(1), + Skill::Invert => Some(1), Skill::Decay => None, // dot Skill::DecayTick => None, Skill::Siphon => Some(1), @@ -455,6 +462,7 @@ impl Skill { // ----------------- // Destruction // ----------------- + Skill::Invert => Category::Green, Skill::Blast => Category::Blue, Skill::Amplify => Category::Blue, Skill::Decay => Category::Blue, // dot @@ -530,6 +538,7 @@ impl Skill { Skill::Decay => 5, // dot // magic combat trickery + Skill::Invert => 3, // hot Skill::Triage => 3, // hot Skill::Slow => 3, Skill::Amplify => 3, @@ -614,6 +623,7 @@ impl Skill { Skill::Haste => haste(source, target, resolution), // speed slow Skill::Heal => heal(source, target, resolution), Skill::Hex => hex(source, target, resolution), // todo prevent casting + Skill::Invert => invert(source, target, resolution), // todo prevent casting Skill::Parry => parry(source, target, resolution), Skill::Purge => purge(source, target, resolution), // dispel all buffs Skill::Purify => purify(source, target, resolution), // dispel all debuffs @@ -722,7 +732,7 @@ fn empower(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> R fn heal(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution { let amount = cryp.green_damage(); - resolution.results.push(target.heal(Skill::Heal, amount)); + resolution.results.push(target.deal_green_damage(Skill::Heal, amount)); return resolution; } @@ -738,7 +748,7 @@ fn triage(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Res fn triage_tick(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution { let amount = cryp.blue_damage().wrapping_div(2); - resolution.results.push(target.heal(Skill::TriageTick, amount)); + resolution.results.push(target.deal_green_damage(Skill::TriageTick, amount)); return resolution; } @@ -794,6 +804,12 @@ fn curse(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Res return resolution;; } +fn invert(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution { + let effect = CrypEffect { effect: Effect::Invert, duration: Effect::Invert.duration(), tick: None }; + resolution.results.push(target.add_effect(Skill::Invert, effect)); + return resolution;; +} + fn recharge(_cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) -> Resolution { resolution.results.push(target.recharge()); return resolution; @@ -817,7 +833,7 @@ fn siphon_tick(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) - match siphon_damage { ResolutionResult::Damage { amount, mitigation: _, category: _, immunity } => { if !immunity.immune { - resolution.results.push(cryp.heal(Skill::Heal, amount)); + resolution.results.push(cryp.deal_green_damage(Skill::Heal, amount)); } }, _ => panic!("siphon tick damage not dealt {:?}", siphon_damage), diff --git a/server/src/vbox.rs b/server/src/vbox.rs index 3b03f575..8950a796 100644 --- a/server/src/vbox.rs +++ b/server/src/vbox.rs @@ -57,6 +57,7 @@ pub enum Var { Haste, Heal, Hex, + Invert, Parry, Purge, Purify, @@ -151,6 +152,7 @@ impl Var { Var::Haste => Some(Skill::Haste), Var::Heal => Some(Skill::Heal), Var::Hex => Some(Skill::Hex), + Var::Invert => Some(Skill::Invert), Var::Parry => Some(Skill::Parry), Var::Purge => Some(Skill::Purge), Var::Purify => Some(Skill::Purify), @@ -206,6 +208,7 @@ impl From for Var { Skill::Haste => Var::Haste, Skill::Heal => Var::Heal, Skill::Hex => Var::Hex, + Skill::Invert => Var::Invert, Skill::Parry => Var::Parry, Skill::Purge => Var::Purge, Skill::Purify => Var::Purify, @@ -282,9 +285,9 @@ fn get_combos() -> Vec { Combo { units: vec![Var::Debuff, Var::Red, Var::Red], var: Var::Snare }, Combo { units: vec![Var::Debuff, Var::Green, Var::Green], var: Var::Purge }, Combo { units: vec![Var::Debuff, Var::Blue, Var::Blue], var: Var::Curse }, - // Combo { units: vec![Var::Debuff, Var::Red, Var::Green], var: Var::Siphon }, + Combo { units: vec![Var::Debuff, Var::Red, Var::Green], var: Var::Slow }, Combo { units: vec![Var::Debuff, Var::Green, Var::Blue], var: Var::Siphon }, - Combo { units: vec![Var::Debuff, Var::Red, Var::Blue], var: Var::Slow }, + Combo { units: vec![Var::Debuff, Var::Red, Var::Blue], var: Var::Invert }, Combo { units: vec![Var::Stun, Var::Red, Var::Red], var: Var::Strangle }, Combo { units: vec![Var::Stun, Var::Green, Var::Green], var: Var::Throw },