Reworked application of effects

This commit is contained in:
Mashy 2019-05-22 13:34:08 +10:00
parent 35bcd89c03
commit 17e8407385
2 changed files with 72 additions and 37 deletions

View File

@ -65,6 +65,7 @@ pub enum EffectMeta {
TickAmount(u64),
AddedDamage(u64),
ScatterTarget(Uuid),
Multiplier(u64),
}
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]

View File

@ -454,18 +454,18 @@ impl Effect {
pub fn apply(&self, value: u64, meta: Option<EffectMeta>) -> u64 {
match self {
Effect::Vulnerable => value.pct(150),
Effect::Block => value.pct(50),
Effect::Buff => value.pct(125),
Effect::Amplify => value.pct(150),
Effect::Curse => value.pct(150),
Effect::Haste => value.pct(150),
Effect::Slow => value.pct(50),
Effect::Impurity => value.pct(150),
Effect::Wither => value.pct(50),
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"),
}),
Effect::Scatter => value >> 1,
@ -544,6 +544,11 @@ impl Effect {
}
}
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
pub enum SkillEffect {
Modifier {effect: Effect, multiplier: u64, duration: u8},
}
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
pub enum Category {
Red,
@ -672,14 +677,45 @@ impl Skill {
_ => 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) -> SkillEffect {
// Buff -> Effect, Multiplier, duration
match self {
Skill::Amplify => SkillEffect::Modifier {effect: Effect::Amplify, multiplier: 150, duration: 2},
Skill::Block => SkillEffect::Modifier {effect: Effect::Block, multiplier: 50, duration: 1},
Skill::Buff => SkillEffect::Modifier {effect: Effect::Buff, multiplier: 125, duration: 2},
Skill::Curse => SkillEffect::Modifier {effect: Effect::Curse, multiplier: 150, duration: 2},
Skill::Debuff => SkillEffect::Modifier {effect: Effect::Slow, multiplier: 50, duration: 3},
Skill::Decay => SkillEffect::Modifier {effect: Effect::Wither, multiplier: 50, duration: 3},
Skill::Impurity => SkillEffect::Modifier {effect: Effect::Impurity, multiplier: 150, duration: 3},
Skill::Haste => SkillEffect::Modifier {effect: Effect::Haste, multiplier: 150, duration: 2},
Skill::Throw => SkillEffect::Modifier {effect: Effect::Vulnerable, multiplier: 150, duration: 3},
_ => {
panic!("no skill effect");
},
}
}
pub fn duration(&self) -> u8 {
match self {
Skill::Block => 1,
Skill::Buff => 2,
Skill::Parry => 2,
Skill::Clutch => 1,
Skill::Debuff => 3,
Skill::Reflect => 1,
Skill::Injure => 2,
@ -693,17 +729,14 @@ impl Skill {
Skill::Snare => 3,
Skill::Taunt => 2,
Skill::Impurity => 3,
Skill::Invert => 1,
Skill::Hex => 2,
Skill::Ruin => 1,
Skill::Curse => 2,
Skill::Banish => 1,
Skill::Haste => 2,
Skill::Amplify => 2,
Skill::Silence => 3,
Skill::Hostility => 2, // Primary Buff
@ -951,6 +984,17 @@ impl Skill {
}
}
fn apply_modifier(skill: Skill, source: &mut Cryp, target: &mut Cryp) -> Resolution {
let skillEffect = skill.effect();
match skillEffect {
SkillEffect::Modifier { effect, multiplier, duration } => {
let crypEffect = CrypEffect::new(effect, duration)
.set_meta(EffectMeta::Multiplier(multiplier));
return Resolution::new(source, target).event(target.add_effect(skill, crypEffect));
}
}
}
fn touch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
target.deal_red_damage(skill, 0)
.into_iter()
@ -1022,11 +1066,8 @@ 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 {
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, stun)));
results.push(Resolution::new(source, target).event(target.add_effect(skill, vulnerable)));
results.push(apply_modifier(skill, source, target));
return results;
}
@ -1061,14 +1102,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 {
let block = CrypEffect::new(Effect::Block, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, block)));
results.push(apply_modifier(skill, source, target));
return results;
}
fn buff(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let fx = CrypEffect::new(Effect::Buff, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, fx)));
results.push(apply_modifier(skill, source, target));
return results;
}
@ -1178,30 +1217,27 @@ 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 {
let amplify = CrypEffect::new(Effect::Amplify, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, amplify)));
results.push(apply_modifier(skill, source, target));
return results;;
}
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)));
results.push(apply_modifier(skill, source, target));
return results;;
}
fn debuff(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)));
results.push(apply_modifier(skill, source, target));
return results;;
}
fn decay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let wither = CrypEffect::new(Effect::Wither, skill.duration());
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)));
results.push(Resolution::new(source, target).event(target.add_effect(skill, wither)));
results.push(apply_modifier(skill, source, target));
return decay_tick(source, target, results, Skill::DecayTick);
}
@ -1265,14 +1301,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 {
let curse = CrypEffect::new(Effect::Curse, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(Skill::Curse, curse)));
results.push(apply_modifier(skill, source, target));
return results;;
}
fn impurity(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions, skill: Skill) -> Resolutions {
let effect = CrypEffect::new(Effect::Impurity, skill.duration());
results.push(Resolution::new(source, target).event(target.add_effect(skill, effect)));
results.push(apply_modifier(skill, source, target));
return results;;
}