Fix HP and other derivated values not computed anymore
All checks were successful
Release Creation / build (release) Successful in 2m57s
All checks were successful
Release Creation / build (release) Successful in 2m57s
This commit is contained in:
@@ -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
|
||||
|
@@ -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: `<p>${game.i18n.format("CTHULHUETERNAL.Label.breakingPointReached", { bp: this.san.breakingPoint, san: this.san.value })}</p>`,
|
||||
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: `<p>${game.i18n.format("CTHULHUETERNAL.Label.breakingPointReached", { bp: this.san.breakingPoint, san: this.san.value })}</p>`,
|
||||
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: `<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 })
|
||||
})
|
||||
return null
|
||||
}
|
||||
if (this.hp.unconscious ) {
|
||||
if (this.hp.unconscious) {
|
||||
// Warn with chat message
|
||||
ChatMessage.create({
|
||||
content: `<p>${game.i18n.localize("CTHULHUETERNAL.Label.unconsciousWarning")}</p>`,
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user