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; }