Jet de vie par les propriétaires

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
This commit is contained in:
Vincent Vandemeulebrouck 2023-10-30 19:08:34 +01:00
parent 9d51631d5c
commit fad29f9652
4 changed files with 27 additions and 13 deletions

View File

@ -75,7 +75,7 @@ export class RdDCombatManager extends Combat {
} }
} }
} }
/************************************************************************************/ /************************************************************************************/
async rollInitiative(ids, formula = undefined, messageOptions = {}) { async rollInitiative(ids, formula = undefined, messageOptions = {}) {
console.log(`${game.system.title} | Combat.rollInitiative()`, ids, formula, messageOptions); console.log(`${game.system.title} | Combat.rollInitiative()`, ids, formula, messageOptions);
@ -448,7 +448,7 @@ export class RdDCombat {
if (Misc.isUniqueConnectedGM()) { if (Misc.isUniqueConnectedGM()) {
let turn = combat.turns.find(t => t.token?.id == combat.current.tokenId); let turn = combat.turns.find(t => t.token?.id == combat.current.tokenId);
if (turn?.actor) { if (turn?.actor) {
RdDCombat.displayActorCombatStatus(combat, turn.actor); RdDCombat.displayActorCombatStatus(combat, turn.actor, turn.token.id);
// TODO Playaudio for player?? // TODO Playaudio for player??
} }
} }
@ -512,8 +512,12 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
static _callJetDeVie(event) { static _callJetDeVie(event) {
let actorId = event.currentTarget.attributes['data-actorId'].value; let actorId = event.currentTarget.attributes['data-actorId'].value;
let actor = game.actors.get(actorId); let tokenId = event.currentTarget.attributes['data-tokenId'].value;
actor.jetVie(); 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(); event.preventDefault();
RdDCombat._callJetDeVie(event); RdDCombat._callJetDeVie(event);
}); });
@ -1292,7 +1296,7 @@ export class RdDCombat {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static async displayActorCombatStatus(combat, actor) { static async displayActorCombatStatus(combat, actor, tokenId) {
let formData = { let formData = {
combatId: combat._id, combatId: combat._id,
alias: actor.name, alias: actor.name,
@ -1301,12 +1305,18 @@ export class RdDCombat {
blessuresStatus: actor.computeResumeBlessure(), blessuresStatus: actor.computeResumeBlessure(),
SConst: actor.getSConst(), SConst: actor.getSConst(),
actorId: actor.id, actorId: actor.id,
tokenId: tokenId,
isGrave: actor.countBlessures(it => it.isGrave()) > 0, isGrave: actor.countBlessures(it => it.isGrave()) > 0,
isCritique: actor.countBlessures(it => it.isCritique()) > 0 isCritique: actor.countBlessures(it => it.isCritique()) > 0
} }
await ChatMessage.create({
ChatUtility.createChatWithRollMode(actor.name, { content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-acteur.hbs`, formData),
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-summary.html`, 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
}); });
} }
} }

View File

@ -245,7 +245,8 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/chat-description.html', '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-appel-au-moral.html',
'systems/foundryvtt-reve-de-dragon/templates/chat-info-distance.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-competence-xp.html',
'systems/foundryvtt-reve-de-dragon/templates/chat-actor-carac-xp.html', 'systems/foundryvtt-reve-de-dragon/templates/chat-actor-carac-xp.html',
'systems/foundryvtt-reve-de-dragon/templates/chat-potionenchantee-chateaudormant.html', 'systems/foundryvtt-reve-de-dragon/templates/chat-potionenchantee-chateaudormant.html',

View File

@ -0,0 +1 @@
<h4>C'est au tour de {{alias}} !</h4>

View File

@ -1,4 +1,4 @@
<h4>C'est au tour de {{alias}} !</h4> <h4>Résumé de santé pour {{alias}}</h4>
<div data-combatid="{{combatId}}" data-combatmessage="actor-turn-summary">{{blessuresStatus}}</div> <div data-combatid="{{combatId}}" data-combatmessage="actor-turn-summary">{{blessuresStatus}}</div>
<div>Son état général est de : {{etatGeneral}} {{#if isSonne}} et est <strong>sonné</strong>{{/if}}</div> <div>Son état général est de : {{etatGeneral}} {{#if isSonne}} et est <strong>sonné</strong>{{/if}}</div>
{{#if isGrave}} {{#if isGrave}}
@ -6,5 +6,7 @@
{{/if}} {{/if}}
{{#if isCritique}} {{#if isCritique}}
<div>{{alias}} souffre d'une <strong>Blessure Critique</strong> : faites un <div>{{alias}} souffre d'une <strong>Blessure Critique</strong> : faites un
<a id="chat-jet-vie" class="chat-card-button" data-actorId="{{actorId}}">Jet de Vie.<a></div> <a class="chat-card-button chat-jet-vie"
data-tokenId="{{tokenId}}"
data-actorId="{{actorId}}">Jet de Vie.<a></div>
{{/if}} {{/if}}