diff --git a/modules/donjon-et-cie-actor.mjs b/modules/donjon-et-cie-actor.mjs index 35c3902..7b48475 100644 --- a/modules/donjon-et-cie-actor.mjs +++ b/modules/donjon-et-cie-actor.mjs @@ -29,6 +29,19 @@ export class DonjonEtCieActor extends Actor { } } + async _preUpdate(changed, options, user) { + if ( + foundry.utils.hasProperty(changed, "system.magie.focus.delta") + && !foundry.utils.hasProperty(changed, "system.magie.focus.resultat") + && !foundry.utils.hasProperty(changed, "system.magie.focus.sceneId") + ) { + foundry.utils.setProperty(changed, "system.magie.focus.resultat", 0); + foundry.utils.setProperty(changed, "system.magie.focus.sceneId", ""); + } + + return super._preUpdate(changed, options, user); + } + getCharacteristicEntries() { return DonjonEtCieUtility.getCharacteristicEntries(this.system); } diff --git a/modules/donjon-et-cie-rolls.mjs b/modules/donjon-et-cie-rolls.mjs index 994f269..ee72673 100644 --- a/modules/donjon-et-cie-rolls.mjs +++ b/modules/donjon-et-cie-rolls.mjs @@ -393,6 +393,7 @@ export class DonjonEtCieRolls { static async rollSpell(actor, item, { mode = "normal", favorKey = "" } = {}) { const characteristicKey = item.system.caracteristique || "intelligence"; const focus = await this.#ensureFocus(actor); + const currentSceneId = DonjonEtCieUtility.getCurrentSceneId(); const rank = Number(actor.system.anciennete?.rang ?? actor.system.sante?.dv ?? 0); const cost = Number(item.system.coutPv ?? 0); const autoDisadvantage = cost > rank; @@ -403,8 +404,13 @@ export class DonjonEtCieRolls { if (!result) return null; - const currentPv = Number(actor.system.sante?.pv?.value ?? 0); - const availableMagicHp = currentPv + focus.activeValue; + const liveActor = game.actors.get(actor.id) ?? actor; + const currentPv = Number(liveActor.system.sante?.pv?.value ?? 0); + const currentFocusSceneId = liveActor.system.magie?.focus?.sceneId ?? ""; + const currentFocusValue = currentFocusSceneId === currentSceneId + ? Number(liveActor.system.magie?.focus?.resultat ?? 0) + : 0; + const availableMagicHp = currentPv + currentFocusValue; if (cost > availableMagicHp) { ui.notifications.warn(game.i18n.localize("DNC.Warn.SpellInsufficientResources")); @@ -413,8 +419,8 @@ export class DonjonEtCieRolls { const characteristicShort = DONJON_ET_CIE.characteristics[characteristicKey]?.short ?? characteristicKey; const success = result.isNaturalTwenty ? false : result.success; - const focusSpent = result.isNaturalOne ? 0 : Math.min(cost, focus.activeValue); - const focusRemaining = Math.max(focus.activeValue - focusSpent, 0); + const focusSpent = result.isNaturalOne ? 0 : Math.min(cost, currentFocusValue); + const focusRemaining = Math.max(currentFocusValue - focusSpent, 0); const spentPv = result.isNaturalOne ? 0 : Math.max(cost - focusSpent, 0); const remainingPv = Math.max(currentPv - spentPv, 0); const updateData = {}; diff --git a/packs/system-help/000040.log b/packs/system-help/000004.log similarity index 100% rename from packs/system-help/000040.log rename to packs/system-help/000004.log diff --git a/packs/system-help/000005.ldb b/packs/system-help/000005.ldb new file mode 100644 index 0000000..9911048 Binary files /dev/null and b/packs/system-help/000005.ldb differ diff --git a/packs/system-help/LOG b/packs/system-help/LOG index bedbd32..77b6b27 100644 --- a/packs/system-help/LOG +++ b/packs/system-help/LOG @@ -1,5 +1,5 @@ -2026/05/03-21:49:37.907525 7f8d8a3ff6c0 Delete type=3 #1 -2026/05/03-21:49:37.915375 7f8d6bfff6c0 Level-0 table #5: started -2026/05/03-21:49:37.919396 7f8d6bfff6c0 Level-0 table #5: 3056 bytes OK -2026/05/03-21:49:37.925768 7f8d6bfff6c0 Delete type=0 #3 -2026/05/03-21:49:37.926041 7f8d6bfff6c0 Manual compaction at level-0 from '!journal!69Da9YvF9BfOV7oK' @ 72057594037927935 : 1 .. '!journal.pages!69Da9YvF9BfOV7oK.XM0eLkgKXPyskV65' @ 0 : 0; will stop at (end) +2026/05/07-00:10:15.348093 7f00437ef6c0 Delete type=3 #1 +2026/05/07-00:10:15.351196 7f00417eb6c0 Level-0 table #5: started +2026/05/07-00:10:15.354504 7f00417eb6c0 Level-0 table #5: 3056 bytes OK +2026/05/07-00:10:15.361308 7f00417eb6c0 Delete type=0 #3 +2026/05/07-00:10:15.361446 7f00417eb6c0 Manual compaction at level-0 from '!journal!69Da9YvF9BfOV7oK' @ 72057594037927935 : 1 .. '!journal.pages!69Da9YvF9BfOV7oK.XM0eLkgKXPyskV65' @ 0 : 0; will stop at (end) diff --git a/packs/system-help/MANIFEST-000002 b/packs/system-help/MANIFEST-000002 new file mode 100644 index 0000000..6c12011 Binary files /dev/null and b/packs/system-help/MANIFEST-000002 differ