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:
@@ -203,7 +203,7 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
|
||||
skills = skills.sort((a, b) => a.name.localeCompare(b.name))
|
||||
console.log('Building skills actions for skills:', skills)
|
||||
for (const skill of skills) {
|
||||
console.log('Processing skill item:', skill)
|
||||
//console.log('Processing skill item:', skill)
|
||||
if (skill.system.skillTotal > 0) {
|
||||
const tooltip = {
|
||||
content: String(skill.system.skillTotal),
|
||||
|
||||
@@ -310,7 +310,13 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
|
||||
options.rollItem = CthulhuEternalUtils.getWeaponSkill(actor, options.rollItem, era)
|
||||
options.initialScore = options.rollItem.system.skillTotal
|
||||
console.log("WEAPON", era, options.rollItem)
|
||||
if (options.weapon.system.state === "junk") {
|
||||
options.isJunk = true
|
||||
options.initialScore = Math.max(0, options.initialScore - 20) // -20% for junk weapons
|
||||
}
|
||||
if (options.weapon.system.state === "worn") {
|
||||
options.isWorn = true
|
||||
}
|
||||
}
|
||||
break
|
||||
default:
|
||||
@@ -341,6 +347,8 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
targetScore: options.initialScore,
|
||||
isLowWP: options.isLowWP,
|
||||
isZeroWP: options.isZeroWP,
|
||||
isJunk: options.isJunk,
|
||||
isWorn: options.isWorn,
|
||||
isExhausted: options.isExhausted,
|
||||
enableHand: options.rollItem.enableHand,
|
||||
enableStowed: options.rollItem.enableStowed,
|
||||
@@ -464,14 +472,15 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
const roll = new this(formula, options.data, rollData)
|
||||
await roll.evaluate()
|
||||
|
||||
roll.displayRollResult(roll, options, rollData)
|
||||
await roll.displayRollResult(roll, options, rollData)
|
||||
|
||||
if (Hooks.call("fvtt-cthulhu-eternal.Roll", options, rollData, roll) === false) return
|
||||
|
||||
|
||||
return roll
|
||||
}
|
||||
|
||||
displayRollResult(formula, options, rollData) {
|
||||
async displayRollResult(formula, options, rollData) {
|
||||
|
||||
// Compute the result quality
|
||||
let resultType = "failure"
|
||||
@@ -489,6 +498,11 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
resultType = "failureCritical"
|
||||
}
|
||||
}
|
||||
if (rollData.weapon?.system?.state === "junk" && this.total > 95) {
|
||||
this.options.isDestroyed = true
|
||||
rollData.isDestroyed = true
|
||||
resultType = "failureCritical"
|
||||
}
|
||||
// As per the rules, a roll of 100 is always a failure, even if the target is above 100
|
||||
if (this.total === 100) {
|
||||
resultType = "failureCritical"
|
||||
|
||||
@@ -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