effects into vec init

This commit is contained in:
Mashy 2019-05-22 17:36:27 +10:00
parent ddfe40d7c1
commit 921eac87dc

View File

@ -544,12 +544,6 @@ impl Effect {
} }
} }
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
pub enum SkillEffect {
Modifier {effect: Effect, multiplier: u64, duration: u8},
Disable {effect: Effect, duration: u8},
}
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)] #[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
pub enum Category { pub enum Category {
Red, Red,
@ -693,22 +687,21 @@ impl Skill {
}), }),
*/ */
pub fn effect(&self) -> CrypEffect { pub fn effect(&self) -> Vec<CrypEffect> {
// Buff -> Effect, Multiplier, duration
match self { match self {
// Modifiers // Modifiers
Skill::Amplify => 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::Block => 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 => 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::Curse => 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 => 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 => CrypEffect {effect: Effect::Wither, 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::Impurity => CrypEffect {effect: Effect::Impurity, duration: 3, meta: Some(EffectMeta::Multiplier(150)), tick: None }, Skill::Impurity => vec![CrypEffect {effect: Effect::Impurity, duration: 3, meta: Some(EffectMeta::Multiplier(150)), tick: None }],
Skill::Haste => 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 => CrypEffect {effect: Effect::Vulnerable, duration: 3, meta: Some(EffectMeta::Multiplier(150)), tick: None}, Skill::Throw => vec![CrypEffect {effect: Effect::Vulnerable, duration: 3, meta: Some(EffectMeta::Multiplier(150)), tick: None}],
// Disables // Disables
Skill::Stun => CrypEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None}, Skill::Stun => vec![CrypEffect {effect: Effect::Stun, duration: 2, meta: None, tick: None}],
_ => { _ => {
panic!("no skill effect"); panic!("no skill effect");
@ -1060,7 +1053,7 @@ fn taunt(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill:
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()); let stun = CrypEffect::new(Effect::Stun, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, stun))); results.push(Resolution::new(source, target).event(target.add_effect(skill, stun)));
results.push(Resolution::new(source, target).event(target.add_effect(skill, skill.effect()))); skill.effect().into_iter().for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results; return results;
} }
@ -1095,12 +1088,12 @@ 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 {
results.push(Resolution::new(source, target).event(target.add_effect(skill, skill.effect()))); 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 {
results.push(Resolution::new(source, target).event(target.add_effect(skill, skill.effect()))); skill.effect().into_iter().for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results; return results;
} }
@ -1210,17 +1203,20 @@ 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 {
results.push(Resolution::new(source, target).event(target.add_effect(skill, skill.effect()))); 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 {
results.push(Resolution::new(source, target).event(target.add_effect(skill, skill.effect()))); 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 {
results.push(Resolution::new(source, target).event(target.add_effect(skill, skill.effect()))); skill.effect().into_iter().for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results;; return results;;
} }
@ -1229,7 +1225,7 @@ fn decay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill:
.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))); results.push(Resolution::new(source, target).event(target.add_effect(skill, decay)));
results.push(Resolution::new(source, target).event(target.add_effect(skill, skill.effect()))); 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);
} }
@ -1294,12 +1290,12 @@ 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 {
results.push(Resolution::new(source, target).event(target.add_effect(skill, skill.effect()))); 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 {
results.push(Resolution::new(source, target).event(target.add_effect(skill, skill.effect()))); skill.effect().into_iter().for_each(|e| (results.push(Resolution::new(source, target).event(target.add_effect(skill, e)))));
return results;; return results;;
} }
@ -1412,7 +1408,7 @@ fn silence(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill
return results; return results;
} }
fn purge(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> 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())) {