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