Corrections diverses autout du combat

This commit is contained in:
2026-04-13 14:19:24 +02:00
parent 44cc07db73
commit d69144f506
46 changed files with 1340 additions and 241 deletions

View File

@@ -572,8 +572,10 @@ async function _onApplyWeaponDamageClick(event, message) {
const button = event.currentTarget
const card = button.closest(".celestopol.chat-roll")
const select = button.closest(".weapon-damage-actions")?.querySelector('select[name="targetActorId"]')
const actorId = button.dataset.actorId || select?.value || ""
const select = button.closest(".weapon-damage-actions")?.querySelector('select[name="targetActorUuid"]')
const selectedOption = select?.selectedOptions?.[0] ?? null
const actorUuid = button.dataset.actorUuid || select?.value || ""
const actorId = button.dataset.actorId || selectedOption?.dataset.actorId || ""
const incomingWounds = Number.parseInt(button.dataset.incomingWounds ?? "", 10)
const currentState = _getDamageApplicationState(message)
@@ -582,7 +584,7 @@ async function _onApplyWeaponDamageClick(event, message) {
return
}
if (!actorId) {
if (!actorUuid && !actorId) {
ui.notifications.warn(game.i18n.localize("CELESTOPOL.Combat.selectCharacterFirst"))
return
}
@@ -593,14 +595,15 @@ async function _onApplyWeaponDamageClick(event, message) {
button.disabled = true
await _requestWeaponDamageApplication({
actorId,
actorUuid,
incomingWounds,
chatMessageId: message?.id ?? null,
})
}
async function _requestWeaponDamageApplication({ actorId, incomingWounds, chatMessageId = null }) {
async function _requestWeaponDamageApplication({ actorId, actorUuid = null, incomingWounds, chatMessageId = null }) {
if (game.user.isGM) {
return _applyWeaponDamage({ actorId, incomingWounds, chatMessageId })
return _applyWeaponDamage({ actorId, actorUuid, incomingWounds, chatMessageId })
}
if (!game.socket) return
@@ -608,6 +611,7 @@ async function _requestWeaponDamageApplication({ actorId, incomingWounds, chatMe
game.socket.emit(`system.${SYSTEM_ID}`, {
type: "applyWeaponDamage",
actorId,
actorUuid,
incomingWounds,
chatMessageId,
})
@@ -645,7 +649,7 @@ function _setDamageStatus(root, { text, cssClass = "" }) {
function _renderPendingWeaponDamageState(root) {
const button = root.querySelector('[data-action="apply-weapon-damage"]')
const select = root.querySelector('select[name="targetActorId"]')
const select = root.querySelector('select[name="targetActorUuid"]')
if (button) {
button.disabled = true
button.textContent = game.i18n.localize("CELESTOPOL.Combat.damageApplying")
@@ -659,7 +663,7 @@ function _renderPendingWeaponDamageState(root) {
function _renderWeaponDamageState(message, root) {
const button = root.querySelector('[data-action="apply-weapon-damage"]')
const select = root.querySelector('select[name="targetActorId"]')
const select = root.querySelector('select[name="targetActorUuid"]')
const state = _getDamageApplicationState(message)
if (!state?.applied) {
@@ -701,8 +705,8 @@ async function _markChatMessageDamageApplied(chatMessageId, data) {
_updateRenderedChatMessageState(message)
}
async function _applyWeaponDamage({ actorId, incomingWounds, chatMessageId = null }) {
const actor = game.actors.get(actorId)
async function _applyWeaponDamage({ actorId, actorUuid = null, incomingWounds, chatMessageId = null }) {
const actor = await CelestopolRoll.resolveActor({ actorId, actorUuid })
if (!actor) return null
const message = chatMessageId ? game.messages.get(chatMessageId) : null