Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f47f2906a4 | ||
|
|
0228f351c7 |
@@ -163,7 +163,7 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
// D'abord, ajouter les combattants du combat actif
|
// D'abord, ajouter les combattants du combat actif
|
||||||
if (game?.combat?.combatants) {
|
if (game?.combat?.combatants) {
|
||||||
for (let c of game.combat.combatants) {
|
for (let c of game.combat.combatants) {
|
||||||
if (c.actorId !== this.actorId) {
|
if (c.actorId !== this.actorId && !c.isDefeated) {
|
||||||
combatants.push({ id: c.id, name: c.name, tokenId: c.token.id })
|
combatants.push({ id: c.id, name: c.name, tokenId: c.token.id })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,6 +174,9 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
const existingTokenIds = new Set(combatants.map(c => c.tokenId))
|
const existingTokenIds = new Set(combatants.map(c => c.tokenId))
|
||||||
for (let token of canvas.scene.tokens) {
|
for (let token of canvas.scene.tokens) {
|
||||||
if (token.actorId !== this.actorId && !existingTokenIds.has(token.id)) {
|
if (token.actorId !== this.actorId && !existingTokenIds.has(token.id)) {
|
||||||
|
// Skip dead tokens: monsters at 0 HP are dead; characters use the defeated flag
|
||||||
|
const tokenActor = game.actors.get(token.actorId)
|
||||||
|
if (tokenActor?.type === "monster" && (Number(tokenActor?.system?.hp?.value) || 0) <= 0) continue
|
||||||
combatants.push({
|
combatants.push({
|
||||||
id: token.id,
|
id: token.id,
|
||||||
name: token.name,
|
name: token.name,
|
||||||
|
|||||||
@@ -33,38 +33,12 @@ Hooks.on("renderChatMessageHTML", (message, html, data) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const btn of html.querySelectorAll(".apply-wounds-btn")) {
|
for (const btn of html.querySelectorAll(".apply-wounds-btn")) {
|
||||||
btn.addEventListener("mouseenter", () => {
|
|
||||||
const combatantId = btn.dataset.combatantId
|
|
||||||
if (combatantId && game.combat) {
|
|
||||||
const combatant = game.combat.combatants.get(combatantId)
|
|
||||||
if (combatant?.token) {
|
|
||||||
const token = canvas.tokens.get(combatant.token.id)
|
|
||||||
if (token) {
|
|
||||||
token.control({ releaseOthers: true })
|
|
||||||
canvas.animatePan(token.center)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
btn.addEventListener("mouseleave", () => canvas.tokens.releaseAll())
|
|
||||||
btn.addEventListener("click", event => LethalFantasyUtils.applyDamage(message, event))
|
btn.addEventListener("click", event => LethalFantasyUtils.applyDamage(message, event))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gestion du survol et du clic sur les boutons de défense
|
// Gestion du survol et du clic sur les boutons de défense
|
||||||
for (const btn of html.querySelectorAll(".request-defense-btn")) {
|
for (const btn of html.querySelectorAll(".request-defense-btn")) {
|
||||||
btn.addEventListener("mouseenter", () => {
|
|
||||||
const tokenId = btn.dataset.tokenId
|
|
||||||
if (tokenId) {
|
|
||||||
const token = canvas.tokens.get(tokenId)
|
|
||||||
if (token) {
|
|
||||||
token.control({ releaseOthers: true })
|
|
||||||
canvas.animatePan(token.center)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
btn.addEventListener("mouseleave", () => canvas.tokens.releaseAll())
|
|
||||||
|
|
||||||
// Gestionnaire pour les boutons de demande de défense
|
// Gestionnaire pour les boutons de demande de défense
|
||||||
btn.addEventListener("click", async event => {
|
btn.addEventListener("click", async event => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|||||||
@@ -105,8 +105,26 @@ export async function handleAttackBoosted(msg) {
|
|||||||
} = msg
|
} = msg
|
||||||
|
|
||||||
const defender = game.actors.get(defenderId)
|
const defender = game.actors.get(defenderId)
|
||||||
|
const attacker = game.actors.get(attackerId)
|
||||||
if (!defender) return
|
if (!defender) return
|
||||||
|
|
||||||
|
// The createChatMessage hook is suppressed on this client in two cases:
|
||||||
|
// 1. Attacker is a PC on another client — the hook's defense reaction loop
|
||||||
|
// and shouldCreateMessage are both skipped.
|
||||||
|
// 2. Attacker is GM-controlled with D30 — the hook skips everything and
|
||||||
|
// waits for this socket handler.
|
||||||
|
// In both cases, this handler must run to show the defense dialog and create
|
||||||
|
// the comparison message. The common condition: the current user is the
|
||||||
|
// defender's primary controller.
|
||||||
|
const _isPrimaryController = actor => {
|
||||||
|
if (!actor) return false
|
||||||
|
const activePlayerOwners = game.users.filter(u => u.active && !u.isGM && actor.testUserPermission(u, "OWNER"))
|
||||||
|
if (activePlayerOwners.length > 0) return activePlayerOwners[0].id === game.user.id
|
||||||
|
return game.user.isGM
|
||||||
|
}
|
||||||
|
const defenderIsMine = _isPrimaryController(defender)
|
||||||
|
if (!defenderIsMine) return
|
||||||
|
|
||||||
let updatedDefenseRoll = defenseRoll
|
let updatedDefenseRoll = defenseRoll
|
||||||
let shieldBlocked = false
|
let shieldBlocked = false
|
||||||
let shieldReaction = null
|
let shieldReaction = null
|
||||||
|
|||||||
Reference in New Issue
Block a user