From 264a5c7a4c15266beb6900de1b98e28758b6d87b Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Sun, 10 Aug 2025 19:33:28 +0200 Subject: [PATCH] Fix HP and other derivated values not computed anymore --- .../applications/sheets/protagonist-sheet.mjs | 26 +++++++------- module/models/protagonist.mjs | 33 ++++++++++-------- .../rituals/{000232.log => 000236.log} | 0 packs-system/rituals/MANIFEST-000230 | Bin 174 -> 0 bytes .../skills/{000401.log => 000405.log} | 0 packs-system/skills/MANIFEST-000399 | Bin 178 -> 0 bytes .../weapons/{000047.log => 000051.log} | 0 packs-system/weapons/MANIFEST-000045 | Bin 173 -> 0 bytes 8 files changed, 31 insertions(+), 28 deletions(-) rename packs-system/rituals/{000232.log => 000236.log} (100%) delete mode 100644 packs-system/rituals/MANIFEST-000230 rename packs-system/skills/{000401.log => 000405.log} (100%) delete mode 100644 packs-system/skills/MANIFEST-000399 rename packs-system/weapons/{000047.log => 000051.log} (100%) delete mode 100644 packs-system/weapons/MANIFEST-000045 diff --git a/module/applications/sheets/protagonist-sheet.mjs b/module/applications/sheets/protagonist-sheet.mjs index 284589b..a3b4363 100644 --- a/module/applications/sheets/protagonist-sheet.mjs +++ b/module/applications/sheets/protagonist-sheet.mjs @@ -99,19 +99,19 @@ export default class CthulhuEternalProtagonistSheet extends CthulhuEternalActorS case "main": break case "skills": { - context.tab = context.tabs.skills - let tmpSkills = doc.itemTypes.skill - tmpSkills.sort((a, b) => a.name.localeCompare(b.name)) - const nbCols = 3; - const nbRows = Math.ceil(tmpSkills.length / nbCols); - let skillsColumns = Array.from({ length: nbRows }, (_, rowIdx) => - Array.from({ length: nbCols }, (_, colIdx) => tmpSkills[rowIdx + colIdx * nbRows]).filter(Boolean) - ); - // Merge skillsColumns in a single flat array - skillsColumns = skillsColumns.flat().filter(Boolean); - console.log("Skills columns:", skillsColumns); - context.skills = skillsColumns - } + context.tab = context.tabs.skills + let tmpSkills = doc.itemTypes.skill + tmpSkills.sort((a, b) => a.name.localeCompare(b.name)) + const nbCols = 3; + const nbRows = Math.ceil(tmpSkills.length / nbCols); + let skillsColumns = Array.from({ length: nbRows }, (_, rowIdx) => + Array.from({ length: nbCols }, (_, colIdx) => tmpSkills[rowIdx + colIdx * nbRows]).filter(Boolean) + ); + // Merge skillsColumns in a single flat array + skillsColumns = skillsColumns.flat().filter(Boolean); + //DEBUG : console.log("Skills columns:", skillsColumns); + context.skills = skillsColumns + } break case "equipment": context.tab = context.tabs.equipment diff --git a/module/models/protagonist.mjs b/module/models/protagonist.mjs index 3be2484..c386315 100644 --- a/module/models/protagonist.mjs +++ b/module/models/protagonist.mjs @@ -90,7 +90,7 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData prepareDerivedData() { super.prepareDerivedData(); - if (!game.user.isGM ) { + if (!game.user.isGM) { return } @@ -140,12 +140,15 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData if (!this.san.breakingPointReached && this.san.value <= this.san.breakingPoint) { updates[`system.san.breakingPointReached`] = true this.san.breakingPointReached = true // Force local update to true - ChatMessage.create({ - content: `

${game.i18n.format("CTHULHUETERNAL.Label.breakingPointReached", { bp: this.san.breakingPoint, san: this.san.value })}

`, - speaker: ChatMessage.getSpeaker({ actor: this.parent }), - // Get the user id of the actor owner - whisper: [game.users.find(u => u.character?.name === this.parent?.name).id ] - }) + let w = game.users.find(u => u.character?.name === this.parent?.name) + if (w) { + ChatMessage.create({ + content: `

${game.i18n.format("CTHULHUETERNAL.Label.breakingPointReached", { bp: this.san.breakingPoint, san: this.san.value })}

`, + speaker: ChatMessage.getSpeaker({ actor: this.parent }), + // Get the user id of the actor owner + whisper: [w.id] + }) + } } // Unconsciousness management @@ -207,7 +210,7 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData actorName: this.parent.name, adaptedToHelplessness: this.biodata.adaptedToHelplessness, adaptedToViolence: this.biodata.adaptedToViolence, - ... rollData + ...rollData } let updates = {} let template = "" @@ -224,7 +227,7 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData } template = "systems/fvtt-cthulhu-eternal/templates/chat-san-temp-insanity.hbs" - } else if (rollData.sanLoss === 0) { // Manage if sanLoss is 0 + } else if (rollData.sanLoss === 0) { // Manage if sanLoss is 0 rollData.resetMsg = false if (rollData.sanType === "violence" && !this.biodata.adaptedToViolence) { updates[`system.san.violence`] = [false, false, false] @@ -236,7 +239,7 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData } template = "systems/fvtt-cthulhu-eternal/templates/chat-san-loss-0.hbs" - } else if (rollData.sanType === "violence" ) { + } else if (rollData.sanType === "violence") { // Set the first false element of the violence array to true let violence = this.san.violence.slice() let index = violence.findIndex(v => !v) @@ -251,7 +254,7 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData updates[`system.san.violence`] = [false, false, false] msgData.adaptedToViolence = true } - } else if (rollData.sanType === "helplessness" ) { + } else if (rollData.sanType === "helplessness") { // If sanType is "helplessness" and adapted to helplessness, set the first false element of the helplessness array to true let helplessness = this.san.helplessness.slice() let index = helplessness.findIndex(h => !h) @@ -266,7 +269,7 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData updates[`system.san.helplessness`] = [false, false, false] msgData.adaptedToHelplessness = true } - } else if (rollData.sanType === "unnatural" ) { + } else if (rollData.sanType === "unnatural") { template = "systems/fvtt-cthulhu-eternal/templates/chat-san-loss-unnatural.hbs" } else { template = "systems/fvtt-cthulhu-eternal/templates/chat-san-loss-none.hbs" @@ -354,15 +357,15 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData */ async roll(rollType, rollItem) { - if (this.hp.dead ) { + if (this.hp.dead) { // Warn with chat message ChatMessage.create({ - content: `

${game.i18n.format("CTHULHUETERNAL.Label.deadWarning", {con: this.characteristics.con.value} )}

`, + content: `

${game.i18n.format("CTHULHUETERNAL.Label.deadWarning", { con: this.characteristics.con.value })}

`, speaker: ChatMessage.getSpeaker({ actor: this.parent }) }) return null } - if (this.hp.unconscious ) { + if (this.hp.unconscious) { // Warn with chat message ChatMessage.create({ content: `

${game.i18n.localize("CTHULHUETERNAL.Label.unconsciousWarning")}

`, diff --git a/packs-system/rituals/000232.log b/packs-system/rituals/000236.log similarity index 100% rename from packs-system/rituals/000232.log rename to packs-system/rituals/000236.log diff --git a/packs-system/rituals/MANIFEST-000230 b/packs-system/rituals/MANIFEST-000230 deleted file mode 100644 index cd95023dae1a658f569d25ab720db9178c70cd59..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 174 zcmYd&UXb0&z{n_-lUkOVlai$8R9TW*o>`pgoS$2eSd>_jU&P8Fub5eqnp><`73P*! zV4QE@ZV;7j?3rl7Xu<#n?2Jztm)v27DKp8h31bj~R93Sg9mD1*u4GA3K< fsV)}-Bhzz6P6p-|j4UR>v;KvH1YUpyUI7IFx0Wv? diff --git a/packs-system/skills/000401.log b/packs-system/skills/000405.log similarity index 100% rename from packs-system/skills/000401.log rename to packs-system/skills/000405.log diff --git a/packs-system/skills/MANIFEST-000399 b/packs-system/skills/MANIFEST-000399 deleted file mode 100644 index a77a3efcc808406ade2bb5f6e96439ce307ad9e7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 178 zcmexa)|KDRz{n_-lUkOVlai$8R9TW*o>`pgoS$2eSd>_jU&P8Fub5eqnp><`RhA#> zR9O`s93Ew1o>t+=$jHh70_==^%qNcvD=Mbt=cJ?-6)Tzs6ops@=K2{Xy9HFaxCJn_ oF@Y5lGN?UxZWT8JBhv(CP6pz{n_-lUkOVlai$8R9TW*o>`pgoS$2eSd>_jU&P8Fub5eqnp><`RaxO^ z>5}1ZY*u3G@8nX(XwCoz?2I}yZnG*Xrse0Pq!tw`8n}2GhZtp*r5fiI=N6|$F)oCt jBV-PrT)#di10$0jCj+xS%U$MJrYSQ(e4rq+A&?IMCv7ao