From 52d6cf3a9e50fde60ad2ad444c5cb27a0b471298 Mon Sep 17 00:00:00 2001 From: tmont Date: Tue, 16 Mar 2021 10:35:53 -0700 Subject: [PATCH] account for armor resistance in enemy magic attacks --- web/static/saga.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/web/static/saga.js b/web/static/saga.js index 19d1eda..6f6e46b 100644 --- a/web/static/saga.js +++ b/web/static/saga.js @@ -188,10 +188,11 @@ }; onCharStatChange(); }, - updateCharArmor: (name, defense) => { + updateCharArmor: (name, defense, resistance) => { charStats.armor = { name, defense, + resistance, }; onCharStatChange(); }, @@ -295,20 +296,22 @@ window.saga.updateCharWeapon(value, attrToNum('power')); break; case 'armor': - window.saga.updateCharArmor(value, attrToNum('defense')); + window.saga.updateCharArmor(value, attrToNum('defense'), { + fire: attrToNum('res-fire'), + ice: attrToNum('res-ice'), + thunder: attrToNum('res-thunder'), + vacuum: attrToNum('res-vacuum'), + debuff: attrToNum('res-debuff'), + }); break; case 'accessory': - window.saga.updateCharAccessory( - value, - attrToNum('defense'), - { - fire: attrToNum('res-fire'), - ice: attrToNum('res-ice'), - thunder: attrToNum('res-thunder'), - vacuum: attrToNum('res-vacuum'), - debuff: attrToNum('res-debuff'), - }, - ); + window.saga.updateCharAccessory(value, attrToNum('defense'), { + fire: attrToNum('res-fire'), + ice: attrToNum('res-ice'), + thunder: attrToNum('res-thunder'), + vacuum: attrToNum('res-vacuum'), + debuff: attrToNum('res-debuff'), + }); break; } }); @@ -510,7 +513,7 @@ window.saga.spells.filter(x => !!x.power && rowData.spells.includes(x.name)).forEach((spell) => { const elementalRes = 0; - const resArmor = 0; + const resArmor = charStats.armor ? charStats.armor.resistance[spell.element.toLowerCase()] : 0; const resAccessory = charStats.accessory ? charStats.accessory.resistance[spell.element.toLowerCase()] : 0; let def = calc.magicalAttack(enemyMagic, charMagic, elementalRes, resArmor, resAccessory, spell.power); let magicUp = calc.magicalAttack(enemyMagic, charMagic, elementalRes, resArmor, resAccessory, spell.power, {