fix mitigation calcs
This commit is contained in:
parent
720b70097b
commit
2a00f4aa4c
@ -8,6 +8,11 @@
|
||||
* phys is faster and chaotic
|
||||
* spells are slow and reliable
|
||||
|
||||
# ask sam
|
||||
* icons
|
||||
* skill type / damage type
|
||||
* skills themselves
|
||||
|
||||
# WORK WORK
|
||||
|
||||
broken skills
|
||||
|
||||
@ -349,7 +349,6 @@ impl Cryp {
|
||||
.collect::<Vec<Effect>>();
|
||||
|
||||
let modified_phys_dmg = phys_dmg_mods.iter().fold(self.phys_dmg.base, |acc, m| m.apply(acc));
|
||||
|
||||
return modified_phys_dmg;
|
||||
}
|
||||
|
||||
@ -446,22 +445,23 @@ impl Cryp {
|
||||
|
||||
// println!("{:?}", phys_dmg_mods);
|
||||
|
||||
let modified_phys_dmg = phys_dmg_mods.iter().fold(amount, |acc, m| m.apply(acc));
|
||||
let modified_dmg = phys_dmg_mods.iter().fold(amount, |acc, m| m.apply(acc));
|
||||
|
||||
// calculate amount of damage armour will not absorb
|
||||
// eg 50 armour 25 dmg -> 25 remainder
|
||||
// 50 armour 100 dmg -> 0 remainder
|
||||
let remainder = self.armour.base.saturating_sub(modified_phys_dmg);
|
||||
let mitigation = modified_phys_dmg.saturating_sub(remainder);
|
||||
// eg 50 armour 25 dmg -> 0 remainder 25 mitigation
|
||||
// 50 armour 100 dmg -> 50 remainder 50 mitigation
|
||||
// 50 armour 5 dmg -> 0 remainder 5 mitigation
|
||||
let remainder = modified_dmg.saturating_sub(self.armour.base);
|
||||
let mitigation = modified_dmg.saturating_sub(remainder);
|
||||
|
||||
// reduce armour by damage amount
|
||||
self.armour.reduce(modified_phys_dmg);
|
||||
// reduce armour by mitigation amount
|
||||
self.armour.reduce(mitigation);
|
||||
|
||||
// deal remainder to hp
|
||||
self.hp.reduce(remainder);
|
||||
|
||||
return ResolutionResult::Damage {
|
||||
amount: modified_phys_dmg,
|
||||
amount: modified_dmg,
|
||||
mitigation,
|
||||
category: Category::PhysDmg,
|
||||
immunity,
|
||||
@ -488,22 +488,15 @@ impl Cryp {
|
||||
|
||||
// println!("{:?}", spell_dmg_mods);
|
||||
|
||||
let modified_spell_dmg = spell_dmg_mods.iter().fold(amount, |acc, m| m.apply(acc));
|
||||
let modified_dmg = spell_dmg_mods.iter().fold(amount, |acc, m| m.apply(acc));
|
||||
let remainder = modified_dmg.saturating_sub(self.armour.base);
|
||||
let mitigation = modified_dmg.saturating_sub(remainder);
|
||||
|
||||
// calculate amount of damage armour will not absorb
|
||||
// eg 50 armour 25 dmg -> 25 remainder
|
||||
// 50 armour 100 dmg -> 0 remainder
|
||||
let remainder = self.spell_shield.base.saturating_sub(modified_spell_dmg);
|
||||
let mitigation = modified_spell_dmg.saturating_sub(remainder);
|
||||
|
||||
// reduce armour by damage amount
|
||||
self.armour.reduce(modified_spell_dmg);
|
||||
|
||||
// deal remainder to hp
|
||||
self.armour.reduce(mitigation);
|
||||
self.hp.reduce(remainder);
|
||||
|
||||
return ResolutionResult::Damage {
|
||||
amount: modified_spell_dmg,
|
||||
amount: modified_dmg,
|
||||
mitigation,
|
||||
category: Category::SpellDmg,
|
||||
immunity,
|
||||
|
||||
@ -994,6 +994,10 @@ mod tests {
|
||||
game.team_by_id(y_team.id).cryp_by_id(y_cryp.id).unwrap().phys_dmg.set(u64::max_value());
|
||||
game.team_by_id(y_team.id).cryp_by_id(y_cryp.id).unwrap().speed.set(u64::max_value());
|
||||
|
||||
// just in case
|
||||
// remove all mitigation
|
||||
game.team_by_id(x_team.id).cryp_by_id(x_cryp.id).unwrap().armour.set(0);
|
||||
|
||||
let _x_stun_id = game.add_skill(x_team.id, x_cryp.id, Some(y_cryp.id), Skill::TestStun).unwrap();
|
||||
game.add_skill(y_team.id, y_cryp.id, Some(x_cryp.id), Skill::Attack).unwrap();
|
||||
|
||||
|
||||
@ -947,7 +947,7 @@ fn drain_tick(cryp: &mut Cryp, target: &mut Cryp, mut resolution: Resolution) ->
|
||||
resolution.results.push(drain_dmg.clone());
|
||||
|
||||
match drain_dmg {
|
||||
ResolutionResult::Damage { amount, category: _, immunity } => {
|
||||
ResolutionResult::Damage { amount, mitigation, category: _, immunity } => {
|
||||
if !immunity.immune {
|
||||
resolution.results.push(cryp.heal(Skill::Heal, amount));
|
||||
}
|
||||
@ -1076,7 +1076,7 @@ mod tests {
|
||||
let res = attack(&mut x, &mut y, Resolution::new(Skill::Attack));
|
||||
|
||||
match res.results[0] {
|
||||
ResolutionResult::Damage { amount, category: _, immunity: _ } => assert_eq!(amount, 50),
|
||||
ResolutionResult::Damage { amount, mitigation: _, category: _, immunity: _ } => assert_eq!(amount, 50),
|
||||
_ => panic!("not damage"),
|
||||
};
|
||||
}
|
||||
@ -1095,6 +1095,11 @@ mod tests {
|
||||
|
||||
// ensure it doesn't have 0 sd
|
||||
x.spell_dmg.set(50);
|
||||
|
||||
// remove all mitigation
|
||||
y.armour.set(0);
|
||||
y.spell_shield.set(0);
|
||||
|
||||
y.deal_phys_dmg(Skill::Attack, 5);
|
||||
let prev_hp = y.hp();
|
||||
|
||||
@ -1106,6 +1111,7 @@ mod tests {
|
||||
|
||||
let res = Resolution::new(Skill::TriageTick);
|
||||
triage_tick(&mut x, &mut y, res);
|
||||
|
||||
assert!(y.hp() > prev_hp);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user