Foundryv14 migration
All checks were successful
Release Creation / build (release) Successful in 46s

This commit is contained in:
2026-04-01 22:57:43 +02:00
parent 7dc2492c96
commit bb6a6248f2
25 changed files with 178 additions and 53 deletions

View File

@@ -483,6 +483,66 @@ export default class CthulhuEternalUtils {
actor.system.roll("damage", rollData.weapon)
}
static async wornWeaponCheck(rollMessage) {
let rollData = rollMessage.rolls[0]?.options?.rollData
if (!rollData) {
rollData = rollMessage.getFlag("fvtt-cthulhu-eternal", "rollData")
}
if (!rollData) {
ui.notifications.error(game.i18n.localize("CTHULHUETERNAL.Label.noRollDataFound"))
return
}
let actor = game.actors.get(rollData.actorId)
if (!actor) {
ui.notifications.error(game.i18n.localize("CTHULHUETERNAL.Label.noActorFound"))
return
}
let weapon = rollData.weapon
if (!weapon) {
ui.notifications.error(game.i18n.localize("CTHULHUETERNAL.Label.noWeaponFound"))
return
}
// Lance un jet de chance (50%)
let luckRoll = new Roll("1d100")
await luckRoll.evaluate()
let isSuccess = luckRoll.total <= 50
let resultMsg = ""
if (isSuccess) {
// Succès - l'arme reste worn
resultMsg = game.i18n.format("CTHULHUETERNAL.Label.wornWeaponCheckSuccess", {
weapon: weapon.name,
roll: luckRoll.total
})
} else {
// Échec - l'arme devient junk
resultMsg = game.i18n.format("CTHULHUETERNAL.Label.wornWeaponCheckFailure", {
weapon: weapon.name,
roll: luckRoll.total
})
// Mettre à jour l'état de l'arme
await actor.updateEmbeddedDocuments("Item", [{
_id: weapon._id,
"system.state": "junk"
}])
ui.notifications.warn(game.i18n.format("CTHULHUETERNAL.Notifications.WeaponBecameJunk", { weapon: weapon.name }))
}
// Créer un message de chat avec le résultat
await ChatMessage.create({
user: game.user.id,
content: `<div class="cthulhu-eternal-roll">
<h4>${game.i18n.localize("CTHULHUETERNAL.Label.wornWeaponCheckTitle")}</h4>
<p>${resultMsg}</p>
</div>`,
speaker: ChatMessage.getSpeaker({ actor: actor }),
})
}
static async nudgeRoll(rollMessage) {
let dialogContext = rollMessage.rolls[0]?.options