Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c97b7a4889 |
@@ -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 } })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
|||||||
@@ -59,14 +59,16 @@ export class TeDeumUtility {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async resetCombatActions(combat) {
|
static async resetCombatActions(combat) {
|
||||||
for (let c of combat.combatants) {
|
if (game.user.isGM) {
|
||||||
let actor = game.actors.get(c.actorId)
|
for (let c of combat.combatants) {
|
||||||
if (actor) {
|
let actor = game.actors.get(c.actorId)
|
||||||
let nbActions = actor.getNbActions()?.value || 0
|
if (actor) {
|
||||||
let isMainGauche = (actor.getCompetenceScore("Main gauche") > 0)
|
let nbActions = actor.getNbActions()?.value || 0
|
||||||
let nbActionsMainGauche = isMainGauche ? nbActions : 0
|
let isMainGauche = (actor.getCompetenceScore("Main gauche") > 0)
|
||||||
await c.setFlag("world", "available-actions", { nbActions, nbActionsMainGauche })
|
let nbActionsMainGauche = isMainGauche ? nbActions : 0
|
||||||
await c.update({ name: `${c.token.name} (${nbActions} / ${nbActionsMainGauche})` })
|
await c.setFlag("world", "available-actions", { nbActions, nbActionsMainGauche })
|
||||||
|
await c.update({ name: `${c.token.name} (${nbActions} / ${nbActionsMainGauche})` })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
await actor.appliquerDegats(rollData)
|
if (game.user.isGM || actor.isOwner) {
|
||||||
|
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.
Reference in New Issue
Block a user