Fix dépense rêve sort

La dépense de rêve de sort se faisait en parallèle de la fermeture
de fenêtre des TMRs, qui modifiait la fatigue. Du coup, l'update de
la dépense de rêve ne se faisait pas
This commit is contained in:
2025-11-27 01:02:09 +01:00
parent 764f9f81c8
commit acd40f3154
3 changed files with 22 additions and 17 deletions

View File

@@ -1,3 +1,4 @@
import { RollBasicParts } from "../roll/roll-basic-parts.mjs"
const ACTOR_EMBEDDED_DOCTYPES = ['Item', 'ActiveEffect']
/**
@@ -62,14 +63,16 @@ export class ActorImpacts {
addDelta(document, path, value) {
ActorImpacts.$checkDocType(document)
const intValue = Number.parseInt(value)
if (Number.isInteger(intValue) && intValue != 0) {
const delta = [path, intValue]
const existing = this[docType].updates.find(it => it.id == document.id)
if (existing) {
existing.deltas.push(delta)
}
else {
this[docType].updates.push({ id: document.id, updates: [], deltas: [delta] })
if (Number.isInteger(intValue)) {
if (intValue != 0){
const delta = [path, intValue]
const existing = this[docType].updates.find(it => it.id == document.id)
if (existing) {
existing.deltas.push(delta)
}
else {
this[docType].updates.push({ id: document.id, updates: [], deltas: [delta] })
}
}
}
else {
@@ -96,7 +99,9 @@ export class ActorImpacts {
async applyImpacts() {
const actor = this.actorToken.actor
await Promise.all(ACTOR_EMBEDDED_DOCTYPES.map(async docType => await this.$applyDocumentsImpacts(actor, docType)))
for (let docType of ACTOR_EMBEDDED_DOCTYPES) {
await this.$applyDocumentsImpacts(actor, docType)
}
const updates = ActorImpacts.$computeUpdates(this, id => actor)
await actor.update(updates, { render: true })
}
@@ -122,8 +127,8 @@ export class ActorImpacts {
}
}
findCreatedId(docType, origId){
return this[docType].creates.find(it => it.id = origId)?.createdId
findCreatedId(docType, origId) {
return this[docType].creates.find(it => it.id = origId)?.createdId
}
$getEmbeddedDocument(docType, id) {