account for armor resistance in enemy magic attacks

This commit is contained in:
tmont 2021-03-16 10:35:53 -07:00
parent 8bfce04a04
commit 52d6cf3a9e

View File

@ -188,10 +188,11 @@
}; };
onCharStatChange(); onCharStatChange();
}, },
updateCharArmor: (name, defense) => { updateCharArmor: (name, defense, resistance) => {
charStats.armor = { charStats.armor = {
name, name,
defense, defense,
resistance,
}; };
onCharStatChange(); onCharStatChange();
}, },
@ -295,20 +296,22 @@
window.saga.updateCharWeapon(value, attrToNum('power')); window.saga.updateCharWeapon(value, attrToNum('power'));
break; break;
case 'armor': case 'armor':
window.saga.updateCharArmor(value, attrToNum('defense')); window.saga.updateCharArmor(value, attrToNum('defense'), {
break;
case 'accessory':
window.saga.updateCharAccessory(
value,
attrToNum('defense'),
{
fire: attrToNum('res-fire'), fire: attrToNum('res-fire'),
ice: attrToNum('res-ice'), ice: attrToNum('res-ice'),
thunder: attrToNum('res-thunder'), thunder: attrToNum('res-thunder'),
vacuum: attrToNum('res-vacuum'), vacuum: attrToNum('res-vacuum'),
debuff: attrToNum('res-debuff'), 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'),
});
break; break;
} }
}); });
@ -510,7 +513,7 @@
window.saga.spells.filter(x => !!x.power && rowData.spells.includes(x.name)).forEach((spell) => { window.saga.spells.filter(x => !!x.power && rowData.spells.includes(x.name)).forEach((spell) => {
const elementalRes = 0; 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; const resAccessory = charStats.accessory ? charStats.accessory.resistance[spell.element.toLowerCase()] : 0;
let def = calc.magicalAttack(enemyMagic, charMagic, elementalRes, resArmor, resAccessory, spell.power); let def = calc.magicalAttack(enemyMagic, charMagic, elementalRes, resArmor, resAccessory, spell.power);
let magicUp = calc.magicalAttack(enemyMagic, charMagic, elementalRes, resArmor, resAccessory, spell.power, { let magicUp = calc.magicalAttack(enemyMagic, charMagic, elementalRes, resArmor, resAccessory, spell.power, {