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();
},
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'));
break;
case 'accessory':
window.saga.updateCharAccessory(
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'),
});
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, {