From 18a69ba993b0e8efe3baa9448262fc02a2b0d972 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Wed, 28 Sep 2022 20:14:24 +0200 Subject: [PATCH] Fix #70 : effect OK for dmr roll --- modules/pegasus-actor.js | 13 +++++++------ modules/pegasus-roll-dialog.js | 2 +- modules/pegasus-utility.js | 5 ++++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/pegasus-actor.js b/modules/pegasus-actor.js index ddacdff..5f43694 100644 --- a/modules/pegasus-actor.js +++ b/modules/pegasus-actor.js @@ -373,7 +373,7 @@ export class PegasusActor extends Actor { } } if (ppp != this.system.ppp.spentPPP) { - //this.update({ 'system.ppp.spentPPP': ppp }) + this.update({ 'system.ppp.spentPPP': ppp }) } } /* -------------------------------------------- */ @@ -385,7 +385,7 @@ export class PegasusActor extends Actor { } } if (sizeBonus != this.system.biodata.sizebonus) { - //this.update( {'system.biodata.sizebonus': sizeBonus}) + this.update( {'system.biodata.sizebonus': sizeBonus}) } } @@ -1758,24 +1758,25 @@ export class PegasusActor extends Actor { processSizeBonus( rollData) { if ( rollData.defenderTokenId) { let diffSize = rollData.defenderSize - this.system.biodata.sizenum+this.system.biodata.sizebonus + console.log("Diffsize", diffSize) if( rollData.subKey == "melee-atk" || rollData.subKey == "ranged-atk") { if ( diffSize > 0) { - rollData.effectsList.push({ label: "Size Bonus", type: "effect", applied: true, value: diffSize }) + rollData.effectsList.push({ label: "Size Bonus", type: "effect", applied: false, isdynamic: true, value: diffSize }) } } if( rollData.subKey == "dmg-res" ) { if ( diffSize < 0) { - rollData.effectsList.push({ label: "Size Bonus", type: "effect", applied: true, value: Math.abs(diffSize) }) + rollData.effectsList.push({ label: "Size Bonus", type: "effect", applied: false, isdynamic: true, value: Math.abs(diffSize) }) } } if( rollData.subKey == "defence" ) { if ( diffSize > 0) { - rollData.effectsList.push({ label: "Size Bonus", type: "effect", applied: true, value: Math.abs(diffSize) }) + rollData.effectsList.push({ label: "Size Bonus", type: "effect", applied: false, isdynamic: true, value: Math.abs(diffSize) }) } } if( rollData.subKey == "melee-dmg" || rollData.subKey == "ranged-dmg") { if ( diffSize < 0) { - rollData.effectsList.push({ label: "Size Bonus", type: "effect", applied: true, value: diffSize }) + rollData.effectsList.push({ label: "Size Bonus", type: "effect", applied: false, isdynamic: true, value: Math.abs(diffSize) }) } } } diff --git a/modules/pegasus-roll-dialog.js b/modules/pegasus-roll-dialog.js index 41c3088..c0315bb 100644 --- a/modules/pegasus-roll-dialog.js +++ b/modules/pegasus-roll-dialog.js @@ -49,7 +49,7 @@ export class PegasusRollDialog extends Dialog { effect.applied = toggled let level, genre, idVal, key - if (effect.type == 'effect') { + if (effect.type == 'effect' && effect.effect) { let effectData = effect.effect level = effectData.system.effectlevel genre = effectData.system.genre diff --git a/modules/pegasus-utility.js b/modules/pegasus-utility.js index 04df984..dea570b 100644 --- a/modules/pegasus-utility.js +++ b/modules/pegasus-utility.js @@ -144,9 +144,12 @@ export class PegasusUtility { static updateEffectsBonusDice(rollData) { let newDicePool = rollData.dicePool.filter(dice => dice.name != "effect-bonus-dice") for (let effect of rollData.effectsList) { - if (effect && effect.applied && effect.type == "effect" && effect.effect.system.bonusdice) { + if (effect && effect.applied && effect.type == "effect" && effect.effect && effect.effect.system.bonusdice) { newDicePool = newDicePool.concat( this.buildDicePool("effect-bonus-dice", effect.effect.system.effectlevel, 0, effect.effect.name )) } + if (effect && effect.applied && effect.type == "effect" && effect.value && effect.isdynamic) { + newDicePool = newDicePool.concat( this.buildDicePool("effect-bonus-dice", effect.value, 0, effect.name )) + } } rollData.dicePool = newDicePool }