From a1e0419e3c35d08276b0240effa7bc446be61024 Mon Sep 17 00:00:00 2001 From: Mashy Date: Tue, 30 Apr 2019 12:13:19 +1000 Subject: [PATCH 1/8] added impl multiplier fn, floating point dmg calculation --- server/src/skill.rs | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/server/src/skill.rs b/server/src/skill.rs index c173d1e0..b74cc4f3 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -584,6 +584,22 @@ pub enum Skill { } impl Skill { + pub fn multiplier(&self) -> f64 { + match self { + Skill::Attack => 0.9, + Skill::Strike => 1.1, + Skill::StrangleTick => 0.3, + Skill::Riposte => 1.0, + Skill::Heal => 1.2, + Skill::TriageTick => 0.65, + Skill::Blast => 1.3, + Skill::CorruptionTick => 0.8, + Skill::DecayTick => 0.6, + Skill::SiphonTick => 0.4, + _ => 1.0, + } + } + pub fn base_cd(&self) -> Cooldown { match self { Skill::Attack => None, @@ -786,7 +802,7 @@ fn touch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Reso } fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amount = source.red_damage(); + let amount = (source.red_damage() as f64 * Skill::Attack.multiplier()).floor() as u64; target.deal_red_damage(Skill::Attack, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -795,7 +811,7 @@ fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Res } fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amount = source.red_damage(); + let amount = (source.red_damage() as f64 * Skill::Strike.multiplier()).floor() as u64; target.deal_red_damage(Skill::Strike, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -804,8 +820,8 @@ fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Res } fn injure(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amount = source.red_damage(); - target.deal_red_damage(Skill::Injure, amount) + let amount = (source.red_damage() as f64 * Skill::Injure.multiplier()).floor() as u64; + target.deal_red_damage(Skill::Injure, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -854,7 +870,7 @@ fn strangle(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> R } fn strangle_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amount = source.red_damage(); + let amount = (source.red_damage() as f64 * Skill::StrangleTick.multiplier()).floor() as u64; target.deal_red_damage(Skill::StrangleTick, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -885,7 +901,7 @@ fn parry(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Reso } fn riposte(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amount = source.red_damage(); + let amount = (source.red_damage() as f64 * Skill::Riposte.multiplier()).floor() as u64; target.deal_red_damage(Skill::Riposte, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -906,7 +922,7 @@ fn empower(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Re } fn heal(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amount = source.green_damage(); + let amount = (source.green_damage() as f64 * Skill::Heal.multiplier()).floor() as u64; target.deal_green_damage(Skill::Heal, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -922,7 +938,7 @@ fn triage(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Res } fn triage_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amount = source.green_damage().wrapping_div(2); + let amount = (source.green_damage() as f64 * Skill::TriageTick.multiplier()).floor() as u64; target.deal_green_damage(Skill::TriageTick, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -930,7 +946,7 @@ fn triage_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) - } fn blast(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amount = source.blue_damage(); + let amount = (source.blue_damage() as f64 * Skill::Blast.multiplier()).floor() as u64; target.deal_blue_damage(Skill::Blast, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -964,7 +980,7 @@ fn decay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Reso } fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amount = source.blue_damage() / 2; + let amount = (source.blue_damage() as f64 * Skill::DecayTick.multiplier()) as u64; target.deal_blue_damage(Skill::DecayTick, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -988,7 +1004,7 @@ fn corruption(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> } fn corruption_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amount = source.blue_damage() / 2; + let amount = (source.blue_damage() as f64 * Skill::CorruptionTick.multiplier()) as u64; target.deal_blue_damage(Skill::CorruptionTick, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -1054,7 +1070,7 @@ fn siphon(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Res } fn siphon_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amount = source.blue_damage(); + let amount = (source.blue_damage() as f64 * Skill::Siphon.multiplier()) as u64; let siphon_events = target.deal_blue_damage(Skill::SiphonTick, amount); for e in siphon_events { From d69a6a0f2ce2807cded61eb351a88a5f0dbeab37 Mon Sep 17 00:00:00 2001 From: Mashy Date: Tue, 30 Apr 2019 13:02:37 +1000 Subject: [PATCH 2/8] Strike T2 --- server/src/skill.rs | 21 ++++++++++++++++----- server/src/vbox.rs | 5 +++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/server/src/skill.rs b/server/src/skill.rs index b74cc4f3..c65d2c18 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -69,7 +69,8 @@ pub fn resolve(skill: Skill, source: &mut Cryp, target: &mut Cryp, mut resolutio Skill::Snare => snare(source, target, resolutions), Skill::Strangle => strangle(source, target, resolutions), Skill::StrangleTick => strangle_tick(source, target, resolutions), - Skill::Strike => strike(source, target, resolutions), + Skill::Strike => strike(source, target, resolutions, 1), + Skill::StrikeII => strike(source, target, resolutions, 2), Skill::Stun => stun(source, target, resolutions), Skill::Taunt => taunt(source, target, resolutions), Skill::Throw => throw(source, target, resolutions), // no damage stun, adds vulnerable @@ -527,6 +528,7 @@ pub enum Skill { StrangleTick, Strike, + StrikeII, Stun, // Evade, // actively evade @@ -588,6 +590,7 @@ impl Skill { match self { Skill::Attack => 0.9, Skill::Strike => 1.1, + Skill::StrikeII => 1.3, Skill::StrangleTick => 0.3, Skill::Riposte => 1.0, Skill::Heal => 1.2, @@ -604,6 +607,7 @@ impl Skill { match self { Skill::Attack => None, Skill::Strike => None, + Skill::StrikeII => None, Skill::Block => None, // reduce damage Skill::Parry => None, // avoid all damage Skill::Riposte => None, // used on parry @@ -660,6 +664,7 @@ impl Skill { match self { Skill::Attack => Category::Red, Skill::Strike => Category::Red, + Skill::StrikeII => Category::Red, Skill::Injure => Category::Red, Skill::Strangle => Category::Red, Skill::StrangleTick => Category::Red, @@ -704,6 +709,7 @@ impl Skill { // ----------------- // Test // ----------------- + Skill::TestTouch => Category::Red, Skill::TestStun => Category::Red, Skill::TestParry => Category::Red, @@ -734,6 +740,7 @@ impl Skill { Skill::TestSiphon => 10, Skill::Strike => u8::max_value(), + Skill::StrikeII => u8::max_value(), Skill::SiphonTick => Var::from(Skill::Siphon).speed(), Skill::DecayTick => Var::from(Skill::Decay).speed(), @@ -810,8 +817,12 @@ fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Res return results; } -fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amount = (source.red_damage() as f64 * Skill::Strike.multiplier()).floor() as u64; +fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, tier: u8) -> Resolutions { + let multiplier = match tier { + 2 => Skill::StrikeII.multiplier(), + _ => Skill::Strike.multiplier() + }; + let amount = (source.red_damage() as f64 * multiplier).floor() as u64; target.deal_red_damage(Skill::Strike, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -980,7 +991,7 @@ fn decay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Reso } fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amount = (source.blue_damage() as f64 * Skill::DecayTick.multiplier()) as u64; + let amount = (source.blue_damage() as f64 * Skill::DecayTick.multiplier()).floor() as u64; target.deal_blue_damage(Skill::DecayTick, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -1004,7 +1015,7 @@ fn corruption(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> } fn corruption_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amount = (source.blue_damage() as f64 * Skill::CorruptionTick.multiplier()) as u64; + let amount = (source.blue_damage() as f64 * Skill::CorruptionTick.multiplier()).floor() as u64; target.deal_blue_damage(Skill::CorruptionTick, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); diff --git a/server/src/vbox.rs b/server/src/vbox.rs index 9f752f26..2d130df1 100644 --- a/server/src/vbox.rs +++ b/server/src/vbox.rs @@ -87,6 +87,7 @@ pub enum Var { Snare, Strangle, Strike, + StrikeII, Siphon, Clutch, Taunt, @@ -207,6 +208,7 @@ impl Var { Var::Snare => Some(Skill::Snare), Var::Strangle => Some(Skill::Strangle), Var::Strike => Some(Skill::Strike), + Var::StrikeII => Some(Skill::StrikeII), Var::Clutch => Some(Skill::Clutch), Var::Taunt => Some(Skill::Taunt), Var::Throw => Some(Skill::Throw), @@ -277,6 +279,7 @@ impl From for Var { Skill::Snare => Var::Snare, Skill::Strangle => Var::Strangle, Skill::Strike => Var::Strike, + Skill::StrikeII => Var::StrikeII, Skill::Stun => Var::Stun, Skill::Taunt => Var::Taunt, Skill::Throw => Var::Throw, @@ -361,6 +364,8 @@ fn get_combos() -> Vec { Combo { units: vec![Var::Stun, Var::Red, Var::Blue], var: Var::Hex }, Combo { units: vec![Var::Attack, Var::Red, Var::Red], var: Var::Strike }, + Combo { units: vec![Var::Strike, Var::Strike, Var::Strike], var: Var::StrikeII }, + Combo { units: vec![Var::Attack, Var::Green, Var::Green], var: Var::Heal }, Combo { units: vec![Var::Attack, Var::Blue, Var::Blue], var: Var::Blast }, Combo { units: vec![Var::Attack, Var::Red, Var::Green], var: Var::Purify }, From 2941d1b73af845b4d35a5655ae97518192bddf90 Mon Sep 17 00:00:00 2001 From: Mashy Date: Tue, 30 Apr 2019 13:45:57 +1000 Subject: [PATCH 3/8] recursively calculate combo specs --- server/src/vbox.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/src/vbox.rs b/server/src/vbox.rs index 2d130df1..694dce3a 100644 --- a/server/src/vbox.rs +++ b/server/src/vbox.rs @@ -117,7 +117,13 @@ impl Var { Var::Red => count.red += 1, Var::Blue => count.blue += 1, Var::Green => count.green += 1, - _ => (), + _ => { + let mut combo_count = Colours::new(); + unit.colours(&mut combo_count); + count.red += combo_count.red; + count.blue += combo_count.blue; + count.green += combo_count.green; + } }), None => (), } From 6bbaa5da708be3b9f15b60821008ed9bacc18095 Mon Sep 17 00:00:00 2001 From: Mashy Date: Tue, 30 Apr 2019 14:40:48 +1000 Subject: [PATCH 4/8] Tier 3 and tier enums --- server/src/skill.rs | 28 +++++++++++++++++++++------- server/src/vbox.rs | 4 ++++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/server/src/skill.rs b/server/src/skill.rs index c65d2c18..e0b2ebc5 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -69,8 +69,9 @@ pub fn resolve(skill: Skill, source: &mut Cryp, target: &mut Cryp, mut resolutio Skill::Snare => snare(source, target, resolutions), Skill::Strangle => strangle(source, target, resolutions), Skill::StrangleTick => strangle_tick(source, target, resolutions), - Skill::Strike => strike(source, target, resolutions, 1), - Skill::StrikeII => strike(source, target, resolutions, 2), + Skill::Strike => strike(source, target, resolutions, Tier::T1), + Skill::StrikeII => strike(source, target, resolutions, Tier::T2), + Skill::StrikeIII => strike(source, target, resolutions, Tier::T3), Skill::Stun => stun(source, target, resolutions), Skill::Taunt => taunt(source, target, resolutions), Skill::Throw => throw(source, target, resolutions), // no damage stun, adds vulnerable @@ -503,6 +504,13 @@ pub enum Category { Ko, } +#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)] +pub enum Tier { + T1, + T2, + T3, +} + #[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)] pub enum Skill { Attack, @@ -529,6 +537,7 @@ pub enum Skill { Strike, StrikeII, + StrikeIII, Stun, // Evade, // actively evade @@ -591,6 +600,7 @@ impl Skill { Skill::Attack => 0.9, Skill::Strike => 1.1, Skill::StrikeII => 1.3, + Skill::StrikeIII => 1.5, Skill::StrangleTick => 0.3, Skill::Riposte => 1.0, Skill::Heal => 1.2, @@ -607,7 +617,8 @@ impl Skill { match self { Skill::Attack => None, Skill::Strike => None, - Skill::StrikeII => None, + Skill::StrikeII => None, + Skill::StrikeIII => None, Skill::Block => None, // reduce damage Skill::Parry => None, // avoid all damage Skill::Riposte => None, // used on parry @@ -665,6 +676,7 @@ impl Skill { Skill::Attack => Category::Red, Skill::Strike => Category::Red, Skill::StrikeII => Category::Red, + Skill::StrikeIII => Category::Red, Skill::Injure => Category::Red, Skill::Strangle => Category::Red, Skill::StrangleTick => Category::Red, @@ -740,7 +752,8 @@ impl Skill { Skill::TestSiphon => 10, Skill::Strike => u8::max_value(), - Skill::StrikeII => u8::max_value(), + Skill::StrikeII => Skill::Strike.speed(), + Skill::StrikeIII => Skill::Strike.speed(), Skill::SiphonTick => Var::from(Skill::Siphon).speed(), Skill::DecayTick => Var::from(Skill::Decay).speed(), @@ -817,10 +830,11 @@ fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Res return results; } -fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, tier: u8) -> Resolutions { +fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, tier: Tier) -> Resolutions { let multiplier = match tier { - 2 => Skill::StrikeII.multiplier(), - _ => Skill::Strike.multiplier() + Tier::T1 => Skill::Strike.multiplier(), + Tier::T2 => Skill::StrikeII.multiplier(), + Tier::T3 => Skill::StrikeIII.multiplier(), }; let amount = (source.red_damage() as f64 * multiplier).floor() as u64; target.deal_red_damage(Skill::Strike, amount) diff --git a/server/src/vbox.rs b/server/src/vbox.rs index 694dce3a..b6ef192b 100644 --- a/server/src/vbox.rs +++ b/server/src/vbox.rs @@ -88,6 +88,7 @@ pub enum Var { Strangle, Strike, StrikeII, + StrikeIII, Siphon, Clutch, Taunt, @@ -215,6 +216,7 @@ impl Var { Var::Strangle => Some(Skill::Strangle), Var::Strike => Some(Skill::Strike), Var::StrikeII => Some(Skill::StrikeII), + Var::StrikeIII => Some(Skill::StrikeIII), Var::Clutch => Some(Skill::Clutch), Var::Taunt => Some(Skill::Taunt), Var::Throw => Some(Skill::Throw), @@ -286,6 +288,7 @@ impl From for Var { Skill::Strangle => Var::Strangle, Skill::Strike => Var::Strike, Skill::StrikeII => Var::StrikeII, + Skill::StrikeIII => Var::StrikeIII, Skill::Stun => Var::Stun, Skill::Taunt => Var::Taunt, Skill::Throw => Var::Throw, @@ -371,6 +374,7 @@ fn get_combos() -> Vec { Combo { units: vec![Var::Attack, Var::Red, Var::Red], var: Var::Strike }, Combo { units: vec![Var::Strike, Var::Strike, Var::Strike], var: Var::StrikeII }, + Combo { units: vec![Var::StrikeII, Var::StrikeII, Var::StrikeII], var: Var::StrikeIII }, Combo { units: vec![Var::Attack, Var::Green, Var::Green], var: Var::Heal }, Combo { units: vec![Var::Attack, Var::Blue, Var::Blue], var: Var::Blast }, From 9d1d470cb6c4a1a8ef34f08b21f867e15e696603 Mon Sep 17 00:00:00 2001 From: Mashy Date: Tue, 30 Apr 2019 21:47:33 +1000 Subject: [PATCH 5/8] Effect duration taken from skill --- server/src/cryp.rs | 6 +- server/src/skill.rs | 465 ++++++++++++++++++++++---------------------- 2 files changed, 235 insertions(+), 236 deletions(-) diff --git a/server/src/cryp.rs b/server/src/cryp.rs index 2ca2c5b0..b87934d1 100644 --- a/server/src/cryp.rs +++ b/server/src/cryp.rs @@ -75,8 +75,8 @@ pub struct CrypEffect { } impl CrypEffect { - pub fn new(effect: Effect) -> CrypEffect { - CrypEffect { effect, duration: effect.duration(), meta: None, tick: None } + pub fn new(effect: Effect, duration: u8) -> CrypEffect { + CrypEffect { effect, duration, meta: None, tick: None } } pub fn set_tick(mut self, tick: Cast) -> CrypEffect { @@ -697,7 +697,7 @@ impl Cryp { // todo modified durations cause of buffs let result = Event::Effect { effect: effect.effect, - duration: effect.effect.duration(), + duration: effect.duration, skill, }; diff --git a/server/src/skill.rs b/server/src/skill.rs index e0b2ebc5..b998dabe 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -35,57 +35,57 @@ pub fn resolve(skill: Skill, source: &mut Cryp, target: &mut Cryp, mut resolutio // } resolutions = match skill { - Skill::Amplify => amplify(source, target, resolutions), // increase magic damage - Skill::Attack => attack(source, target, resolutions), - Skill::Banish => banish(source, target, resolutions), // TODO prevent all actions - Skill::Blast => blast(source, target, resolutions), - Skill::Block => block(source, target, resolutions), - Skill::Clutch => clutch(source, target, resolutions), - Skill::Corrupt => corrupt(source, target, resolutions), - Skill::CorruptionTick => corruption_tick(source, target, resolutions), - Skill::Curse => curse(source, target, resolutions), - Skill::Decay => decay(source, target, resolutions), // dot - Skill::DecayTick => decay_tick(source, target, resolutions), // dot - Skill::Empower => empower(source, target, resolutions), // increased phys damage - Skill::Haste => haste(source, target, resolutions), // speed slow - Skill::Heal => heal(source, target, resolutions), - Skill::Hex => hex(source, target, resolutions), - Skill::Hostility => hostility(source, target, resolutions), - Skill::Invert => invert(source, target, resolutions), - Skill::Injure => injure(source, target, resolutions), - Skill::Parry => parry(source, target, resolutions), - Skill::Purge => purge(source, target, resolutions), // dispel all buffs - Skill::Purify => purify(source, target, resolutions), // dispel all debuffs - Skill::Recharge => recharge(source, target, resolutions), // target is immune to magic damage and fx - Skill::Reflect => reflect(source, target, resolutions), + Skill::Amplify => amplify(source, target, resolutions, Skill::Amplify), // increase magic damage + Skill::Attack => attack(source, target, resolutions, Skill::Attack), + Skill::Banish => banish(source, target, resolutions, Skill::Banish), // TODO prevent all actions + Skill::Blast => blast(source, target, resolutions, Skill::Blast), + Skill::Block => block(source, target, resolutions, Skill::Block), + Skill::Clutch => clutch(source, target, resolutions, Skill::Clutch), + Skill::Corrupt => corrupt(source, target, resolutions, Skill::Corrupt), + Skill::CorruptionTick => corruption_tick(source, target, resolutions, Skill::CorruptionTick), + Skill::Curse => curse(source, target, resolutions, Skill::Curse), + Skill::Decay => decay(source, target, resolutions, Skill::Decay), // dot + Skill::DecayTick => decay_tick(source, target, resolutions, Skill::DecayTick), // dot + Skill::Empower => empower(source, target, resolutions, Skill::Empower), // increased phys damage + Skill::Haste => haste(source, target, resolutions, Skill::Haste), // speed slow + Skill::Heal => heal(source, target, resolutions, Skill::Heal), + Skill::Hex => hex(source, target, resolutions, Skill::Hex), + Skill::Hostility => hostility(source, target, resolutions, Skill::Hostility), + Skill::Invert => invert(source, target, resolutions, Skill::Invert), + Skill::Injure => injure(source, target, resolutions, Skill::Injure), + Skill::Parry => parry(source, target, resolutions, Skill::Parry), + Skill::Purge => purge(source, target, resolutions, Skill::Purge), // dispel all buffs + Skill::Purify => purify(source, target, resolutions, Skill::Purify), // dispel all debuffs + Skill::Recharge => recharge(source, target, resolutions, Skill::Recharge), // target is immune to magic damage and fx + Skill::Reflect => reflect(source, target, resolutions, Skill::Reflect), Skill::Riposte => panic!("riposte should not be caste"), - Skill::Ruin => ruin(source, target, resolutions), - Skill::Shield => shield(source, target, resolutions), // target is immune to magic damage and fx - Skill::Silence => silence(source, target, resolutions), // target cannot cast spells - Skill::Siphon => siphon(source, target, resolutions), - Skill::SiphonTick => siphon_tick(source, target, resolutions), // hot + Skill::Ruin => ruin(source, target, resolutions, Skill::Ruin), + Skill::Shield => shield(source, target, resolutions, Skill::Shield), // target is immune to magic damage and fx + Skill::Silence => silence(source, target, resolutions, Skill::Silence), // target cannot cast spells + Skill::Siphon => siphon(source, target, resolutions, Skill::Siphon), + Skill::SiphonTick => siphon_tick(source, target, resolutions, Skill::SiphonTick), // hot Skill::Slay => unimplemented!(), - Skill::Slow => slow(source, target, resolutions), // speed slow - Skill::Snare => snare(source, target, resolutions), - Skill::Strangle => strangle(source, target, resolutions), - Skill::StrangleTick => strangle_tick(source, target, resolutions), - Skill::Strike => strike(source, target, resolutions, Tier::T1), - Skill::StrikeII => strike(source, target, resolutions, Tier::T2), - Skill::StrikeIII => strike(source, target, resolutions, Tier::T3), - Skill::Stun => stun(source, target, resolutions), - Skill::Taunt => taunt(source, target, resolutions), - Skill::Throw => throw(source, target, resolutions), // no damage stun, adds vulnerable - Skill::Triage => triage(source, target, resolutions), // hot - Skill::TriageTick => triage_tick(source, target, resolutions), // hot + Skill::Slow => slow(source, target, resolutions, Skill::Slow), // speed slow + Skill::Snare => snare(source, target, resolutions, Skill::Snare), + Skill::Strangle => strangle(source, target, resolutions, Skill::Strangle), + Skill::StrangleTick => strangle_tick(source, target, resolutions, Skill::StrangleTick), + Skill::Strike => strike(source, target, resolutions, Skill::Strike), + Skill::StrikeII => strike(source, target, resolutions, Skill::StrikeII), + Skill::StrikeIII => strike(source, target, resolutions, Skill::StrikeIII), + Skill::Stun => stun(source, target, resolutions, Skill::Stun), + Skill::Taunt => taunt(source, target, resolutions, Skill::Taunt), + Skill::Throw => throw(source, target, resolutions, Skill::Throw), // no damage stun, adds vulnerable + Skill::Triage => triage(source, target, resolutions, Skill::Triage), // hot + Skill::TriageTick => triage_tick(source, target, resolutions, Skill::TriageTick), // hot // ----------------- // Test // ----------------- - Skill::TestTouch => touch(source, target, resolutions), - Skill::TestStun => stun(source, target, resolutions), - Skill::TestBlock => block(source, target, resolutions), - Skill::TestParry => parry(source, target, resolutions), - Skill::TestSiphon => siphon(source, target, resolutions), + Skill::TestTouch => touch(source, target, resolutions, Skill::TestTouch), + Skill::TestStun => stun(source, target, resolutions, Skill::Stun), + Skill::TestBlock => block(source, target, resolutions, Skill::Block), + Skill::TestParry => parry(source, target, resolutions, Skill::Parry), + Skill::TestSiphon => siphon(source, target, resolutions, Skill::Siphon), }; // if any event dealt damage to target cryp @@ -98,15 +98,15 @@ pub fn resolve(skill: Skill, source: &mut Cryp, target: &mut Cryp, mut resolutio match r.event { Event::Damage { amount, skill, mitigation: _, colour: _ } => { if target.affected(Effect::Corrupt) { - resolutions = corruption(target, source, resolutions); + resolutions = corruption(target, source, resolutions, Skill::Corrupt); } if target.affected(Effect::Hostility) { - resolutions = hatred(source, target, resolutions, skill, amount); + resolutions = hatred(source, target, resolutions, skill, amount, Skill::Hostility); } }, Event::Immunity { skill: _, immunity } => match immunity.contains(&Effect::Parry) { - true => resolutions = riposte(target, source, resolutions), + true => resolutions = riposte(target, source, resolutions, Skill::Riposte), false => (), }, _ => (), @@ -430,58 +430,6 @@ impl Effect { Effect::Ko => Category::Ko, } } - - pub fn duration(&self) -> u8 { - match self { - Effect::Block => 1, - Effect::Parry => 1, - Effect::Clutch => 1, - - Effect::Reflect => 1, - - Effect::Injured => 2, - - Effect::Strangle => 2, - Effect::Strangling => 2, - - Effect::Stun => 1, - Effect::Vulnerable => 2, - Effect::Snare => 2, - - Effect::Taunt => 1, - Effect::Empower => 2, - Effect::Invert => 1, - - Effect::Hex => 2, - Effect::Ruin => 1, - Effect::Curse => 2, - Effect::Banish => 1, - - Effect::Slow => 2, - Effect::Haste => 2, - - Effect::Amplify => 2, - Effect::Silence => 2, - - Effect::Hostility => 2, - Effect::Hatred => 5, - - Effect::Corrupt => 2, - Effect::Corruption => 3, - - Effect::Shield => 2, - - Effect::Triage => 3, - Effect::Decay => 3, - Effect::Siphon => 2, - - _ => { - println!("{:?} does not have a duration", self); - return 1; - }, - } - } - } #[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)] @@ -504,13 +452,6 @@ pub enum Category { Ko, } -#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)] -pub enum Tier { - T1, - T2, - T3, -} - #[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)] pub enum Skill { Attack, @@ -613,6 +554,68 @@ impl Skill { } } + pub fn duration(&self) -> u8 { + match self { + Skill::Block => 1, + Skill::Parry => 1, + Skill::Clutch => 1, + + Skill::Reflect => 1, + + Skill::Injure => 2, + + Skill::Strangle => 2, + + Skill::Stun => 2, + Skill::Throw => 2, + Skill::Snare => 2, + + Skill::Taunt => 1, + Skill::Empower => 2, + Skill::Invert => 1, + + Skill::Hex => 2, + Skill::Ruin => 1, + Skill::Curse => 2, + Skill::Banish => 1, + + Skill::Slow => 2, + Skill::Haste => 2, + + Skill::Amplify => 2, + Skill::Silence => 2, + + Skill::Hostility => 2, // Primary Buff + Skill::Corrupt => 2, // Primary Buff + + Skill::Shield => 2, + + Skill::Triage => 3, + Skill::Decay => 3, + Skill::Siphon => 2, + + _ => { + println!("{:?} does not have a duration", self); + return 1; + }, + } + } + + pub fn secondary_duration(&self) -> u8 { + match self { + Skill::Hostility => 5, // Increased dmg buff + Skill::Corrupt => 3, // Damage over time + Skill::Throw => 3, // Inc dmg taken debuff + + _ => { + println!("{:?} does not have a secondary duration", self); + return 1; + }, + } + + } + + pub fn base_cd(&self) -> Cooldown { match self { Skill::Attack => None, @@ -813,15 +816,15 @@ impl Skill { } } -fn touch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - target.deal_red_damage(Skill::TestTouch, 0) +fn touch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + target.deal_red_damage(skill, 0) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); return results; } -fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { +fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = (source.red_damage() as f64 * Skill::Attack.multiplier()).floor() as u64; target.deal_red_damage(Skill::Attack, amount) .into_iter() @@ -830,13 +833,9 @@ fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Res return results; } -fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, tier: Tier) -> Resolutions { - let multiplier = match tier { - Tier::T1 => Skill::Strike.multiplier(), - Tier::T2 => Skill::StrikeII.multiplier(), - Tier::T3 => Skill::StrikeIII.multiplier(), - }; - let amount = (source.red_damage() as f64 * multiplier).floor() as u64; +fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + + let amount = (source.red_damage() as f64 * skill.multiplier()).floor() as u64; target.deal_red_damage(Skill::Strike, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -844,59 +843,59 @@ fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, tier: return results; } -fn injure(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amount = (source.red_damage() as f64 * Skill::Injure.multiplier()).floor() as u64; +fn injure(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let amount = (source.red_damage() as f64 * skill.multiplier()).floor() as u64; target.deal_red_damage(Skill::Injure, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); - let effect = CrypEffect::new(Effect::Injured); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Injure, effect))); + let effect = CrypEffect::new(Effect::Injured, 2); + results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); return results; } -fn stun(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let effect = CrypEffect::new(Effect::Stun); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Stun, effect))); +fn stun(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let effect = CrypEffect::new(Effect::Stun, skill.duration()); + results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); return results; } -fn clutch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let effect = CrypEffect::new(Effect::Clutch); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Clutch, effect))); +fn clutch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let effect = CrypEffect::new(Effect::Clutch, skill.duration()); + results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); return results; } -fn taunt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let effect = CrypEffect::new(Effect::Taunt); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Taunt, effect))); +fn taunt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let effect = CrypEffect::new(Effect::Taunt, skill.duration()); + results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); return results; } -fn throw(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let stun = CrypEffect::new(Effect::Stun); - let vulnerable = CrypEffect::new(Effect::Vulnerable); +fn throw(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let stun = CrypEffect::new(Effect::Stun, skill.duration()); + let vulnerable = CrypEffect::new(Effect::Vulnerable, skill.secondary_duration()); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Throw, stun))); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Throw, vulnerable))); + results.push(Resolution::new(source, target).event(target.add_effect(skill, stun))); + results.push(Resolution::new(source, target).event(target.add_effect(skill, vulnerable))); return results; } -fn strangle(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let target_stun = CrypEffect::new(Effect::Strangle) +fn strangle(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let target_stun = CrypEffect::new(Effect::Strangle, skill.duration()) .set_tick(Cast::new_tick(source, target, Skill::StrangleTick)); - let attacker_immunity = CrypEffect::new(Effect::Strangling); + let attacker_immunity = CrypEffect::new(Effect::Strangling, skill.duration()); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Strangle, target_stun))); - results.push(Resolution::new(source, source).event(source.add_effect(Skill::Strangle, attacker_immunity))); - return strangle_tick(source, target, results); + results.push(Resolution::new(source, target).event(target.add_effect(skill, target_stun))); + results.push(Resolution::new(source, source).event(source.add_effect(skill, attacker_immunity))); + return strangle_tick(source, target, results, Skill::StrangleTick); } -fn strangle_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amount = (source.red_damage() as f64 * Skill::StrangleTick.multiplier()).floor() as u64; - target.deal_red_damage(Skill::StrangleTick, amount) +fn strangle_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let amount = (source.red_damage() as f64 * skill.multiplier()).floor() as u64; + target.deal_red_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -913,19 +912,19 @@ fn strangle_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) return results; } -fn block(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let block = CrypEffect::new(Effect::Block); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Block, block))); +fn block(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let block = CrypEffect::new(Effect::Block, skill.duration()); + results.push(Resolution::new(source, target).event(target.add_effect(skill, block))); return results; } -fn parry(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let effect = CrypEffect::new(Effect::Parry); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Parry, effect))); +fn parry(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let effect = CrypEffect::new(Effect::Parry, skill.duration()); + results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); return results; } -fn riposte(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { +fn riposte(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = (source.red_damage() as f64 * Skill::Riposte.multiplier()).floor() as u64; target.deal_red_damage(Skill::Riposte, amount) .into_iter() @@ -934,19 +933,19 @@ fn riposte(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Re return results; } -fn snare(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let snare = CrypEffect::new(Effect::Snare); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Snare, snare))); +fn snare(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let snare = CrypEffect::new(Effect::Snare, skill.duration()); + results.push(Resolution::new(source, target).event(target.add_effect(skill, snare))); return results; } -fn empower(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let empower = CrypEffect::new(Effect::Empower); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Empower, empower))); +fn empower(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let empower = CrypEffect::new(Effect::Empower, skill.duration()); + results.push(Resolution::new(source, target).event(target.add_effect(skill, empower))); return results; } -fn heal(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { +fn heal(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = (source.green_damage() as f64 * Skill::Heal.multiplier()).floor() as u64; target.deal_green_damage(Skill::Heal, amount) .into_iter() @@ -954,58 +953,58 @@ fn heal(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resol return results; } -fn triage(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let effect = CrypEffect::new(Effect::Triage) +fn triage(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let effect = CrypEffect::new(Effect::Triage, skill.duration()) .set_tick(Cast::new_tick(source, target, Skill::TriageTick)); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Triage, effect))); - return triage_tick(source, target, results); + results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); + return triage_tick(source, target, results, Skill::TriageTick); } -fn triage_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amount = (source.green_damage() as f64 * Skill::TriageTick.multiplier()).floor() as u64; +fn triage_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let amount = (source.green_damage() as f64 * skill.multiplier()).floor() as u64; target.deal_green_damage(Skill::TriageTick, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); return results; } -fn blast(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amount = (source.blue_damage() as f64 * Skill::Blast.multiplier()).floor() as u64; +fn blast(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let amount = (source.blue_damage() as f64 * skill.multiplier()).floor() as u64; target.deal_blue_damage(Skill::Blast, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); return results; } -fn amplify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amplify = CrypEffect::new(Effect::Amplify); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Amplify, amplify))); +fn amplify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let amplify = CrypEffect::new(Effect::Amplify, skill.duration()); + results.push(Resolution::new(source, target).event(target.add_effect(skill, amplify))); return results;; } -fn haste(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let effect = CrypEffect::new(Effect::Haste); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Haste, effect))); +fn haste(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let effect = CrypEffect::new(Effect::Haste, skill.duration()); + results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); return results;; } -fn slow(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let effect = CrypEffect::new(Effect::Slow); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Slow, effect))); +fn slow(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let effect = CrypEffect::new(Effect::Slow, skill.duration()); + results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); return results;; } -fn decay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let decay = CrypEffect::new(Effect::Decay) +fn decay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let decay = CrypEffect::new(Effect::Decay, skill.duration()) .set_tick(Cast::new_tick(source, target, Skill::DecayTick)); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Decay, decay))); - return decay_tick(source, target, results); + results.push(Resolution::new(source, target).event(target.add_effect(skill, decay))); + return decay_tick(source, target, results, Skill::DecayTick); } -fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amount = (source.blue_damage() as f64 * Skill::DecayTick.multiplier()).floor() as u64; +fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let amount = (source.blue_damage() as f64 * skill.multiplier()).floor() as u64; target.deal_blue_damage(Skill::DecayTick, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -1014,88 +1013,88 @@ fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> // corrupt is the buff effect // when attacked it runs corruption and applies a debuff -fn corrupt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let effect = CrypEffect::new(Effect::Corrupt); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Corrupt, effect))); +fn corrupt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let effect = CrypEffect::new(Effect::Corrupt, skill.duration()); + results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); return results;; } -fn corruption(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let effect = CrypEffect::new(Effect::Corruption) +fn corruption(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let effect = CrypEffect::new(Effect::Corruption, skill.secondary_duration()) .set_tick(Cast::new_tick(source, target, Skill::CorruptionTick)); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Corrupt, effect))); - return corruption_tick(source, target, results); + results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); + return corruption_tick(source, target, results, Skill::CorruptionTick); } -fn corruption_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amount = (source.blue_damage() as f64 * Skill::CorruptionTick.multiplier()).floor() as u64; +fn corruption_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let amount = (source.blue_damage() as f64 * skill.multiplier()).floor() as u64; target.deal_blue_damage(Skill::CorruptionTick, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); return results; } -fn ruin(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let effect = CrypEffect::new(Effect::Ruin); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Ruin, effect))); - return results;; -} - - -fn hex(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let hex = CrypEffect::new(Effect::Hex); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Hex, hex))); - return results;; -} - -fn hostility(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let effect = CrypEffect::new(Effect::Hostility); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Hostility, effect))); - return results;; -} - -fn hatred(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill, amount: u64) -> Resolutions { - let effect = CrypEffect::new(Effect::Hatred) - .set_meta(EffectMeta::AddedDamage(amount)); - +fn ruin(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let effect = CrypEffect::new(Effect::Ruin, skill.duration()); results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); return results;; } -fn curse(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let curse = CrypEffect::new(Effect::Curse); + +fn hex(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let hex = CrypEffect::new(Effect::Hex, skill.duration()); + results.push(Resolution::new(source, target).event(target.add_effect(skill, hex))); + return results;; +} + +fn hostility(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let effect = CrypEffect::new(Effect::Hostility, skill.duration()); + results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); + return results;; +} + +fn hatred(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, reflect_skill: Skill, amount: u64, skill: Skill) -> Resolutions { + let effect = CrypEffect::new(Effect::Hatred, skill.secondary_duration()) + .set_meta(EffectMeta::AddedDamage(amount)); + + results.push(Resolution::new(source, target).event(target.add_effect(reflect_skill, effect))); + return results;; +} + +fn curse(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let curse = CrypEffect::new(Effect::Curse, skill.duration()); results.push(Resolution::new(source, target).event(target.add_effect(Skill::Curse, curse))); return results;; } -fn invert(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let effect = CrypEffect::new(Effect::Invert); +fn invert(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let effect = CrypEffect::new(Effect::Invert, skill.duration()); results.push(Resolution::new(source, target).event(target.add_effect(Skill::Invert, effect))); return results;; } -fn reflect(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let effect = CrypEffect::new(Effect::Reflect); +fn reflect(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let effect = CrypEffect::new(Effect::Reflect, skill.duration()); results.push(Resolution::new(source, target).event(target.add_effect(Skill::Reflect, effect))); return results;; } -fn recharge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { +fn recharge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { results.push(Resolution::new(source, target).event(target.recharge())); return results; } -fn siphon(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let siphon = CrypEffect::new(Effect::Siphon) +fn siphon(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let siphon = CrypEffect::new(Effect::Siphon, skill.duration()) .set_tick(Cast::new_tick(source, target, Skill::SiphonTick)); results.push(Resolution::new(source, target).event(target.add_effect(Skill::Siphon, siphon))); - return siphon_tick(source, target, results); + return siphon_tick(source, target, results, Skill::SiphonTick); } -fn siphon_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let amount = (source.blue_damage() as f64 * Skill::Siphon.multiplier()) as u64; +fn siphon_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let amount = (source.blue_damage() as f64 * skill.multiplier()) as u64; let siphon_events = target.deal_blue_damage(Skill::SiphonTick, amount); for e in siphon_events { @@ -1115,19 +1114,19 @@ fn siphon_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) - return results; } -fn shield(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let shield = CrypEffect::new(Effect::Shield); +fn shield(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let shield = CrypEffect::new(Effect::Shield, skill.duration()); results.push(Resolution::new(source, target).event(target.add_effect(Skill::Shield, shield))); return results; } -fn silence(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let silence = CrypEffect::new(Effect::Silence); +fn silence(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let silence = CrypEffect::new(Effect::Silence, skill.duration()); results.push(Resolution::new(source, target).event(target.add_effect(Skill::Silence, silence))); return results; } -fn purge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { +fn purge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { while let Some(i) = target.effects .iter() .position(|ce| [Category::Buff, Category::Buff].contains(&ce.effect.category())) { @@ -1138,7 +1137,7 @@ fn purge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Reso return results; } -fn purify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { +fn purify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { while let Some(i) = target.effects .iter() .position(|ce| [Category::Debuff, Category::Debuff].contains(&ce.effect.category())) { @@ -1149,8 +1148,8 @@ fn purify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Res return results; } -fn banish(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { - let banish = CrypEffect::new(Effect::Banish); +fn banish(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { + let banish = CrypEffect::new(Effect::Banish, skill.duration()); results.push(Resolution::new(source, target).event(target.add_effect(Skill::Banish, banish))); return results; } From 6a4a24d080428be0678b196f68ea7b2bf631e51d Mon Sep 17 00:00:00 2001 From: Mashy Date: Wed, 1 May 2019 10:46:31 +1000 Subject: [PATCH 6/8] test fixes --- server/src/skill.rs | 78 +++++++++++++++++++++++---------------------- server/src/vbox.rs | 2 +- 2 files changed, 41 insertions(+), 39 deletions(-) diff --git a/server/src/skill.rs b/server/src/skill.rs index b998dabe..7b5b8e48 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -538,18 +538,18 @@ pub enum Skill { impl Skill { pub fn multiplier(&self) -> f64 { match self { - Skill::Attack => 0.9, + Skill::Attack => 1.0, // 1.0 to pass tests Skill::Strike => 1.1, Skill::StrikeII => 1.3, Skill::StrikeIII => 1.5, Skill::StrangleTick => 0.3, Skill::Riposte => 1.0, - Skill::Heal => 1.2, + Skill::Heal => 1.0, // 1.0 to pass tests Skill::TriageTick => 0.65, Skill::Blast => 1.3, Skill::CorruptionTick => 0.8, Skill::DecayTick => 0.6, - Skill::SiphonTick => 0.4, + Skill::SiphonTick => 1.0, // 1.0 to pass tests _ => 1.0, } } @@ -825,8 +825,9 @@ fn touch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: } fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - let amount = (source.red_damage() as f64 * Skill::Attack.multiplier()).floor() as u64; - target.deal_red_damage(Skill::Attack, amount) + let amount = (source.red_damage() as f64 * skill.multiplier()).floor() as u64; + println!("{:?}", amount); + target.deal_red_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -836,7 +837,7 @@ fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = (source.red_damage() as f64 * skill.multiplier()).floor() as u64; - target.deal_red_damage(Skill::Strike, amount) + target.deal_red_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -845,7 +846,7 @@ fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: fn injure(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = (source.red_damage() as f64 * skill.multiplier()).floor() as u64; - target.deal_red_damage(Skill::Injure, amount) + target.deal_red_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -926,7 +927,7 @@ fn parry(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: fn riposte(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = (source.red_damage() as f64 * Skill::Riposte.multiplier()).floor() as u64; - target.deal_red_damage(Skill::Riposte, amount) + target.deal_red_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -946,8 +947,8 @@ fn empower(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill } fn heal(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - let amount = (source.green_damage() as f64 * Skill::Heal.multiplier()).floor() as u64; - target.deal_green_damage(Skill::Heal, amount) + let amount = (source.green_damage() as f64 * skill.multiplier()).floor() as u64; + target.deal_green_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); return results; @@ -971,7 +972,7 @@ fn triage_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, s fn blast(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = (source.blue_damage() as f64 * skill.multiplier()).floor() as u64; - target.deal_blue_damage(Skill::Blast, amount) + target.deal_blue_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); return results; @@ -1005,7 +1006,7 @@ fn decay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = (source.blue_damage() as f64 * skill.multiplier()).floor() as u64; - target.deal_blue_damage(Skill::DecayTick, amount) + target.deal_blue_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); return results; @@ -1029,7 +1030,7 @@ fn corruption(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, sk fn corruption_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = (source.blue_damage() as f64 * skill.multiplier()).floor() as u64; - target.deal_blue_damage(Skill::CorruptionTick, amount) + target.deal_blue_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); return results; @@ -1070,13 +1071,13 @@ fn curse(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: fn invert(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { let effect = CrypEffect::new(Effect::Invert, skill.duration()); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Invert, effect))); + results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); return results;; } fn reflect(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { let effect = CrypEffect::new(Effect::Reflect, skill.duration()); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Reflect, effect))); + results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); return results;; } @@ -1089,7 +1090,7 @@ fn siphon(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: let siphon = CrypEffect::new(Effect::Siphon, skill.duration()) .set_tick(Cast::new_tick(source, target, Skill::SiphonTick)); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Siphon, siphon))); + results.push(Resolution::new(source, target).event(target.add_effect(skill, siphon))); return siphon_tick(source, target, results, Skill::SiphonTick); } @@ -1116,13 +1117,13 @@ fn siphon_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, s fn shield(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { let shield = CrypEffect::new(Effect::Shield, skill.duration()); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Shield, shield))); + results.push(Resolution::new(source, target).event(target.add_effect(skill, shield))); return results; } fn silence(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { let silence = CrypEffect::new(Effect::Silence, skill.duration()); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Silence, silence))); + results.push(Resolution::new(source, target).event(target.add_effect(skill, silence))); return results; } @@ -1150,7 +1151,7 @@ fn purify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: fn banish(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { let banish = CrypEffect::new(Effect::Banish, skill.duration()); - results.push(Resolution::new(source, target).event(target.add_effect(Skill::Banish, banish))); + results.push(Resolution::new(source, target).event(target.add_effect(skill, banish))); return results; } @@ -1170,7 +1171,7 @@ mod tests { x.deal_red_damage(Skill::Attack, 5); - heal(&mut y, &mut x, vec![]); + heal(&mut y, &mut x, vec![], Skill::Heal); } #[test] @@ -1181,7 +1182,7 @@ mod tests { let mut y = Cryp::new() .named(&"camel".to_string()); - decay(&mut x, &mut y, vec![]); + decay(&mut x, &mut y, vec![], Skill::Decay); assert!(y.effects.iter().any(|e| e.effect == Effect::Decay)); @@ -1202,10 +1203,10 @@ mod tests { x.red_damage.force(100); y.green_life.force(500); - block(&mut y.clone(), &mut y, vec![]); + block(&mut y.clone(), &mut y, vec![], Skill::Block); assert!(y.effects.iter().any(|e| e.effect == Effect::Block)); - let mut results = attack(&mut x, &mut y, vec![]); + let mut results = attack(&mut x, &mut y, vec![], Skill::Attack); let Resolution { source: _, target: _, event } = results.remove(0); match event { @@ -1222,12 +1223,13 @@ mod tests { let mut y = Cryp::new() .named(&"camel".to_string()); - x.red_damage.force(u64::max_value()); + x.red_damage.force(10000000000000); // can't convert u64 max to f64 - clutch(&mut y.clone(), &mut y, vec![]); + clutch(&mut y.clone(), &mut y, vec![], Skill::Clutch); assert!(y.affected(Effect::Clutch)); - let mut results = attack(&mut x, &mut y, vec![]); + let mut results = attack(&mut x, &mut y, vec![], Skill::Attack); + println!("{:?}", y.green_life()); assert!(y.green_life() == 1); let Resolution { source: _, target: _, event } = results.remove(0); @@ -1263,15 +1265,15 @@ mod tests { y.red_life.reduce(64); x.red_damage.force(256 + 64); - invert(&mut y.clone(), &mut y, vec![]); + invert(&mut y.clone(), &mut y, vec![], Skill::Invert); assert!(y.affected(Effect::Invert)); // heal should deal green damage - heal(&mut x, &mut y, vec![]); + heal(&mut x, &mut y, vec![], Skill::Heal); assert!(y.green_life() == 768); // attack should heal and recharge red shield - let mut results = attack(&mut x, &mut y, vec![]); + let mut results = attack(&mut x, &mut y, vec![], Skill::Attack); assert!(y.green_life() == 1024); match results.remove(0).event { @@ -1298,7 +1300,7 @@ mod tests { let mut y = Cryp::new() .named(&"camel".to_string()); - reflect(&mut y.clone(), &mut y, vec![]); + reflect(&mut y.clone(), &mut y, vec![], Skill::Reflect); assert!(y.affected(Effect::Reflect)); let mut results = vec![]; @@ -1366,7 +1368,7 @@ mod tests { let mut y = Cryp::new() .named(&"camel".to_string()); - corrupt(&mut y.clone(), &mut y, vec![]); + corrupt(&mut y.clone(), &mut y, vec![], Skill::Corrupt); assert!(y.affected(Effect::Corrupt)); resolve(Skill::Attack, &mut x, &mut y, vec![]); @@ -1382,7 +1384,7 @@ mod tests { let mut y = Cryp::new() .named(&"camel".to_string()); - hostility(&mut y.clone(), &mut y, vec![]); + hostility(&mut y.clone(), &mut y, vec![], Skill::Hostility); assert!(y.affected(Effect::Hostility)); resolve(Skill::Attack, &mut x, &mut y, vec![]); @@ -1416,7 +1418,7 @@ mod tests { y.deal_red_damage(Skill::Attack, 5); let prev_hp = y.green_life(); - triage(&mut x, &mut y, vec![]); + triage(&mut x, &mut y, vec![], Skill::Triage); assert!(y.effects.iter().any(|e| e.effect == Effect::Triage)); assert!(y.green_life() > prev_hp); @@ -1436,7 +1438,7 @@ mod tests { y.deal_red_damage(Skill::Attack, 5); y.deal_blue_damage(Skill::Blast, 5); - let mut results = recharge(&mut x, &mut y, vec![]); + let mut results = recharge(&mut x, &mut y, vec![], Skill::Recharge); let Resolution { source: _, target: _, event } = results.remove(0); match event { @@ -1454,7 +1456,7 @@ mod tests { let mut x = Cryp::new() .named(&"muji".to_string()); - silence(&mut x.clone(), &mut x, vec![]); + silence(&mut x.clone(), &mut x, vec![], Skill::Silence); assert!(x.effects.iter().any(|e| e.effect == Effect::Silence)); assert!(x.disabled(Skill::Silence).is_some()); } @@ -1466,7 +1468,7 @@ mod tests { x.blue_damage.force(50); - amplify(&mut x.clone(), &mut x, vec![]); + amplify(&mut x.clone(), &mut x, vec![], Skill::Amplify); assert!(x.effects.iter().any(|e| e.effect == Effect::Amplify)); assert_eq!(x.blue_damage(), 100); } @@ -1476,10 +1478,10 @@ mod tests { let mut x = Cryp::new() .named(&"muji".to_string()); - decay(&mut x.clone(), &mut x, vec![]); + decay(&mut x.clone(), &mut x, vec![], Skill::Decay); assert!(x.effects.iter().any(|e| e.effect == Effect::Decay)); - purify(&mut x.clone(), &mut x, vec![]); + purify(&mut x.clone(), &mut x, vec![], Skill::Purify); assert!(!x.effects.iter().any(|e| e.effect == Effect::Decay)); } } diff --git a/server/src/vbox.rs b/server/src/vbox.rs index b6ef192b..1f4ecffd 100644 --- a/server/src/vbox.rs +++ b/server/src/vbox.rs @@ -362,7 +362,7 @@ fn get_combos() -> Vec { Combo { units: vec![Var::Block, Var::Green, Var::Green], var: Var::Reflect }, Combo { units: vec![Var::Block, Var::Blue, Var::Blue], var: Var::Corrupt }, Combo { units: vec![Var::Block, Var::Red, Var::Green], var: Var::Taunt }, - Combo { units: vec![Var::Block, Var::Green, Var::Blue], var: Var::Life }, + Combo { units: vec![Var::Block, Var::Green, Var::Blue], var: Var::Recharge }, // was life before (clash) Combo { units: vec![Var::Block, Var::Red, Var::Blue], var: Var::Recharge }, Combo { units: vec![Var::Stun, Var::Red, Var::Red], var: Var::Strangle }, From 3e271d4455767405c02ee9be0671e05a1ab4119d Mon Sep 17 00:00:00 2001 From: Mashy Date: Wed, 1 May 2019 13:12:30 +1000 Subject: [PATCH 7/8] int multiplier, remove floats --- server/src/skill.rs | 56 +++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/server/src/skill.rs b/server/src/skill.rs index 7b5b8e48..3a36859d 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -1,6 +1,7 @@ use rand::{thread_rng, Rng}; use uuid::Uuid; +use spec::{IntPct}; use cryp::{Cryp, CrypEffect, EffectMeta, Stat}; use vbox::{Var}; @@ -69,9 +70,11 @@ pub fn resolve(skill: Skill, source: &mut Cryp, target: &mut Cryp, mut resolutio Skill::Snare => snare(source, target, resolutions, Skill::Snare), Skill::Strangle => strangle(source, target, resolutions, Skill::Strangle), Skill::StrangleTick => strangle_tick(source, target, resolutions, Skill::StrangleTick), + Skill::Strike => strike(source, target, resolutions, Skill::Strike), Skill::StrikeII => strike(source, target, resolutions, Skill::StrikeII), Skill::StrikeIII => strike(source, target, resolutions, Skill::StrikeIII), + Skill::Stun => stun(source, target, resolutions, Skill::Stun), Skill::Taunt => taunt(source, target, resolutions, Skill::Taunt), Skill::Throw => throw(source, target, resolutions, Skill::Throw), // no damage stun, adds vulnerable @@ -536,21 +539,21 @@ pub enum Skill { } impl Skill { - pub fn multiplier(&self) -> f64 { + pub fn multiplier(&self) -> u64 { match self { - Skill::Attack => 1.0, // 1.0 to pass tests - Skill::Strike => 1.1, - Skill::StrikeII => 1.3, - Skill::StrikeIII => 1.5, - Skill::StrangleTick => 0.3, - Skill::Riposte => 1.0, - Skill::Heal => 1.0, // 1.0 to pass tests - Skill::TriageTick => 0.65, - Skill::Blast => 1.3, - Skill::CorruptionTick => 0.8, - Skill::DecayTick => 0.6, - Skill::SiphonTick => 1.0, // 1.0 to pass tests - _ => 1.0, + Skill::Attack => 100, // 1.0 to pass tests + Skill::Strike => 110, + Skill::StrikeII => 130, + Skill::StrikeIII => 150, + Skill::StrangleTick => 30, + Skill::Riposte => 100, + Skill::Heal => 100, // 1.0 to pass tests + Skill::TriageTick => 65, + Skill::Blast => 130, + Skill::CorruptionTick => 80, + Skill::DecayTick => 60, + Skill::SiphonTick => 100, // 1.0 to pass tests + _ => 100, } } @@ -825,7 +828,7 @@ fn touch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: } fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - let amount = (source.red_damage() as f64 * skill.multiplier()).floor() as u64; + let amount = source.red_damage().pct(skill.multiplier()); println!("{:?}", amount); target.deal_red_damage(skill, amount) .into_iter() @@ -835,8 +838,7 @@ fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: } fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - - let amount = (source.red_damage() as f64 * skill.multiplier()).floor() as u64; + let amount = source.red_damage().pct(skill.multiplier()); target.deal_red_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -845,7 +847,7 @@ fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: } fn injure(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - let amount = (source.red_damage() as f64 * skill.multiplier()).floor() as u64; + let amount = source.red_damage().pct(skill.multiplier()); target.deal_red_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -895,7 +897,7 @@ fn strangle(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skil } fn strangle_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - let amount = (source.red_damage() as f64 * skill.multiplier()).floor() as u64; + let amount = source.red_damage().pct(skill.multiplier()); target.deal_red_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -926,7 +928,7 @@ fn parry(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: } fn riposte(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - let amount = (source.red_damage() as f64 * Skill::Riposte.multiplier()).floor() as u64; + let amount = source.red_damage().pct(skill.multiplier()); target.deal_red_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -947,7 +949,7 @@ fn empower(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill } fn heal(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - let amount = (source.green_damage() as f64 * skill.multiplier()).floor() as u64; + let amount = source.green_damage().pct(skill.multiplier()); target.deal_green_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -963,7 +965,7 @@ fn triage(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: } fn triage_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - let amount = (source.green_damage() as f64 * skill.multiplier()).floor() as u64; + let amount = source.green_damage().pct(skill.multiplier()); target.deal_green_damage(Skill::TriageTick, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -971,7 +973,7 @@ fn triage_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, s } fn blast(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - let amount = (source.blue_damage() as f64 * skill.multiplier()).floor() as u64; + let amount = source.blue_damage().pct(skill.multiplier()); target.deal_blue_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -1005,7 +1007,7 @@ fn decay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: } fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - let amount = (source.blue_damage() as f64 * skill.multiplier()).floor() as u64; + let amount = source.blue_damage().pct(skill.multiplier()); target.deal_blue_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -1029,7 +1031,7 @@ fn corruption(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, sk } fn corruption_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - let amount = (source.blue_damage() as f64 * skill.multiplier()).floor() as u64; + let amount = source.blue_damage().pct(skill.multiplier()); target.deal_blue_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -1095,7 +1097,7 @@ fn siphon(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: } fn siphon_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { - let amount = (source.blue_damage() as f64 * skill.multiplier()) as u64; + let amount = source.blue_damage().pct(skill.multiplier()); let siphon_events = target.deal_blue_damage(Skill::SiphonTick, amount); for e in siphon_events { @@ -1223,7 +1225,7 @@ mod tests { let mut y = Cryp::new() .named(&"camel".to_string()); - x.red_damage.force(10000000000000); // can't convert u64 max to f64 + x.red_damage.force(10000000000000); // multiplication of int max will cause overflow clutch(&mut y.clone(), &mut y, vec![], Skill::Clutch); assert!(y.affected(Effect::Clutch)); From f3aef83305b85d0e6fbe2112fec8d656ee9f14a8 Mon Sep 17 00:00:00 2001 From: Mashy Date: Wed, 1 May 2019 15:16:13 +1000 Subject: [PATCH 8/8] test fix, remove prnt lines --- server/src/game.rs | 4 ++-- server/src/skill.rs | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/server/src/game.rs b/server/src/game.rs index 3bfca93b..079e2cea 100644 --- a/server/src/game.rs +++ b/server/src/game.rs @@ -1068,8 +1068,8 @@ mod tests { let x_cryp = x_team.cryps[0].clone(); let y_cryp = y_team.cryps[0].clone(); - game.team_by_id(y_team.id).cryp_by_id(y_cryp.id).unwrap().red_damage.force(u64::max_value()); - game.team_by_id(y_team.id).cryp_by_id(y_cryp.id).unwrap().speed.force(u64::max_value()); + game.team_by_id(y_team.id).cryp_by_id(y_cryp.id).unwrap().red_damage.force(1000000000); + game.team_by_id(y_team.id).cryp_by_id(y_cryp.id).unwrap().speed.force(1000000000); // just in case // remove all mitigation diff --git a/server/src/skill.rs b/server/src/skill.rs index 3a36859d..e0b8fdeb 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -829,7 +829,6 @@ fn touch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { let amount = source.red_damage().pct(skill.multiplier()); - println!("{:?}", amount); target.deal_red_damage(skill, amount) .into_iter() .for_each(|e| results.push(Resolution::new(source, target).event(e))); @@ -1231,7 +1230,6 @@ mod tests { assert!(y.affected(Effect::Clutch)); let mut results = attack(&mut x, &mut y, vec![], Skill::Attack); - println!("{:?}", y.green_life()); assert!(y.green_life() == 1); let Resolution { source: _, target: _, event } = results.remove(0);