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

@@ -99,19 +99,19 @@ export default class CthulhuEternalProtagonistSheet extends CthulhuEternalActorS
case "main": case "main":
break break
case "skills": { case "skills": {
context.tab = context.tabs.skills context.tab = context.tabs.skills
let tmpSkills = doc.itemTypes.skill let tmpSkills = doc.itemTypes.skill
tmpSkills.sort((a, b) => a.name.localeCompare(b.name)) tmpSkills.sort((a, b) => a.name.localeCompare(b.name))
const nbCols = 3; const nbCols = 3;
const nbRows = Math.ceil(tmpSkills.length / nbCols); const nbRows = Math.ceil(tmpSkills.length / nbCols);
let skillsColumns = Array.from({ length: nbRows }, (_, rowIdx) => let skillsColumns = Array.from({ length: nbRows }, (_, rowIdx) =>
Array.from({ length: nbCols }, (_, colIdx) => tmpSkills[rowIdx + colIdx * nbRows]).filter(Boolean) Array.from({ length: nbCols }, (_, colIdx) => tmpSkills[rowIdx + colIdx * nbRows]).filter(Boolean)
); );
// 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
case "equipment": case "equipment":
context.tab = context.tabs.equipment context.tab = context.tabs.equipment

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,12 +140,15 @@ 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
ChatMessage.create({ let w = game.users.find(u => u.character?.name === this.parent?.name)
content: `<p>${game.i18n.format("CTHULHUETERNAL.Label.breakingPointReached", { bp: this.san.breakingPoint, san: this.san.value })}</p>`, if (w) {
speaker: ChatMessage.getSpeaker({ actor: this.parent }), ChatMessage.create({
// Get the user id of the actor owner content: `<p>${game.i18n.format("CTHULHUETERNAL.Label.breakingPointReached", { bp: this.san.breakingPoint, san: this.san.value })}</p>`,
whisper: [game.users.find(u => u.character?.name === this.parent?.name).id ] speaker: ChatMessage.getSpeaker({ actor: this.parent }),
}) // Get the user id of the actor owner
whisper: [w.id]
})
}
} }
// Unconsciousness management // Unconsciousness management
@@ -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 = ""
@@ -224,7 +227,7 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
} }
template = "systems/fvtt-cthulhu-eternal/templates/chat-san-temp-insanity.hbs" 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 rollData.resetMsg = false
if (rollData.sanType === "violence" && !this.biodata.adaptedToViolence) { if (rollData.sanType === "violence" && !this.biodata.adaptedToViolence) {
updates[`system.san.violence`] = [false, false, false] 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" 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.