Effect duration taken from skill

This commit is contained in:
Mashy 2019-04-30 21:47:33 +10:00
parent 6bbaa5da70
commit 9d1d470cb6
2 changed files with 235 additions and 236 deletions

View File

@ -75,8 +75,8 @@ pub struct CrypEffect {
} }
impl CrypEffect { impl CrypEffect {
pub fn new(effect: Effect) -> CrypEffect { pub fn new(effect: Effect, duration: u8) -> CrypEffect {
CrypEffect { effect, duration: effect.duration(), meta: None, tick: None } CrypEffect { effect, duration, meta: None, tick: None }
} }
pub fn set_tick(mut self, tick: Cast) -> CrypEffect { pub fn set_tick(mut self, tick: Cast) -> CrypEffect {
@ -697,7 +697,7 @@ impl Cryp {
// todo modified durations cause of buffs // todo modified durations cause of buffs
let result = Event::Effect { let result = Event::Effect {
effect: effect.effect, effect: effect.effect,
duration: effect.effect.duration(), duration: effect.duration,
skill, skill,
}; };

View File

@ -35,57 +35,57 @@ pub fn resolve(skill: Skill, source: &mut Cryp, target: &mut Cryp, mut resolutio
// } // }
resolutions = match skill { resolutions = match skill {
Skill::Amplify => amplify(source, target, resolutions), // increase magic damage Skill::Amplify => amplify(source, target, resolutions, Skill::Amplify), // increase magic damage
Skill::Attack => attack(source, target, resolutions), Skill::Attack => attack(source, target, resolutions, Skill::Attack),
Skill::Banish => banish(source, target, resolutions), // TODO prevent all actions Skill::Banish => banish(source, target, resolutions, Skill::Banish), // TODO prevent all actions
Skill::Blast => blast(source, target, resolutions), Skill::Blast => blast(source, target, resolutions, Skill::Blast),
Skill::Block => block(source, target, resolutions), Skill::Block => block(source, target, resolutions, Skill::Block),
Skill::Clutch => clutch(source, target, resolutions), Skill::Clutch => clutch(source, target, resolutions, Skill::Clutch),
Skill::Corrupt => corrupt(source, target, resolutions), Skill::Corrupt => corrupt(source, target, resolutions, Skill::Corrupt),
Skill::CorruptionTick => corruption_tick(source, target, resolutions), Skill::CorruptionTick => corruption_tick(source, target, resolutions, Skill::CorruptionTick),
Skill::Curse => curse(source, target, resolutions), Skill::Curse => curse(source, target, resolutions, Skill::Curse),
Skill::Decay => decay(source, target, resolutions), // dot Skill::Decay => decay(source, target, resolutions, Skill::Decay), // dot
Skill::DecayTick => decay_tick(source, target, resolutions), // dot Skill::DecayTick => decay_tick(source, target, resolutions, Skill::DecayTick), // dot
Skill::Empower => empower(source, target, resolutions), // increased phys damage Skill::Empower => empower(source, target, resolutions, Skill::Empower), // increased phys damage
Skill::Haste => haste(source, target, resolutions), // speed slow Skill::Haste => haste(source, target, resolutions, Skill::Haste), // speed slow
Skill::Heal => heal(source, target, resolutions), Skill::Heal => heal(source, target, resolutions, Skill::Heal),
Skill::Hex => hex(source, target, resolutions), Skill::Hex => hex(source, target, resolutions, Skill::Hex),
Skill::Hostility => hostility(source, target, resolutions), Skill::Hostility => hostility(source, target, resolutions, Skill::Hostility),
Skill::Invert => invert(source, target, resolutions), Skill::Invert => invert(source, target, resolutions, Skill::Invert),
Skill::Injure => injure(source, target, resolutions), Skill::Injure => injure(source, target, resolutions, Skill::Injure),
Skill::Parry => parry(source, target, resolutions), Skill::Parry => parry(source, target, resolutions, Skill::Parry),
Skill::Purge => purge(source, target, resolutions), // dispel all buffs Skill::Purge => purge(source, target, resolutions, Skill::Purge), // dispel all buffs
Skill::Purify => purify(source, target, resolutions), // dispel all debuffs Skill::Purify => purify(source, target, resolutions, Skill::Purify), // dispel all debuffs
Skill::Recharge => recharge(source, target, resolutions), // target is immune to magic damage and fx Skill::Recharge => recharge(source, target, resolutions, Skill::Recharge), // target is immune to magic damage and fx
Skill::Reflect => reflect(source, target, resolutions), Skill::Reflect => reflect(source, target, resolutions, Skill::Reflect),
Skill::Riposte => panic!("riposte should not be caste"), Skill::Riposte => panic!("riposte should not be caste"),
Skill::Ruin => ruin(source, target, resolutions), Skill::Ruin => ruin(source, target, resolutions, Skill::Ruin),
Skill::Shield => shield(source, target, resolutions), // target is immune to magic damage and fx Skill::Shield => shield(source, target, resolutions, Skill::Shield), // target is immune to magic damage and fx
Skill::Silence => silence(source, target, resolutions), // target cannot cast spells Skill::Silence => silence(source, target, resolutions, Skill::Silence), // target cannot cast spells
Skill::Siphon => siphon(source, target, resolutions), Skill::Siphon => siphon(source, target, resolutions, Skill::Siphon),
Skill::SiphonTick => siphon_tick(source, target, resolutions), // hot Skill::SiphonTick => siphon_tick(source, target, resolutions, Skill::SiphonTick), // hot
Skill::Slay => unimplemented!(), Skill::Slay => unimplemented!(),
Skill::Slow => slow(source, target, resolutions), // speed slow Skill::Slow => slow(source, target, resolutions, Skill::Slow), // speed slow
Skill::Snare => snare(source, target, resolutions), Skill::Snare => snare(source, target, resolutions, Skill::Snare),
Skill::Strangle => strangle(source, target, resolutions), Skill::Strangle => strangle(source, target, resolutions, Skill::Strangle),
Skill::StrangleTick => strangle_tick(source, target, resolutions), Skill::StrangleTick => strangle_tick(source, target, resolutions, Skill::StrangleTick),
Skill::Strike => strike(source, target, resolutions, Tier::T1), Skill::Strike => strike(source, target, resolutions, Skill::Strike),
Skill::StrikeII => strike(source, target, resolutions, Tier::T2), Skill::StrikeII => strike(source, target, resolutions, Skill::StrikeII),
Skill::StrikeIII => strike(source, target, resolutions, Tier::T3), Skill::StrikeIII => strike(source, target, resolutions, Skill::StrikeIII),
Skill::Stun => stun(source, target, resolutions), Skill::Stun => stun(source, target, resolutions, Skill::Stun),
Skill::Taunt => taunt(source, target, resolutions), Skill::Taunt => taunt(source, target, resolutions, Skill::Taunt),
Skill::Throw => throw(source, target, resolutions), // no damage stun, adds vulnerable Skill::Throw => throw(source, target, resolutions, Skill::Throw), // no damage stun, adds vulnerable
Skill::Triage => triage(source, target, resolutions), // hot Skill::Triage => triage(source, target, resolutions, Skill::Triage), // hot
Skill::TriageTick => triage_tick(source, target, resolutions), // hot Skill::TriageTick => triage_tick(source, target, resolutions, Skill::TriageTick), // hot
// ----------------- // -----------------
// Test // Test
// ----------------- // -----------------
Skill::TestTouch => touch(source, target, resolutions), Skill::TestTouch => touch(source, target, resolutions, Skill::TestTouch),
Skill::TestStun => stun(source, target, resolutions), Skill::TestStun => stun(source, target, resolutions, Skill::Stun),
Skill::TestBlock => block(source, target, resolutions), Skill::TestBlock => block(source, target, resolutions, Skill::Block),
Skill::TestParry => parry(source, target, resolutions), Skill::TestParry => parry(source, target, resolutions, Skill::Parry),
Skill::TestSiphon => siphon(source, target, resolutions), Skill::TestSiphon => siphon(source, target, resolutions, Skill::Siphon),
}; };
// if any event dealt damage to target cryp // 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 { match r.event {
Event::Damage { amount, skill, mitigation: _, colour: _ } => { Event::Damage { amount, skill, mitigation: _, colour: _ } => {
if target.affected(Effect::Corrupt) { if target.affected(Effect::Corrupt) {
resolutions = corruption(target, source, resolutions); resolutions = corruption(target, source, resolutions, Skill::Corrupt);
} }
if target.affected(Effect::Hostility) { 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) { Event::Immunity { skill: _, immunity } => match immunity.contains(&Effect::Parry) {
true => resolutions = riposte(target, source, resolutions), true => resolutions = riposte(target, source, resolutions, Skill::Riposte),
false => (), false => (),
}, },
_ => (), _ => (),
@ -430,58 +430,6 @@ impl Effect {
Effect::Ko => Category::Ko, 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)] #[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
@ -504,13 +452,6 @@ pub enum Category {
Ko, Ko,
} }
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
pub enum Tier {
T1,
T2,
T3,
}
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)] #[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
pub enum Skill { pub enum Skill {
Attack, 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 { pub fn base_cd(&self) -> Cooldown {
match self { match self {
Skill::Attack => None, Skill::Attack => None,
@ -813,15 +816,15 @@ impl Skill {
} }
} }
fn touch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn touch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
target.deal_red_damage(Skill::TestTouch, 0) target.deal_red_damage(skill, 0)
.into_iter() .into_iter()
.for_each(|e| results.push(Resolution::new(source, target).event(e))); .for_each(|e| results.push(Resolution::new(source, target).event(e)));
return results; 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; let amount = (source.red_damage() as f64 * Skill::Attack.multiplier()).floor() as u64;
target.deal_red_damage(Skill::Attack, amount) target.deal_red_damage(Skill::Attack, amount)
.into_iter() .into_iter()
@ -830,13 +833,9 @@ fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Res
return results; return results;
} }
fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, tier: Tier) -> Resolutions { fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let multiplier = match tier {
Tier::T1 => Skill::Strike.multiplier(), let amount = (source.red_damage() as f64 * skill.multiplier()).floor() as u64;
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) target.deal_red_damage(Skill::Strike, amount)
.into_iter() .into_iter()
.for_each(|e| results.push(Resolution::new(source, target).event(e))); .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; return results;
} }
fn injure(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn injure(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = (source.red_damage() as f64 * Skill::Injure.multiplier()).floor() as u64; let amount = (source.red_damage() as f64 * skill.multiplier()).floor() as u64;
target.deal_red_damage(Skill::Injure, amount) target.deal_red_damage(Skill::Injure, amount)
.into_iter() .into_iter()
.for_each(|e| results.push(Resolution::new(source, target).event(e))); .for_each(|e| results.push(Resolution::new(source, target).event(e)));
let effect = CrypEffect::new(Effect::Injured); let effect = CrypEffect::new(Effect::Injured, 2);
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Injure, effect))); results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results; return results;
} }
fn stun(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn stun(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Stun); let effect = CrypEffect::new(Effect::Stun, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Stun, effect))); results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results; return results;
} }
fn clutch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn clutch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Clutch); let effect = CrypEffect::new(Effect::Clutch, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Clutch, effect))); results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results; return results;
} }
fn taunt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn taunt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Taunt); let effect = CrypEffect::new(Effect::Taunt, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Taunt, effect))); results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results; return results;
} }
fn throw(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn throw(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let stun = CrypEffect::new(Effect::Stun); let stun = CrypEffect::new(Effect::Stun, skill.duration());
let vulnerable = CrypEffect::new(Effect::Vulnerable); 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, 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, vulnerable)));
return results; return results;
} }
fn strangle(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn strangle(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let target_stun = CrypEffect::new(Effect::Strangle) let target_stun = CrypEffect::new(Effect::Strangle, skill.duration())
.set_tick(Cast::new_tick(source, target, Skill::StrangleTick)); .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, target).event(target.add_effect(skill, target_stun)));
results.push(Resolution::new(source, source).event(source.add_effect(Skill::Strangle, attacker_immunity))); results.push(Resolution::new(source, source).event(source.add_effect(skill, attacker_immunity)));
return strangle_tick(source, target, results); return strangle_tick(source, target, results, Skill::StrangleTick);
} }
fn strangle_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn strangle_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = (source.red_damage() as f64 * Skill::StrangleTick.multiplier()).floor() as u64; let amount = (source.red_damage() as f64 * skill.multiplier()).floor() as u64;
target.deal_red_damage(Skill::StrangleTick, amount) target.deal_red_damage(skill, amount)
.into_iter() .into_iter()
.for_each(|e| results.push(Resolution::new(source, target).event(e))); .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; return results;
} }
fn block(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn block(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let block = CrypEffect::new(Effect::Block); let block = CrypEffect::new(Effect::Block, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Block, block))); results.push(Resolution::new(source, target).event(target.add_effect(skill, block)));
return results; return results;
} }
fn parry(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn parry(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Parry); let effect = CrypEffect::new(Effect::Parry, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Parry, effect))); results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results; 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; 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::Riposte, amount)
.into_iter() .into_iter()
@ -934,19 +933,19 @@ fn riposte(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Re
return results; return results;
} }
fn snare(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn snare(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let snare = CrypEffect::new(Effect::Snare); let snare = CrypEffect::new(Effect::Snare, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Snare, snare))); results.push(Resolution::new(source, target).event(target.add_effect(skill, snare)));
return results; return results;
} }
fn empower(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn empower(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let empower = CrypEffect::new(Effect::Empower); let empower = CrypEffect::new(Effect::Empower, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Empower, empower))); results.push(Resolution::new(source, target).event(target.add_effect(skill, empower)));
return results; 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; let amount = (source.green_damage() as f64 * Skill::Heal.multiplier()).floor() as u64;
target.deal_green_damage(Skill::Heal, amount) target.deal_green_damage(Skill::Heal, amount)
.into_iter() .into_iter()
@ -954,58 +953,58 @@ fn heal(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resol
return results; return results;
} }
fn triage(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn triage(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Triage) let effect = CrypEffect::new(Effect::Triage, skill.duration())
.set_tick(Cast::new_tick(source, target, Skill::TriageTick)); .set_tick(Cast::new_tick(source, target, Skill::TriageTick));
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Triage, effect))); results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return triage_tick(source, target, results); return triage_tick(source, target, results, Skill::TriageTick);
} }
fn triage_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn triage_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = (source.green_damage() as f64 * Skill::TriageTick.multiplier()).floor() as u64; let amount = (source.green_damage() as f64 * skill.multiplier()).floor() as u64;
target.deal_green_damage(Skill::TriageTick, amount) target.deal_green_damage(Skill::TriageTick, amount)
.into_iter() .into_iter()
.for_each(|e| results.push(Resolution::new(source, target).event(e))); .for_each(|e| results.push(Resolution::new(source, target).event(e)));
return results; return results;
} }
fn blast(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn blast(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = (source.blue_damage() as f64 * Skill::Blast.multiplier()).floor() as u64; let amount = (source.blue_damage() as f64 * skill.multiplier()).floor() as u64;
target.deal_blue_damage(Skill::Blast, amount) target.deal_blue_damage(Skill::Blast, amount)
.into_iter() .into_iter()
.for_each(|e| results.push(Resolution::new(source, target).event(e))); .for_each(|e| results.push(Resolution::new(source, target).event(e)));
return results; return results;
} }
fn amplify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn amplify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let amplify = CrypEffect::new(Effect::Amplify); let amplify = CrypEffect::new(Effect::Amplify, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Amplify, amplify))); results.push(Resolution::new(source, target).event(target.add_effect(skill, amplify)));
return results;; return results;;
} }
fn haste(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn haste(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Haste); let effect = CrypEffect::new(Effect::Haste, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Haste, effect))); results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results;; return results;;
} }
fn slow(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn slow(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Slow); let effect = CrypEffect::new(Effect::Slow, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Slow, effect))); results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results;; return results;;
} }
fn decay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn decay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let decay = CrypEffect::new(Effect::Decay) let decay = CrypEffect::new(Effect::Decay, skill.duration())
.set_tick(Cast::new_tick(source, target, Skill::DecayTick)); .set_tick(Cast::new_tick(source, target, Skill::DecayTick));
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Decay, decay))); results.push(Resolution::new(source, target).event(target.add_effect(skill, decay)));
return decay_tick(source, target, results); return decay_tick(source, target, results, Skill::DecayTick);
} }
fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = (source.blue_damage() as f64 * Skill::DecayTick.multiplier()).floor() as u64; let amount = (source.blue_damage() as f64 * skill.multiplier()).floor() as u64;
target.deal_blue_damage(Skill::DecayTick, amount) target.deal_blue_damage(Skill::DecayTick, amount)
.into_iter() .into_iter()
.for_each(|e| results.push(Resolution::new(source, target).event(e))); .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 // corrupt is the buff effect
// when attacked it runs corruption and applies a debuff // when attacked it runs corruption and applies a debuff
fn corrupt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn corrupt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Corrupt); let effect = CrypEffect::new(Effect::Corrupt, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Corrupt, effect))); results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results;; return results;;
} }
fn corruption(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn corruption(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Corruption) let effect = CrypEffect::new(Effect::Corruption, skill.secondary_duration())
.set_tick(Cast::new_tick(source, target, Skill::CorruptionTick)); .set_tick(Cast::new_tick(source, target, Skill::CorruptionTick));
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Corrupt, effect))); results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return corruption_tick(source, target, results); return corruption_tick(source, target, results, Skill::CorruptionTick);
} }
fn corruption_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn corruption_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = (source.blue_damage() as f64 * Skill::CorruptionTick.multiplier()).floor() as u64; let amount = (source.blue_damage() as f64 * skill.multiplier()).floor() as u64;
target.deal_blue_damage(Skill::CorruptionTick, amount) target.deal_blue_damage(Skill::CorruptionTick, amount)
.into_iter() .into_iter()
.for_each(|e| results.push(Resolution::new(source, target).event(e))); .for_each(|e| results.push(Resolution::new(source, target).event(e)));
return results; return results;
} }
fn ruin(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn ruin(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Ruin); let effect = CrypEffect::new(Effect::Ruin, skill.duration());
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));
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return results;; 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))); results.push(Resolution::new(source, target).event(target.add_effect(Skill::Curse, curse)));
return results;; return results;;
} }
fn invert(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn invert(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Invert); 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::Invert, effect)));
return results;; return results;;
} }
fn reflect(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn reflect(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Reflect); 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::Reflect, effect)));
return results;; 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())); results.push(Resolution::new(source, target).event(target.recharge()));
return results; return results;
} }
fn siphon(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn siphon(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let siphon = CrypEffect::new(Effect::Siphon) let siphon = CrypEffect::new(Effect::Siphon, skill.duration())
.set_tick(Cast::new_tick(source, target, Skill::SiphonTick)); .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, 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 { fn siphon_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let amount = (source.blue_damage() as f64 * Skill::Siphon.multiplier()) as u64; let amount = (source.blue_damage() as f64 * skill.multiplier()) as u64;
let siphon_events = target.deal_blue_damage(Skill::SiphonTick, amount); let siphon_events = target.deal_blue_damage(Skill::SiphonTick, amount);
for e in siphon_events { for e in siphon_events {
@ -1115,19 +1114,19 @@ fn siphon_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -
return results; return results;
} }
fn shield(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn shield(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let shield = CrypEffect::new(Effect::Shield); 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, shield)));
return results; return results;
} }
fn silence(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn silence(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let silence = CrypEffect::new(Effect::Silence); 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, silence)));
return results; 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 while let Some(i) = target.effects
.iter() .iter()
.position(|ce| [Category::Buff, Category::Buff].contains(&ce.effect.category())) { .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; 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 while let Some(i) = target.effects
.iter() .iter()
.position(|ce| [Category::Debuff, Category::Debuff].contains(&ce.effect.category())) { .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; return results;
} }
fn banish(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn banish(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let banish = CrypEffect::new(Effect::Banish); 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, banish)));
return results; return results;
} }