Correction sur blessures et actions restantes
All checks were successful
Release Creation / build (release) Successful in 53s

This commit is contained in:
2025-10-16 22:59:32 +02:00
parent 5d13500838
commit c97b7a4889
20 changed files with 58 additions and 13 deletions

View File

@@ -10,6 +10,7 @@ export class TeDeumCombat extends Combat {
for (let cId of ids) { for (let cId of ids) {
const c = this.combatants.get(cId); const c = this.combatants.get(cId);
let initBonus = c.actor ? c.actor.getInitiativeScore(this.id, cId) : -1; let initBonus = c.actor ? c.actor.getInitiativeScore(this.id, cId) : -1;
console.log("Init Bonus : ", c.name, initBonus)
await this.updateEmbeddedDocuments("Combatant", [{ _id: cId, initiative: initBonus }]); await this.updateEmbeddedDocuments("Combatant", [{ _id: cId, initiative: initBonus }]);
} }
@@ -31,8 +32,12 @@ export class TeDeumCombat extends Combat {
} }
if (ca.nbActionsMainGauche < 0) ca.nbActionsMainGauche = 0 if (ca.nbActionsMainGauche < 0) ca.nbActionsMainGauche = 0
if (ca.nbActions < 0) ca.nbActions = 0 if (ca.nbActions < 0) ca.nbActions = 0
await combatant.setFlag("world", "available-actions", ca) console.log("Modify Action : ", combatant.name, ca)
await combatant.update({ name: `${combatant.token.name} (${ca.nbActions} / ${ca.nbActionsMainGauche})` }) if (game.user.isGM) {
await TeDeumUtility.updateCombatantActions(combatant, ca)
} else {
game.socket.emit("system.fvtt-te-deum", { msg: "msg_modify_combat_action", data: { combatantId: combatantId, ca: ca } })
}
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@@ -59,6 +59,7 @@ export class TeDeumUtility {
/* -------------------------------------------- */ /* -------------------------------------------- */
static async resetCombatActions(combat) { static async resetCombatActions(combat) {
if (game.user.isGM) {
for (let c of combat.combatants) { for (let c of combat.combatants) {
let actor = game.actors.get(c.actorId) let actor = game.actors.get(c.actorId)
if (actor) { if (actor) {
@@ -70,6 +71,7 @@ export class TeDeumUtility {
} }
} }
} }
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static async ready() { static async ready() {
@@ -300,7 +302,12 @@ export class TeDeumUtility {
let defenderToken = canvas.tokens.placeables.find(t => t.id == rollData.defenderTokenId) let defenderToken = canvas.tokens.placeables.find(t => t.id == rollData.defenderTokenId)
if (defenderToken) { if (defenderToken) {
let actor = defenderToken.actor let actor = defenderToken.actor
if (game.user.isGM || actor.isOwner) {
await actor.appliquerDegats(rollData) await actor.appliquerDegats(rollData)
} else {
// Send a socket message
game.socket.emit("system.fvtt-te-deum", { name: "msg_apply_damage", data: { rollData } });
}
// Attaque naturelle avec dégats inférieur à -2 // Attaque naturelle avec dégats inférieur à -2
if ((rollData?.arme?.system.specificites?.poing?.hasSpec || rollData?.arme?.system.specificites?.pied?.hasSpec) && rollData.degats < -2) { if ((rollData?.arme?.system.specificites?.poing?.hasSpec || rollData?.arme?.system.specificites?.pied?.hasSpec) && rollData.degats < -2) {
let attacker = this.getActorFromRollData(rollData) let attacker = this.getActorFromRollData(rollData)
@@ -436,6 +443,28 @@ export class TeDeumUtility {
chatMsg.setFlag("world", "tedeum-rolldata", rollData) chatMsg.setFlag("world", "tedeum-rolldata", rollData)
} }
} }
if (msg.name == "msg_modify_combat_action") {
if (game.user.isGM) {
let { combatantId, ca } = msg.data
let combatant = game.combat.combatants.get(combatantId)
if (combatant) {
console.log("sock - Modify Combat Action : ", combatant.name, ca)
await TeDeumUtility.updateCombatantActions(combatant, ca)
}
}
}
if (msg.name == "msg_apply_damage") {
if (game.user.isGM) {
let rollData = msg.data.rollData
let defenderToken = canvas.tokens.placeables.find(t => t.id == rollData.defenderTokenId)
if (defenderToken) {
let actor = defenderToken.actor
await actor.appliquerDegats(rollData)
} else {
ui.notifications.error("Impossible de trouver la cible de l'attaque, aucun degats appliqué")
}
}
}
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@@ -618,6 +647,12 @@ export class TeDeumUtility {
} }
} }
/* -------------------------------------------- */
static async updateCombatantActions(combatant, ca) {
await combatant.setFlag("world", "available-actions", ca)
await combatant.update({ name: `${combatant.token.name} (${ca.nbActions} / ${ca.nbActionsMainGauche})` })
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static async manageCombatActions(actor, rollData) { static async manageCombatActions(actor, rollData) {
let combat = game.combats.active let combat = game.combats.active
@@ -639,8 +674,13 @@ export class TeDeumUtility {
} else { } else {
ui.notifications.error(`${actor.name} n'a plus d'actions disponibles pour ce round`) ui.notifications.error(`${actor.name} n'a plus d'actions disponibles pour ce round`)
} }
await combatant.setFlag("world", "available-actions", ca) console.log("Manage combat actions 1", actor.name, combatant)
await combatant.update({ name: `${combatant.token.name} (${ca.nbActions} / ${ca.nbActionsMainGauche})` }) if (game.user.isGM) {
await this.updateCombatantActions(combatant, ca)
} else {
// Send a socket message
game.socket.emit("system.fvtt-te-deum", { name: "msg_modify_combat_action", data: { combatantId: combatant.id, ca } });
}
rollData.hasActions = true rollData.hasActions = true
rollData.remainingActions = ca.nbActions rollData.remainingActions = ca.nbActions
rollData.remainingActionsMainGauche = ca.nbActionsMainGauche rollData.remainingActionsMainGauche = ca.nbActionsMainGauche

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.