added impl multiplier fn, floating point dmg calculation

This commit is contained in:
Mashy 2019-04-30 12:13:19 +10:00
parent 57b3782a45
commit a1e0419e3c

View File

@ -584,6 +584,22 @@ pub enum Skill {
} }
impl Skill { impl Skill {
pub fn multiplier(&self) -> f64 {
match self {
Skill::Attack => 0.9,
Skill::Strike => 1.1,
Skill::StrangleTick => 0.3,
Skill::Riposte => 1.0,
Skill::Heal => 1.2,
Skill::TriageTick => 0.65,
Skill::Blast => 1.3,
Skill::CorruptionTick => 0.8,
Skill::DecayTick => 0.6,
Skill::SiphonTick => 0.4,
_ => 1.0,
}
}
pub fn base_cd(&self) -> Cooldown { pub fn base_cd(&self) -> Cooldown {
match self { match self {
Skill::Attack => None, Skill::Attack => None,
@ -786,7 +802,7 @@ fn touch(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Reso
} }
fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let amount = source.red_damage(); 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()
.for_each(|e| results.push(Resolution::new(source, target).event(e))); .for_each(|e| results.push(Resolution::new(source, target).event(e)));
@ -795,7 +811,7 @@ fn attack(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Res
} }
fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let amount = source.red_damage(); let amount = (source.red_damage() as f64 * Skill::Strike.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)));
@ -804,8 +820,8 @@ fn strike(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Res
} }
fn injure(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn injure(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let amount = source.red_damage(); let amount = (source.red_damage() as f64 * Skill::Injure.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)));
@ -854,7 +870,7 @@ fn strangle(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> R
} }
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) -> Resolutions {
let amount = source.red_damage(); let amount = (source.red_damage() as f64 * Skill::StrangleTick.multiplier()).floor() as u64;
target.deal_red_damage(Skill::StrangleTick, amount) target.deal_red_damage(Skill::StrangleTick, 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)));
@ -885,7 +901,7 @@ fn parry(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Reso
} }
fn riposte(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn riposte(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let amount = source.red_damage(); 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()
.for_each(|e| results.push(Resolution::new(source, target).event(e))); .for_each(|e| results.push(Resolution::new(source, target).event(e)));
@ -906,7 +922,7 @@ fn empower(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Re
} }
fn heal(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn heal(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let amount = source.green_damage(); 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()
.for_each(|e| results.push(Resolution::new(source, target).event(e))); .for_each(|e| results.push(Resolution::new(source, target).event(e)));
@ -922,7 +938,7 @@ fn triage(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Res
} }
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) -> Resolutions {
let amount = source.green_damage().wrapping_div(2); let amount = (source.green_damage() as f64 * Skill::TriageTick.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)));
@ -930,7 +946,7 @@ fn triage_tick(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -
} }
fn blast(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions { fn blast(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Resolutions {
let amount = source.blue_damage(); let amount = (source.blue_damage() as f64 * Skill::Blast.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)));
@ -964,7 +980,7 @@ fn decay(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Reso
} }
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) -> Resolutions {
let amount = source.blue_damage() / 2; let amount = (source.blue_damage() as f64 * Skill::DecayTick.multiplier()) 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)));
@ -988,7 +1004,7 @@ fn corruption(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) ->
} }
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) -> Resolutions {
let amount = source.blue_damage() / 2; let amount = (source.blue_damage() as f64 * Skill::CorruptionTick.multiplier()) 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)));
@ -1054,7 +1070,7 @@ fn siphon(source: &mut Cryp, target: &mut Cryp, mut results: Resolutions) -> Res
} }
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) -> Resolutions {
let amount = source.blue_damage(); let amount = (source.blue_damage() as f64 * Skill::Siphon.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 {