Fix HP and other derivated values not computed anymore
All checks were successful
Release Creation / build (release) Successful in 2m57s

This commit is contained in:
2025-08-10 19:33:28 +02:00
parent 4edbc9b618
commit 264a5c7a4c
8 changed files with 31 additions and 28 deletions

View File

@@ -109,7 +109,7 @@ export default class CthulhuEternalProtagonistSheet extends CthulhuEternalActorS
); );
// Merge skillsColumns in a single flat array // Merge skillsColumns in a single flat array
skillsColumns = skillsColumns.flat().filter(Boolean); skillsColumns = skillsColumns.flat().filter(Boolean);
console.log("Skills columns:", skillsColumns); //DEBUG : console.log("Skills columns:", skillsColumns);
context.skills = skillsColumns context.skills = skillsColumns
} }
break break

View File

@@ -90,7 +90,7 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
prepareDerivedData() { prepareDerivedData() {
super.prepareDerivedData(); super.prepareDerivedData();
if (!game.user.isGM ) { if (!game.user.isGM) {
return return
} }
@@ -140,13 +140,16 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
if (!this.san.breakingPointReached && this.san.value <= this.san.breakingPoint) { if (!this.san.breakingPointReached && this.san.value <= this.san.breakingPoint) {
updates[`system.san.breakingPointReached`] = true updates[`system.san.breakingPointReached`] = true
this.san.breakingPointReached = true // Force local update to true this.san.breakingPointReached = true // Force local update to true
let w = game.users.find(u => u.character?.name === this.parent?.name)
if (w) {
ChatMessage.create({ ChatMessage.create({
content: `<p>${game.i18n.format("CTHULHUETERNAL.Label.breakingPointReached", { bp: this.san.breakingPoint, san: this.san.value })}</p>`, content: `<p>${game.i18n.format("CTHULHUETERNAL.Label.breakingPointReached", { bp: this.san.breakingPoint, san: this.san.value })}</p>`,
speaker: ChatMessage.getSpeaker({ actor: this.parent }), speaker: ChatMessage.getSpeaker({ actor: this.parent }),
// Get the user id of the actor owner // Get the user id of the actor owner
whisper: [game.users.find(u => u.character?.name === this.parent?.name).id ] whisper: [w.id]
}) })
} }
}
// Unconsciousness management // Unconsciousness management
if (!this.hp.unconscious && this.hp.value <= 2) { if (!this.hp.unconscious && this.hp.value <= 2) {
@@ -207,7 +210,7 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
actorName: this.parent.name, actorName: this.parent.name,
adaptedToHelplessness: this.biodata.adaptedToHelplessness, adaptedToHelplessness: this.biodata.adaptedToHelplessness,
adaptedToViolence: this.biodata.adaptedToViolence, adaptedToViolence: this.biodata.adaptedToViolence,
... rollData ...rollData
} }
let updates = {} let updates = {}
let template = "" let template = ""
@@ -236,7 +239,7 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
} }
template = "systems/fvtt-cthulhu-eternal/templates/chat-san-loss-0.hbs" 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 // Set the first false element of the violence array to true
let violence = this.san.violence.slice() let violence = this.san.violence.slice()
let index = violence.findIndex(v => !v) 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] updates[`system.san.violence`] = [false, false, false]
msgData.adaptedToViolence = true 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 // 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 helplessness = this.san.helplessness.slice()
let index = helplessness.findIndex(h => !h) 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] updates[`system.san.helplessness`] = [false, false, false]
msgData.adaptedToHelplessness = true msgData.adaptedToHelplessness = true
} }
} else if (rollData.sanType === "unnatural" ) { } else if (rollData.sanType === "unnatural") {
template = "systems/fvtt-cthulhu-eternal/templates/chat-san-loss-unnatural.hbs" template = "systems/fvtt-cthulhu-eternal/templates/chat-san-loss-unnatural.hbs"
} else { } else {
template = "systems/fvtt-cthulhu-eternal/templates/chat-san-loss-none.hbs" 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) { async roll(rollType, rollItem) {
if (this.hp.dead ) { if (this.hp.dead) {
// Warn with chat message // Warn with chat message
ChatMessage.create({ ChatMessage.create({
content: `<p>${game.i18n.format("CTHULHUETERNAL.Label.deadWarning", {con: this.characteristics.con.value} )}</p>`, content: `<p>${game.i18n.format("CTHULHUETERNAL.Label.deadWarning", { con: this.characteristics.con.value })}</p>`,
speaker: ChatMessage.getSpeaker({ actor: this.parent }) speaker: ChatMessage.getSpeaker({ actor: this.parent })
}) })
return null return null
} }
if (this.hp.unconscious ) { if (this.hp.unconscious) {
// Warn with chat message // Warn with chat message
ChatMessage.create({ ChatMessage.create({
content: `<p>${game.i18n.localize("CTHULHUETERNAL.Label.unconsciousWarning")}</p>`, content: `<p>${game.i18n.localize("CTHULHUETERNAL.Label.unconsciousWarning")}</p>`,

Binary file not shown.

Binary file not shown.

Binary file not shown.