From fad29f9652ed447d1f660eb3ddba301d9d25e8d6 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Mon, 30 Oct 2023 19:08:34 +0100 Subject: [PATCH] =?UTF-8?q?Jet=20de=20vie=20par=20les=20propri=C3=A9taires?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Les messages de tour sont séparés en deux: - un message pour tout le monde disant de qui c'est le tour - un message pour les propriétaires du token pour les informations de santé (jets de vie à faire, ...) Seul les propriétaires peuvent déclencher les jets de vie --- module/rdd-combat.js | 30 ++++++++++++------- module/rdd-utility.js | 3 +- templates/chat-actor-turn-acteur.hbs | 1 + ...summary.html => chat-actor-turn-sante.hbs} | 6 ++-- 4 files changed, 27 insertions(+), 13 deletions(-) create mode 100644 templates/chat-actor-turn-acteur.hbs rename templates/{chat-actor-turn-summary.html => chat-actor-turn-sante.hbs} (74%) diff --git a/module/rdd-combat.js b/module/rdd-combat.js index ee434acd..c0eea94c 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -75,7 +75,7 @@ export class RdDCombatManager extends Combat { } } } - + /************************************************************************************/ async rollInitiative(ids, formula = undefined, messageOptions = {}) { console.log(`${game.system.title} | Combat.rollInitiative()`, ids, formula, messageOptions); @@ -448,7 +448,7 @@ export class RdDCombat { if (Misc.isUniqueConnectedGM()) { let turn = combat.turns.find(t => t.token?.id == combat.current.tokenId); if (turn?.actor) { - RdDCombat.displayActorCombatStatus(combat, turn.actor); + RdDCombat.displayActorCombatStatus(combat, turn.actor, turn.token.id); // TODO Playaudio for player?? } } @@ -512,8 +512,12 @@ export class RdDCombat { /* -------------------------------------------- */ static _callJetDeVie(event) { let actorId = event.currentTarget.attributes['data-actorId'].value; - let actor = game.actors.get(actorId); - actor.jetVie(); + let tokenId = event.currentTarget.attributes['data-tokenId'].value; + let token = canvas.tokens.placeables.find(t => t.id == tokenId) + const actor = token?.actor ?? game.actors.get(actorId); + if (actor?.isOwner) { + actor.jetVie(); + } } /* -------------------------------------------- */ @@ -539,7 +543,7 @@ export class RdDCombat { } }); } - html.on("click", '#chat-jet-vie', event => { + html.on("click", 'a.chat-jet-vie', event => { event.preventDefault(); RdDCombat._callJetDeVie(event); }); @@ -1292,7 +1296,7 @@ export class RdDCombat { } /* -------------------------------------------- */ - static async displayActorCombatStatus(combat, actor) { + static async displayActorCombatStatus(combat, actor, tokenId) { let formData = { combatId: combat._id, alias: actor.name, @@ -1301,12 +1305,18 @@ export class RdDCombat { blessuresStatus: actor.computeResumeBlessure(), SConst: actor.getSConst(), actorId: actor.id, + tokenId: tokenId, isGrave: actor.countBlessures(it => it.isGrave()) > 0, isCritique: actor.countBlessures(it => it.isCritique()) > 0 } - - ChatUtility.createChatWithRollMode(actor.name, { - content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-summary.html`, formData) + await ChatMessage.create({ + content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-acteur.hbs`, formData), + alias: actor.name + }); + await ChatMessage.create({ + content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-sante.hbs`, formData), + whisper: ChatUtility.getWhisperRecipientsAndGMs(actor.name), + alias: actor.name }); } -} +} \ No newline at end of file diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 703e3c87..b3b188a9 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -245,7 +245,8 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/chat-description.html', 'systems/foundryvtt-reve-de-dragon/templates/chat-info-appel-au-moral.html', 'systems/foundryvtt-reve-de-dragon/templates/chat-info-distance.html', - 'systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-summary.html', + 'systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-acteur.hbs', + 'systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-sante.hbs', 'systems/foundryvtt-reve-de-dragon/templates/chat-actor-competence-xp.html', 'systems/foundryvtt-reve-de-dragon/templates/chat-actor-carac-xp.html', 'systems/foundryvtt-reve-de-dragon/templates/chat-potionenchantee-chateaudormant.html', diff --git a/templates/chat-actor-turn-acteur.hbs b/templates/chat-actor-turn-acteur.hbs new file mode 100644 index 00000000..ad174c7f --- /dev/null +++ b/templates/chat-actor-turn-acteur.hbs @@ -0,0 +1 @@ +

C'est au tour de {{alias}} !

diff --git a/templates/chat-actor-turn-summary.html b/templates/chat-actor-turn-sante.hbs similarity index 74% rename from templates/chat-actor-turn-summary.html rename to templates/chat-actor-turn-sante.hbs index b1509a66..30d80271 100644 --- a/templates/chat-actor-turn-summary.html +++ b/templates/chat-actor-turn-sante.hbs @@ -1,4 +1,4 @@ -

C'est au tour de {{alias}} !

+

Résumé de santé pour {{alias}}

{{blessuresStatus}}
Son état général est de : {{etatGeneral}} {{#if isSonne}} et est sonné{{/if}}
{{#if isGrave}} @@ -6,5 +6,7 @@ {{/if}} {{#if isCritique}}
{{alias}} souffre d'une Blessure Critique : faites un - Jet de Vie.
+ Jet de Vie. {{/if}} \ No newline at end of file