Fix release numbering

This commit is contained in:
2026-06-14 23:25:24 +02:00
parent 709e69fac8
commit e43487b727
35 changed files with 391 additions and 152 deletions
+50 -38
View File
@@ -139,11 +139,19 @@ export default class CthulhuEternalRoll extends Roll {
weapon.system.killRadius = choice.killRadius // Override kill radius
}
let combatants = []
let targets = []
if (game?.combat?.combatants) {
for (let c of game.combat.combatants) {
if (c.actorid !== actor.id) {
combatants.push({ id: c.id, name: c.name })
if (c.actorId !== actor.id) {
targets.push({ id: c.id, name: c.name, actorId: c.actorId, tokenId: c.token?.id })
}
}
}
// Fall back to scene tokens if not in combat
if (targets.length === 0 && canvas?.scene) {
for (let tokenDoc of canvas.scene.tokens) {
if (tokenDoc.actorId !== actor.id) {
targets.push({ name: tokenDoc.name, actorId: tokenDoc.actorId, tokenId: tokenDoc.id })
}
}
}
@@ -162,12 +170,11 @@ export default class CthulhuEternalRoll extends Roll {
isLethal,
ammoUsed: weapon?.ammoUsed || 0,
rollResult: lethalityRoll.total,
combatants: combatants
combatants: targets
}
let flavor = await foundry.applications.handlebars.renderTemplate("systems/fvtt-cthulhu-eternal/templates/chat-lethal-damage.hbs", msgData)
let msg = await ChatMessage.create({
user: game.user.id,
content: flavor,
content: await foundry.applications.handlebars.renderTemplate("systems/fvtt-cthulhu-eternal/templates/chat-lethal-damage.hbs", msgData),
speaker: ChatMessage.getSpeaker({ actor: actor }),
}, { rollMode: options.rollMode, create: true })
await msg.setFlag("fvtt-cthulhu-eternal", "woundData", msgData)
@@ -191,12 +198,11 @@ export default class CthulhuEternalRoll extends Roll {
formula,
ammoUsed: weapon?.ammoUsed || 0,
rollResult: damageRoll.total,
combatants: combatants
combatants: targets
}
let flavor = await foundry.applications.handlebars.renderTemplate("systems/fvtt-cthulhu-eternal/templates/chat-regular-damage.hbs", msgData)
let msg = await ChatMessage.create({
user: game.user.id,
content: flavor,
content: await foundry.applications.handlebars.renderTemplate("systems/fvtt-cthulhu-eternal/templates/chat-regular-damage.hbs", msgData),
speaker: ChatMessage.getSpeaker({ actor: actor }),
}, { rollMode: options.rollMode, create: true })
await msg.setFlag("fvtt-cthulhu-eternal", "woundData", msgData)
@@ -254,7 +260,8 @@ export default class CthulhuEternalRoll extends Roll {
let formula = "1d100"
let hasModifier = true
let hasMultiplier = false
options.isNudge = true
const nudgeEnabled = game.settings.get("fvtt-cthulhu-eternal", "settings-nudge")
options.isNudge = nudgeEnabled
let actor = game.actors.get(options.actorId)
let target = CthulhuEternalUtils.getTarget()
@@ -271,7 +278,7 @@ export default class CthulhuEternalRoll extends Roll {
case "san":
case "char":
options.initialScore = options.rollItem.targetScore
options.isNudge = (options.rollType !== "san")
options.isNudge = nudgeEnabled && (options.rollType !== "san")
break
case "resource":
hasModifier = false
@@ -322,7 +329,7 @@ export default class CthulhuEternalRoll extends Roll {
break
}
const rollModes = foundry.utils.duplicate(CONFIG.Dice.rollModes); //Object.fromEntries(Object.entries(CONFIG.Dice.rollModes).map(([key, value]) => [key, game.i18n.localize(value)]))
const rollModes = foundry.utils.duplicate(CONFIG.ChatMessage.modes ?? CONFIG.Dice.rollModes)
const fieldRollMode = new foundry.data.fields.StringField({
choices: rollModes,
blank: false,
@@ -526,6 +533,16 @@ export default class CthulhuEternalRoll extends Roll {
}
rollData.resultType = resultType
// Compute WP cost to nudge a failure into a success (minimum roll needed = targetScore)
if (this.options.isFailure && options.isNudge && !this.options.isNudgedRoll && rollData.targetScore > 0 && this.total > rollData.targetScore) {
const actor = game.actors.get(options.actorId)
const wpAvailable = actor?.system?.wp?.value ?? 0
const wpCostToSucceed = Math.ceil((this.total - rollData.targetScore) / 5)
this.options.wpCostToSucceed = (wpCostToSucceed <= wpAvailable) ? wpCostToSucceed : 0
} else {
this.options.wpCostToSucceed = 0
}
this.options.isLowWP = rollData.isLowWP
this.options.isZeroWP = rollData.isZeroWP
this.options.isExhausted = rollData.isExhausted
@@ -685,7 +702,19 @@ export default class CthulhuEternalRoll extends Roll {
* @param {boolean} [options.create=true] Whether to create the message.
* @returns {Promise} - A promise that resolves when the message is created.
*/
async toMessage(messageData = {}, { rollMode, create = true } = {}) {
async toMessage(messageData = {}, { rollMode, messageMode, create = true } = {}) {
let rollData = this.options.rollData || this.options
let rollItem = this.options.rollItem
// Determine skill progression before calling super.toMessage so _getChatCardData picks it up
let skillMarkedForProgress = false
if (rollData.resultType?.includes("failure") && rollItem?.type === "skill") {
if (rollItem.system.diceEvolved && !rollItem.system.rollFailed && !rollItem.system.isAdversary) {
skillMarkedForProgress = true
}
}
this.options.skillMarkedForProgress = skillMarkedForProgress
let rollMsg = await super.toMessage(
{
isFailure: this.resultType === "failure",
@@ -695,34 +724,17 @@ export default class CthulhuEternalRoll extends Roll {
realDamage: this.realDamage,
...messageData,
},
{ rollMode: rollMode },
{ messageMode: messageMode ?? rollMode },
)
let rollData = this.options.rollData || this.options
let rollItem = this.options.rollItem
await rollMsg.setFlag("fvtt-cthulhu-eternal", "rollData", rollData)
// Manage the skill evolution if the roll is a failure
if (rollData.resultType.includes("failure") && rollItem.type === "skill") {
// Is the skill able to progress
if (rollItem.system.diceEvolved && !rollItem.system.rollFailed) {
// If the skill is not adversary, we can evolve it
if (!rollItem.system.isAdversary) {
rollItem.system.rollFailed = true
// Get the actor and update the skill
const actor = game.actors.get(rollData.actorId)
await actor.updateEmbeddedDocuments("Item", [{
_id: rollItem._id,
"system.rollFailed": true
}])
// Create a chat message to inform the user
const flavor = `${rollItem.name} - ${game.i18n.localize("CTHULHUETERNAL.Label.skillFailed")}`
await ChatMessage.create({
user: game.user.id,
content: `<div class="cthulhu-eternal-roll"><p>${flavor}</p></div>`,
speaker: ChatMessage.getSpeaker({ actor: rollData.actor }),
}, { rollMode: rollData.rollMode, create: true })
}
}
// Apply skill rollFailed flag after the message is created
if (skillMarkedForProgress) {
const actor = game.actors.get(rollData.actorId)
await actor.updateEmbeddedDocuments("Item", [{
_id: rollItem._id,
"system.rollFailed": true
}])
}
// If the roll is a SAN roll, we propose to select the SAN loss