Converted mostly to Cryp Effects

This commit is contained in:
Mashy 2019-05-22 22:07:41 +10:00
parent 5f4a0b708e
commit 60b3445f84
4 changed files with 146 additions and 154 deletions

View File

@ -90,6 +90,10 @@ impl CrypEffect {
self.meta = Some(meta); self.meta = Some(meta);
self self
} }
pub fn get_duration(&self) -> u8 {
self.duration
}
} }
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)] #[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]

View File

@ -1319,11 +1319,11 @@ mod tests {
match source.id == x_cryp.id { match source.id == x_cryp.id {
true => match event { true => match event {
Event::Effect { effect, duration, skill: _ } => { Event::Effect { effect, duration, skill: _ } => {
assert!(*effect == Effect::Ruin); assert!(*effect == Effect::Stun);
assert!(*duration == 1); assert!(*duration == 1);
true true
}, },
Event::AoeSkill { skill } => false, Event::AoeSkill { skill: _ } => false,
_ => panic!("ruin result not effect {:?}", event), _ => panic!("ruin result not effect {:?}", event),
} }
false => false, false => false,

View File

@ -267,7 +267,7 @@ impl Item {
Item::Block => format!("Reduce incoming red damage by {:?}%", Item::Block => format!("Reduce incoming red damage by {:?}%",
100 - Effect::Block.apply(100, None)), 100 - Effect::Block.apply(100, None)),
Item::Stun => format!("Stun target cryp for {:?}T", Item::Stun => format!("Stun target cryp for {:?}T",
self.into_skill().unwrap().duration()), self.into_skill().unwrap().effect().first().unwrap().get_duration()),
Item::Buff => format!("Increase target cryp red damage and speed by {:?}%", Item::Buff => format!("Increase target cryp red damage and speed by {:?}%",
Effect::Buff.apply(100, None) - 100), Effect::Buff.apply(100, None) - 100),
Item::Debuff => format!("Slow target cryp"), Item::Debuff => format!("Slow target cryp"),
@ -310,11 +310,11 @@ impl Item {
// Skills <- need to move effect mulltipliers into skills // Skills <- need to move effect mulltipliers into skills
Item::Amplify => format!("Increase red and blue power by {:?}%. Lasts {:?}T", Item::Amplify => format!("Increase red and blue power by {:?}%. Lasts {:?}T",
Effect::Amplify.apply(100, None) - 100, Effect::Amplify.apply(100, None) - 100,
self.into_skill().unwrap().duration()), self.into_skill().unwrap().effect().first().unwrap().get_duration()),
Item::Banish => format!("Banish target for {:?}T. Item::Banish => format!("Banish target for {:?}T.
Banished cryps are immune to all skills and effects." Banished cryps are immune to all skills and effects.",
, self.into_skill().unwrap().duration()), self.into_skill().unwrap().effect().first().unwrap().get_duration()),
Item::Blast => format!("Deals blue damage {:?}% blue power.", self.into_skill().unwrap().multiplier()), Item::Blast => format!("Deals blue damage {:?}% blue power.", self.into_skill().unwrap().multiplier()),
@ -327,22 +327,23 @@ impl Item {
Item::Corrupt => format!( Item::Corrupt => format!(
"Self targetting defensive for {:?}T. Applies corrupt to attackers dealing blue damage {:?}% blue power per turn for {:?}T.", "Self targetting defensive for {:?}T. Applies corrupt to attackers dealing blue damage {:?}% blue power per turn for {:?}T.",
self.into_skill().unwrap().duration(), self.into_skill().unwrap().effect().first().unwrap().get_duration(),
Skill::Corrupt.multiplier(), Skill::Corrupt.multiplier(),
Skill::Corrupt.duration()), self.into_skill().unwrap().effect().first().unwrap().get_duration()), // Need secondary
Item::Curse => format!( Item::Curse => format!(
"Increases red and blue damage taken by 50%. Lasts {:?}T", "Increases red and blue damage taken by 50%. Lasts {:?}T",
self.into_skill().unwrap().duration()), self.into_skill().unwrap().effect().first().unwrap().get_duration()),
Item::Decay => format!( Item::Decay => format!(
"Reduces healing taken by 50% and deals blue damage {:?}% blue power each turn. Lasts {:?}T", "Reduces healing taken by 50% and deals blue damage {:?}% blue power each turn. Lasts {:?}T",
self.into_skill().unwrap().multiplier(), self.into_skill().unwrap().multiplier(),
self.into_skill().unwrap().duration()), self.into_skill().unwrap().effect().first().unwrap().get_duration()),
Item::Hostility => format!( Item::Hostility => format!(
"Gain Hostility for {:?}T. {} Hatred lasts {:?}T", "Gain Hostility for {:?}T. {} Hatred lasts {:?}T",
self.into_skill().unwrap().duration(), self.into_skill().unwrap().effect().first().unwrap().get_duration(),
"When attacked by Hostility you gain Hatred which increased red and blue power based on damage taken.", "When attacked by Hostility you gain Hatred which increased red and blue power based on damage taken.",
self.into_skill().unwrap().secondary_duration()), self.into_skill().unwrap().secondary_duration()),
@ -351,19 +352,21 @@ impl Item {
"Haste increases Speed by 50%, Red based Attack skills will strike again dealing", "Haste increases Speed by 50%, Red based Attack skills will strike again dealing",
Skill::HasteStrike.multiplier(), Skill::HasteStrike.multiplier(),
"% Speed as Red Damage", "% Speed as Red Damage",
self.into_skill().unwrap().duration()), self.into_skill().unwrap().effect().first().unwrap().get_duration()),
Item::Heal => format!("Heals for {:?}% green power.", self.into_skill().unwrap().multiplier()), Item::Heal => format!("Heals for {:?}% green power.", self.into_skill().unwrap().multiplier()),
Item::Hex => format!("Blue based skill that applies Hex for {:?}T. \ Item::Hex => format!("Blue based skill that applies Hex for {:?}T. \
Hexed targets cannot cast any skills.", self.into_skill().unwrap().duration()), Hexed targets cannot cast any skills.",
self.into_skill().unwrap().effect().first().unwrap().get_duration()),
Item::Impurity => format!( Item::Impurity => format!(
"{} {:?}{}. Lasts {:?}T", "{} {:?}{}. Lasts {:?}T",
"Impurity increases Green Power by 50%, Blue based Attack skills will blast again dealing", "Impurity increases Green Power by 50%, Blue based Attack skills will blast again dealing",
Skill::ImpureBlast.multiplier(), Skill::ImpureBlast.multiplier(),
"% Green Power as Blue Damage", "% Green Power as Blue Damage",
self.into_skill().unwrap().duration()), self.into_skill().unwrap().effect().first().unwrap().get_duration()),
Item::Invert => format!( Item::Invert => format!(
"Reverse healing into damage and damage into healing. "Reverse healing into damage and damage into healing.
@ -372,7 +375,7 @@ impl Item {
Item::Parry => format!("{} {:?}% red power and blocks red skills for {:?}T. {} {:?}% red power.", Item::Parry => format!("{} {:?}% red power and blocks red skills for {:?}T. {} {:?}% red power.",
"Self targetting skill. Recharges RedLife for", "Self targetting skill. Recharges RedLife for",
self.into_skill().unwrap().multiplier(), self.into_skill().unwrap().multiplier(),
self.into_skill().unwrap().duration(), self.into_skill().unwrap().effect().first().unwrap().get_duration(),
"If a red skill is parried the cryp will riposte the source dealing red damage", "If a red skill is parried the cryp will riposte the source dealing red damage",
Skill::Riposte.multiplier()), Skill::Riposte.multiplier()),
@ -384,23 +387,22 @@ impl Item {
Item::Reflect => format!( Item::Reflect => format!(
"Reflect incoming skills to source. Lasts {:?}T", "Reflect incoming skills to source. Lasts {:?}T",
self.into_skill().unwrap().duration()), self.into_skill().unwrap().effect().first().unwrap().get_duration()),
Item::Recharge => format!( Item::Recharge => format!(
"Recharge red and blue shield based on {:?} red and blue power", "Recharge red and blue shield based on {:?} red and blue power",
self.into_skill().unwrap().multiplier()), self.into_skill().unwrap().multiplier()),
Item::Ruin => format!( Item::Ruin => format!(
"Team wide Stun for {:?}T. Stunned cryps are unable to cast skills.", "Team wide Stun for {:?}T. Stunned cryps are unable to cast skills.",
self.into_skill().unwrap().duration()), self.into_skill().unwrap().effect().first().unwrap().get_duration()),
Item::Scatter => format!( Item::Scatter => format!(
"Caster links with target. Linked cryps split incoming damage evenly. Recharges target blue shield {:?}% of blue power", "Caster links with target. Linked cryps split incoming damage evenly. Recharges target blue shield {:?}% of blue power",
self.into_skill().unwrap().multiplier()), self.into_skill().unwrap().multiplier()),
Item::Silence => format!( Item::Silence => format!(
"Block the target from using blue skills for {:?}T and deals blue damage {:?}% blue power. {}", "Block the target from using blue skills for {:?}T and deals blue damage {:?}% blue power. {}",
self.into_skill().unwrap().duration(), self.into_skill().unwrap().effect().first().unwrap().get_duration(),
self.into_skill().unwrap().multiplier(), self.into_skill().unwrap().multiplier(),
"Deals 45% more damage per blue skill on target"), "Deals 45% more damage per blue skill on target"),
@ -410,12 +412,12 @@ impl Item {
Item::Sleep => format!( Item::Sleep => format!(
"Stun for {:?}T and heal for {:?}% green power.", "Stun for {:?}T and heal for {:?}% green power.",
self.into_skill().unwrap().duration(), self.into_skill().unwrap().effect().first().unwrap().get_duration(),
self.into_skill().unwrap().multiplier()), self.into_skill().unwrap().multiplier()),
Item::Snare => format!( Item::Snare => format!(
"Block the target from using red skills for {:?}T and deals red damage {:?}% red power. {}", "Block the target from using red skills for {:?}T and deals red damage {:?}% red power. {}",
self.into_skill().unwrap().duration(), self.into_skill().unwrap().effect().first().unwrap().get_duration(),
self.into_skill().unwrap().multiplier(), self.into_skill().unwrap().multiplier(),
"Deals 35% more damage per red skill on target"), "Deals 35% more damage per red skill on target"),
@ -423,7 +425,7 @@ impl Item {
"Strangle the target disabling skills from both the caster and the target. "Strangle the target disabling skills from both the caster and the target.
While strangling deal red damage each turn {:?}% red power. Lasts {:?}T.", While strangling deal red damage each turn {:?}% red power. Lasts {:?}T.",
self.into_skill().unwrap().multiplier(), self.into_skill().unwrap().multiplier(),
self.into_skill().unwrap().duration()), self.into_skill().unwrap().effect().first().unwrap().get_duration()),
Item::Strike => format!( Item::Strike => format!(
"Hits at maximum speed dealing red damage {:?}% red power", "Hits at maximum speed dealing red damage {:?}% red power",
@ -438,22 +440,24 @@ impl Item {
Item::Siphon => format!( Item::Siphon => format!(
"Deals blue damage {:?}% blue power each turn and heals caster based on damage dealt. Lasts {:?}T", "Deals blue damage {:?}% blue power each turn and heals caster based on damage dealt. Lasts {:?}T",
self.into_skill().unwrap().multiplier(), self.into_skill().unwrap().multiplier(),
self.into_skill().unwrap().duration()), self.into_skill().unwrap().effect().first().unwrap().get_duration()),
Item::Taunt => format!("{} {:?}T. Recharges RedLife for {:?} red power.", Item::Taunt => format!("{} {:?}T. Recharges RedLife for {:?} red power.",
"Taunt redirects skills against the team to target, lasts", "Taunt redirects skills against the team to target, lasts",
self.into_skill().unwrap().duration(), self.into_skill().unwrap().effect().first().unwrap().get_duration(),
self.into_skill().unwrap().multiplier()), self.into_skill().unwrap().multiplier()),
Item::Throw => format!( Item::Throw => format!(
"Stun the target for {:?}T and applies Vulnerable increasing red damage taken by 50% for {:?}T", "Stun the target for {:?}T and applies Vulnerable increasing red damage taken by 50% for {:?}T",
self.into_skill().unwrap().duration(), self.into_skill().unwrap().effect().first().unwrap().get_duration(),
self.into_skill().unwrap().secondary_duration()), self.into_skill().unwrap().secondary_duration()),
Item::Triage => format!( Item::Triage => format!(
"Heals target for {:?}% green power each turn. Lasts {:?}T", "Heals target for {:?}% green power each turn. Lasts {:?}T",
self.into_skill().unwrap().multiplier(), self.into_skill().unwrap().multiplier(),
self.into_skill().unwrap().duration()), self.into_skill().unwrap().effect().first().unwrap().get_duration()),
_ => format!("..."), _ => format!("..."),
} }

238
server/src/skill.rs Executable file → Normal file
View File

@ -668,82 +668,51 @@ impl Skill {
_ => 100, _ => 100,
} }
} }
/*
Effect::Amplify |
Effect::Vulnerable |
Effect::Block |
Effect::Buff |
Effect::Curse |
Effect::Haste |
Effect::Slow |
Effect::Impurity |
Effect::Wither => value.pct(match meta {
Some(EffectMeta::Multiplier(d)) => d,
_ => panic!("not multiplier"),
}),
*/
pub fn effect(&self) -> Vec<CrypEffect> { pub fn effect(&self) -> Vec<CrypEffect> {
match self { match self {
// Modifiers // Modifiers
Skill::Amplify => vec![CrypEffect {effect: Effect::Amplify, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None}], Skill::Amplify => vec![CrypEffect {effect: Effect::Amplify, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None}],
Skill::Banish => vec![CrypEffect {effect: Effect::Banish, duration: 1, meta: None, tick: None}],
Skill::Block => vec![CrypEffect {effect: Effect::Block, duration: 1, meta: Some(EffectMeta::Multiplier(50)), tick: None}], Skill::Block => vec![CrypEffect {effect: Effect::Block, duration: 1, meta: Some(EffectMeta::Multiplier(50)), tick: None}],
Skill::Buff => vec![CrypEffect {effect: Effect::Buff, duration: 2, meta: Some(EffectMeta::Multiplier(125)), tick: None }], Skill::Buff => vec![CrypEffect {effect: Effect::Buff, duration: 2, meta: Some(EffectMeta::Multiplier(125)), tick: None }],
Skill::Corrupt => vec![CrypEffect {effect: Effect::Corrupt, duration: 2, meta: None, tick: None}],
Skill::Clutch => vec![CrypEffect {effect: Effect::Clutch, duration: 1, meta: None, tick: None }],
Skill::Curse => vec![CrypEffect {effect: Effect::Curse, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None}], Skill::Curse => vec![CrypEffect {effect: Effect::Curse, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None}],
Skill::Debuff => vec![CrypEffect {effect: Effect::Slow, duration: 3, meta: Some(EffectMeta::Multiplier(50)), tick: None }], Skill::Debuff => vec![CrypEffect {effect: Effect::Slow, duration: 3, meta: Some(EffectMeta::Multiplier(50)), tick: None }],
Skill::Decay => vec![CrypEffect {effect: Effect::Wither, duration: 3, meta: Some(EffectMeta::Multiplier(50)), tick: None }], Skill::Decay => vec![
Skill::Impurity => vec![CrypEffect {effect: Effect::Impurity, duration: 3, meta: Some(EffectMeta::Multiplier(150)), tick: None }], CrypEffect {effect: Effect::Wither, duration: 3, meta: Some(EffectMeta::Multiplier(50)), tick: None },
CrypEffect {effect: Effect::Decay, duration: 3, meta: None, tick: None }],
Skill::Haste => vec![CrypEffect {effect: Effect::Haste, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None }], Skill::Haste => vec![CrypEffect {effect: Effect::Haste, duration: 2, meta: Some(EffectMeta::Multiplier(150)), tick: None }],
Skill::Throw => vec![CrypEffect {effect: Effect::Vulnerable, duration: 3, meta: Some(EffectMeta::Multiplier(150)), tick: None}], Skill::Hex => vec![CrypEffect {effect: Effect::Hex, duration: 2, meta: None, tick: None}],
Skill::Hostility => vec![CrypEffect {effect: Effect::Hostility, duration: 2, meta: None, tick: None}],
Skill::Impurity => vec![CrypEffect {effect: Effect::Impurity, duration: 3, meta: Some(EffectMeta::Multiplier(150)), tick: None }],
Skill::Invert => vec![CrypEffect {effect: Effect::Invert, duration: 2, meta: None, tick: None}],
// Disables Skill::Parry => vec![CrypEffect {effect: Effect::Parry, duration: 2, meta: None, tick: None }],
Skill::Reflect => vec![CrypEffect {effect: Effect::Reflect, duration: 1, meta: None, tick: None }],
Skill::Throw => vec![
CrypEffect {effect: Effect::Stun, duration: 1, meta: None, tick: None},
CrypEffect {effect: Effect::Vulnerable, duration: 3, meta: Some(EffectMeta::Multiplier(150)), tick: None}],
Skill::Ruin => vec![CrypEffect {effect: Effect::Stun, duration: 1, meta: None, tick: None}],
Skill::Scatter => vec![CrypEffect {effect: Effect::Scatter, duration: 2, meta: None, tick: None}],
Skill::Silence => vec![CrypEffect {effect: Effect::Silence, duration: 2, meta: None, tick: None}],
Skill::Siphon => vec![CrypEffect {effect: Effect::Siphon, duration: 2, meta: None, tick: None}],
Skill::Sleep => vec![CrypEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None}],
Skill::Snare => vec![CrypEffect {effect: Effect::Snare, duration: 2, meta: None, tick: None}],
Skill::Strangle => vec![CrypEffect {effect: Effect::Strangle, duration: 2, meta: None, tick: None}],
Skill::Stun => vec![CrypEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None}], Skill::Stun => vec![CrypEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None}],
Skill::Taunt => vec![CrypEffect {effect: Effect::Taunt, duration: 2, meta: None, tick: None}],
Skill::Triage => vec![CrypEffect {effect: Effect::Triage, duration: 2, meta: None, tick: None}],
//Unused
Skill::Injure => vec![CrypEffect {effect: Effect::Injured, duration: 2, meta: None, tick: None }],
_ => { _ => {
panic!("no skill effect"); panic!("{:?} no skill effect", self);
},
}
}
pub fn duration(&self) -> u8 {
match self {
Skill::Parry => 2,
Skill::Clutch => 1,
Skill::Reflect => 1,
Skill::Injure => 2,
Skill::Strangle => 2,
Skill::Stun => 2,
Skill::Sleep => 3,
Skill::Throw => 1,
Skill::Snare => 3,
Skill::Taunt => 2,
Skill::Invert => 1,
Skill::Hex => 2,
Skill::Ruin => 1,
Skill::Banish => 1,
Skill::Haste => 2,
Skill::Silence => 3,
Skill::Hostility => 2, // Primary Buff
Skill::Corrupt => 2, // Primary Buff
Skill::Scatter => 2,
Skill::Triage => 3,
Skill::Decay => 3,
Skill::Siphon => 2,
_ => {
info!("{:?} does not have a duration", self);
return 1;
}, },
} }
} }
@ -752,7 +721,6 @@ impl Skill {
match self { match self {
Skill::Hostility => 5, // Increased dmg buff Skill::Hostility => 5, // Increased dmg buff
Skill::Corrupt => 3, // Damage over time Skill::Corrupt => 3, // Damage over time
Skill::Throw => 3, // Inc dmg taken debuff
_ => { _ => {
info!("{:?} does not have a secondary duration", self); info!("{:?} does not have a secondary duration", self);
@ -1013,20 +981,23 @@ fn injure(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill:
.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, 2); skill.effect().into_iter()
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results; return results;
} }
fn stun(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn stun(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Stun, skill.duration()); skill.effect().into_iter()
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results; return results;
} }
fn sleep(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn sleep(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Stun, skill.duration()); skill.effect().into_iter()
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
let amount = source.green_damage().pct(skill.multiplier()); let amount = source.green_damage().pct(skill.multiplier());
target.deal_green_damage(skill, amount) target.deal_green_damage(skill, amount)
.into_iter() .into_iter()
@ -1036,8 +1007,8 @@ fn sleep(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill:
} }
fn clutch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn clutch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Clutch, skill.duration()); skill.effect().into_iter()
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results; return results;
} }
@ -1045,26 +1016,28 @@ fn taunt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill:
let red_amount = source.red_damage().pct(skill.multiplier()); let red_amount = source.red_damage().pct(skill.multiplier());
results.push(Resolution::new(source, target).event(target.recharge(skill, red_amount, 0))); results.push(Resolution::new(source, target).event(target.recharge(skill, red_amount, 0)));
let effect = CrypEffect::new(Effect::Taunt, skill.duration()); skill.effect().into_iter()
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results; return results;
} }
fn throw(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn throw(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let stun = CrypEffect::new(Effect::Stun, skill.duration()); skill.effect().into_iter()
results.push(Resolution::new(source, target).event(target.add_effect(skill, stun))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
skill.effect().into_iter().for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results; return results;
} }
fn strangle(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { 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, skill.duration()); skill.effect().into_iter().for_each(|e| {
let CrypEffect { effect: _, duration, meta: _, tick: _ } = e;
let strangle = e.clone().set_tick(Cast::new_tick(source, target, Skill::StrangleTick));
results.push(Resolution::new(source, target).event(target.add_effect(skill, strangle)));
results.push(Resolution::new(source, target).event(target.add_effect(skill, target_stun))); let attacker_strangle = CrypEffect::new(Effect::Strangling, duration);
results.push(Resolution::new(source, source).event(source.add_effect(skill, attacker_immunity))); results.push(Resolution::new(source, source).event(source.add_effect(skill, attacker_strangle)));
});
return strangle_tick(source, target, results, Skill::StrangleTick); return strangle_tick(source, target, results, Skill::StrangleTick);
} }
@ -1088,12 +1061,14 @@ fn strangle_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions,
} }
fn block(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn block(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter().for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results; return results;
} }
fn buff(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn buff(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter().for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results; return results;
} }
@ -1101,8 +1076,8 @@ fn parry(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill:
let red_amount = source.red_damage().pct(skill.multiplier()); let red_amount = source.red_damage().pct(skill.multiplier());
results.push(Resolution::new(source, target).event(target.recharge(skill, red_amount, 0))); results.push(Resolution::new(source, target).event(target.recharge(skill, red_amount, 0)));
let effect = CrypEffect::new(Effect::Parry, skill.duration()); skill.effect().into_iter()
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results; return results;
} }
@ -1116,8 +1091,8 @@ fn riposte(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill
} }
fn snare(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn snare(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let snare = CrypEffect::new(Effect::Snare, skill.duration()); skill.effect().into_iter()
results.push(Resolution::new(source, target).event(target.add_effect(skill, snare))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
let s_multi = target.skills let s_multi = target.skills
.iter() .iter()
@ -1164,10 +1139,11 @@ fn heal(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: S
} }
fn triage(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn triage(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Triage, skill.duration()) skill.effect().into_iter().for_each(|e| {
.set_tick(Cast::new_tick(source, target, Skill::TriageTick)); let triage = e.clone().set_tick(Cast::new_tick(source, target, Skill::TriageTick));
results.push(Resolution::new(source, target).event(target.add_effect(skill, triage)));
});
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
return triage_tick(source, target, results, Skill::TriageTick); return triage_tick(source, target, results, Skill::TriageTick);
} }
@ -1203,31 +1179,35 @@ fn blast(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill:
} }
fn amplify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn amplify(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter().for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results;; return results;;
} }
fn haste(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn haste(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter().for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results;; return results;;
} }
fn debuff(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn debuff(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter().for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results;; return results;;
} }
fn decay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { 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)); skill.effect().into_iter().for_each(|e| {
let CrypEffect { effect, duration: _, meta: _, tick: _ } = e;
let apply_effect = match effect {
Effect::Wither => e.clone(),
Effect::Decay => e.clone().set_tick(Cast::new_tick(source, target, Skill::DecayTick)),
_ => panic!("wrong decay effects"),
};
results.push(Resolution::new(source, target).event(target.add_effect(skill, apply_effect)));
});
results.push(Resolution::new(source, target).event(target.add_effect(skill, decay)));
skill.effect().into_iter().for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return decay_tick(source, target, results, Skill::DecayTick); return decay_tick(source, target, results, Skill::DecayTick);
} }
@ -1242,8 +1222,8 @@ fn decay_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, sk
// 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, skill: Skill) -> Resolutions { fn corrupt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Corrupt, skill.duration()); skill.effect().into_iter()
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results;; return results;;
} }
@ -1264,21 +1244,21 @@ fn corruption_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolution
} }
fn ruin(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn ruin(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Ruin, skill.duration()); skill.effect().into_iter()
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results;; return results;;
} }
fn hex(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn hex(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let hex = CrypEffect::new(Effect::Hex, skill.duration()); skill.effect().into_iter()
results.push(Resolution::new(source, target).event(target.add_effect(skill, hex))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results;; return results;;
} }
fn hostility(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn hostility(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Hostility, skill.duration()); skill.effect().into_iter()
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results;; return results;;
} }
@ -1291,24 +1271,26 @@ fn hatred(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, reflec
} }
fn curse(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn curse(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter().for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results;; return results;;
} }
fn impurity(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn impurity(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
skill.effect().into_iter().for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e))))); skill.effect().into_iter()
.for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results;; return results;;
} }
fn invert(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn invert(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Invert, skill.duration()); skill.effect().into_iter()
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results;; return results;;
} }
fn reflect(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn reflect(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Reflect, skill.duration()); skill.effect().into_iter()
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
let blue_amount = source.blue_damage().pct(skill.multiplier()); let blue_amount = source.blue_damage().pct(skill.multiplier());
results.push(Resolution::new(source, target).event(target.recharge(skill, 0, blue_amount))); results.push(Resolution::new(source, target).event(target.recharge(skill, 0, blue_amount)));
@ -1325,10 +1307,11 @@ fn recharge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skil
} }
fn siphon(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn siphon(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let siphon = CrypEffect::new(Effect::Siphon, skill.duration()) skill.effect().into_iter().for_each(|e| {
.set_tick(Cast::new_tick(source, target, Skill::SiphonTick)); let siphon = e.clone().set_tick(Cast::new_tick(source, target, Skill::SiphonTick));
results.push(Resolution::new(source, target).event(target.add_effect(skill, siphon)));
});
results.push(Resolution::new(source, target).event(target.add_effect(skill, siphon)));
return siphon_tick(source, target, results, Skill::SiphonTick); return siphon_tick(source, target, results, Skill::SiphonTick);
} }
@ -1353,13 +1336,14 @@ fn siphon_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, s
} }
fn scatter(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn scatter(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Scatter, skill.duration())
.set_meta(EffectMeta::ScatterTarget(target.id));
let blue_amount = source.blue_damage().pct(skill.multiplier()); let blue_amount = source.blue_damage().pct(skill.multiplier());
results.push(Resolution::new(source, target).event(target.recharge(skill, 0, blue_amount))); results.push(Resolution::new(source, target).event(target.recharge(skill, 0, blue_amount)));
results.push(Resolution::new(source, target).event(source.add_effect(skill, effect))); skill.effect().into_iter().for_each(|e| {
let scatter = e.clone().set_meta(EffectMeta::ScatterTarget(target.id));
results.push(Resolution::new(source, target).event(source.add_effect(skill, scatter)));
});
return results; return results;
} }
@ -1391,8 +1375,8 @@ fn scatter_hit(source: &Cryp, target: &Cryp, mut results: Resolutions, game: &mu
} }
fn silence(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions { fn silence(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let silence = CrypEffect::new(Effect::Silence, skill.duration()); skill.effect().into_iter()
results.push(Resolution::new(source, target).event(target.add_effect(skill, silence))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
let s_multi = target.skills let s_multi = target.skills
.iter() .iter()
@ -1437,8 +1421,8 @@ 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 { fn banish(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let banish = CrypEffect::new(Effect::Banish, skill.duration()); skill.effect().into_iter()
results.push(Resolution::new(source, target).event(target.add_effect(skill, banish))); .for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results; return results;
} }