@@ -3,6 +3,8 @@ import { calculateCombatResult } from '../../combat/utils/calculateCombatResult'
33import { ABFSettingsKeys } from '../../../utils/registerSettings' ;
44import { executeMacro } from '../../utils/functions/executeMacro' ;
55import ABFFoundryRoll from '../../rolls/ABFFoundryRoll.js' ;
6+ import { ABFSupernaturalShieldData } from '../../combat/ABFSupernaturalShieldData' ;
7+ import { shieldValueCheck } from '../../combat/utils/shieldValueCheck.js' ;
68
79const getInitialData = ( attacker , defender , options = { } ) => {
810 const attackerActor = attacker . actor ;
@@ -385,19 +387,21 @@ export class GMCombatDialog extends FormApplication {
385387
386388 async newSupernaturalShieldIfBeAble ( ) {
387389 const { supShield } = this . modalData . defender . result ?. values ;
388- if (
389- ( this . modalData . defender . result ?. type === 'mystic' ||
390- this . modalData . defender . result ?. type === 'psychic' ) &&
391- supShield . create
392- ) {
393- const supShieldId = await this . defenderActor . newSupernaturalShield (
394- this . modalData . defender . result . type ,
395- this . modalData . defender . result ?. power ?? { } ,
396- this . modalData . defender . result . values ?. psychicPotential ?? 0 ,
397- this . modalData . defender . result . spell ?? { } ,
398- this . modalData . defender . result . values ?. spellGrade
399- ) ;
400- return supShieldId ;
390+ const result = this . modalData . defender . result ;
391+
392+ if ( ( result ?. type === 'mystic' || result ?. type === 'psychic' ) && supShield . create ) {
393+ const shieldPoints = Number ( result . values ?. supShield ?. shieldPoints ?? 0 ) ;
394+
395+ const abilityFormula =
396+ result . type === 'psychic' ? 'TU_FORMULA_PSIQUICA' : 'TU_FORMULA_MAGICA' ;
397+
398+ const shieldData = ABFSupernaturalShieldData . builder ( )
399+ . name ( result . type === 'psychic' ? result ?. power ?. name : result ?. spell ?. name )
400+ . shieldPoints ( shieldPoints )
401+ . abilityFormula ( abilityFormula )
402+ . build ( ) ;
403+
404+ return await this . defenderActor . newSupernaturalShield ( shieldData ) ;
401405 }
402406 }
403407
@@ -427,10 +431,7 @@ export class GMCombatDialog extends FormApplication {
427431 attacker . result . values . total + this . modalData . attacker . customModifier ,
428432 0
429433 ) ;
430- newCombatResult . at = Math . max (
431- defender . result . values . at - reducedArmor ,
432- 0
433- ) ;
434+ newCombatResult . at = Math . max ( defender . result . values . at - reducedArmor , 0 ) ;
434435 newCombatResult . halvedAbsorption =
435436 defender . result . type === 'resistance'
436437 ? defender . result . values . surprised
@@ -492,9 +493,7 @@ export class GMCombatDialog extends FormApplication {
492493
493494 if ( attacker . result ?. type === 'combat' ) {
494495 const weaponName =
495- attacker . result . values ?. weaponName ||
496- attacker . result . weapon ?. name ||
497- 'Unarmed' ;
496+ attacker . result . values ?. weaponName || attacker . result . weapon ?. name || 'Unarmed' ;
498497 const { name } = { name : weaponName } ;
499498 macroName = macroPrefixAttack + name ;
500499 } else if ( attacker . result ?. type === 'mystic' ) {
0 commit comments