Foundryv14 migration
All checks were successful
Release Creation / build (release) Successful in 46s
All checks were successful
Release Creation / build (release) Successful in 46s
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user