This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 = {};
|
||||
|
||||
Binary file not shown.
@@ -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)
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user