spell dmg

This commit is contained in:
ntr 2019-01-11 17:06:51 +11:00
parent 13bba0200b
commit 720b70097b

View File

@ -433,6 +433,7 @@ impl Cryp {
if immune { if immune {
return ResolutionResult::Damage { return ResolutionResult::Damage {
amount: 0, amount: 0,
mitigation: 0,
category: Category::PhysDmg, category: Category::PhysDmg,
immunity, immunity,
}; };
@ -474,6 +475,7 @@ impl Cryp {
if immune { if immune {
return ResolutionResult::Damage { return ResolutionResult::Damage {
amount: 0, amount: 0,
mitigation: 0,
category: Category::SpellDmg, category: Category::SpellDmg,
immunity, immunity,
}; };
@ -488,17 +490,21 @@ impl Cryp {
let modified_spell_dmg = spell_dmg_mods.iter().fold(amount, |acc, m| m.apply(acc)); let modified_spell_dmg = spell_dmg_mods.iter().fold(amount, |acc, m| m.apply(acc));
// reduce spell_shield by damage amount // calculate amount of damage armour will not absorb
self.spell_shield.reduce(modified_spell_dmg); // 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 amount by the amount absorbed by spell_shield // reduce armour by damage amount
let remainder = amount.saturating_sub(modified_spell_dmg); self.armour.reduce(modified_spell_dmg);
// deal remainder to hp // deal remainder to hp
self.hp.reduce(remainder); self.hp.reduce(remainder);
return ResolutionResult::Damage { return ResolutionResult::Damage {
amount: modified_spell_dmg, amount: modified_spell_dmg,
mitigation,
category: Category::SpellDmg, category: Category::SpellDmg,
immunity, immunity,
}; };