#105 Affichage résumé a chaque tour de combat

This commit is contained in:
sladecraven 2021-01-03 15:40:48 +01:00
parent 57c568c0d4
commit 969291a526
7 changed files with 84 additions and 18 deletions

View File

@ -232,7 +232,7 @@ export class RdDActor extends Actor {
return ''; return '';
} }
// TODO: gérer une liste de flags demi-surprise (avec icône sur le token)? // TODO: gérer une liste de flags demi-surprise (avec icône sur le token)?
if ( this.data.data.sante.sonne.value) { if ( this.data.data.sante.sonne && this.data.data.sante.sonne.value) {
return 'demi'; return 'demi';
} }
return ''; return '';
@ -748,7 +748,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
getEtatGeneral() { getEtatGeneral() {
return (this.data.data.compteurs && actor.data.data.compteurs.etat) ? this.data.data.compteurs.etat.value : 0; return (this.data.data.compteurs && this.data.data.compteurs.etat) ? this.data.data.compteurs.etat.value : 0;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -924,6 +924,23 @@ export class RdDActor extends Actor {
await this.update( {"data.reve.seuil": seuil } ); await this.update( {"data.reve.seuil": seuil } );
} }
/* -------------------------------------------- */
getSonne() {
if ( !this.isEntiteCauchemar() && this.data.data.sante.sonne ) {
return this.data.data.sante.sonne.value;
}
return false;
}
/* -------------------------------------------- */
getSConst() {
if ( !this.isEntiteCauchemar() && this.data.data.attributs ) {
return this.data.data.attributs.sconst.value;
}
return 0;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
testSiSonne( sante, endurance ) testSiSonne( sante, endurance )
{ {
@ -945,6 +962,11 @@ export class RdDActor extends Actor {
{ {
return blessuresListe.filter(b => b.active).length return blessuresListe.filter(b => b.active).length
} }
/* -------------------------------------------- */
countBlessuresByName( name )
{
return this.countBlessures( this.data.data.blessures[name].liste );
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async jetVie() { async jetVie() {

View File

@ -4,6 +4,7 @@
*/ */
export class ChatUtility { export class ChatUtility {
/* -------------------------------------------- */
static chatWithRollMode(chatOptions, name) { static chatWithRollMode(chatOptions, name) {
let rollMode = game.settings.get("core", "rollMode"); let rollMode = game.settings.get("core", "rollMode");
ChatUtility.createChatMessage(chatOptions, rollMode, name); ChatUtility.createChatMessage(chatOptions, rollMode, name);

View File

@ -58,7 +58,7 @@ export class RdDCombat {
return RdDCombat.createUsingTarget(attacker) return RdDCombat.createUsingTarget(attacker)
} }
/* -------------------------------------------- */
static _sendRollMessage(sender, recipient, defenderTokenId, topic, message, rollData) { static _sendRollMessage(sender, recipient, defenderTokenId, topic, message, rollData) {
let chatMessage = { let chatMessage = {
content: message, content: message,
@ -85,6 +85,13 @@ export class RdDCombat {
} }
} }
/* -------------------------------------------- */
static _callJetDeVie( event ) {
let actorId = event.currentTarget.attributes['data-actorId'].value;
let actor = game.actors.get(actorId);
actor.jetVie();
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static registerChatCallbacks(html) { static registerChatCallbacks(html) {
for (let button of ['#parer-button', '#esquiver-button', '#particuliere-attaque', '#encaisser-button']) { for (let button of ['#parer-button', '#esquiver-button', '#particuliere-attaque', '#encaisser-button']) {
@ -93,6 +100,11 @@ export class RdDCombat {
RdDCombat.createForEvent(event).onEvent(button, event); RdDCombat.createForEvent(event).onEvent(button, event);
}); });
} }
html.on("click", '#chat-jet-vie', event => {
event.preventDefault();
RdDCombat._callJetDeVie(event);
} );
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -668,4 +680,35 @@ export class RdDCombat {
return rolled.isSuccess; return rolled.isSuccess;
} }
/* -------------------------------------------- */
static async displayActorCombatStatus( actor ) {
let rollMode = game.settings.get("core", "rollMode");
let rollData = {
alias: actor.name,
etatGeneral: actor.getEtatGeneral(),
isSonne: actor.getSonne(),
blessuresStatus: actor.computeResumeBlessure(),
SConst: actor.getSConst(),
actorId: actor.data._id,
isGrave: false,
isCritique: false
}
if ( actor.countBlessuresByName("critiques") > 0 ) { // Pour éviter le cumul grave + critique
rollData.isCritique = true;
} else if ( actor.countBlessuresByName("graves") > 0) {
rollData.isGrave = true;
}
let content = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-summary.html`, rollData);
ChatUtility.createChatMessage({ content: content }, rollMode, actor.name);
}
/* -------------------------------------------- */
static updateCombatRound( combat, data) {
if (combat.data.round != 0 && combat.turns && combat.data.active) {
let turn = combat.turns.find(t => t.tokenId == combat.current.tokenId);
this.displayActorCombatStatus( turn.actor );
// TODO Playaudio ??
}
}
} }

View File

@ -20,6 +20,7 @@ import { RdDCalendrier } from "./rdd-calendrier.js";
import { RdDResolutionTable } from "./rdd-resolution-table.js"; import { RdDResolutionTable } from "./rdd-resolution-table.js";
import { RdDTokenHud } from "./rdd-token-hud.js"; import { RdDTokenHud } from "./rdd-token-hud.js";
import { RdDCommands } from "./rdd-commands.js"; import { RdDCommands } from "./rdd-commands.js";
import { RdDCombat } from "./rdd-combat.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
/* Foundry VTT Initialization */ /* Foundry VTT Initialization */
@ -257,20 +258,9 @@ Hooks.once("ready", function() {
// Integration du TokenHUD // Integration du TokenHUD
Hooks.on('renderTokenHUD', (app, html, data) => { RdDTokenHud.addTokenHudExtensions(app, html, data._id) }); Hooks.on('renderTokenHUD', (app, html, data) => { RdDTokenHud.addTokenHudExtensions(app, html, data._id) });
Hooks.on("updateCombat", (combat, data) => { RdDCombat.updateCombatRound(combat, data) } );
}); });
/* -------------------------------------------- */
/* Abandonné pour l'instant
Hooks.on("preCreateToken", (scene, tokenData, options) => {
let actor = game.actors.get( tokenData.actorId )
if (actor) {
let tokenSize = actor.data.data.carac.taille.value / 10;
tokenData.width = tokenSize;
tokenData.height = tokenSize;
}
console.log("PRECREATE:", scene, tokenData, options);
});*/
/* -------------------------------------------- */ /* -------------------------------------------- */
/* Foundry VTT Initialization */ /* Foundry VTT Initialization */
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -92,6 +92,7 @@ export class RdDResolutionTable {
return message; return message;
} }
/* -------------------------------------------- */
static async buildRollDataHtml(rollData, template = 'chat-resultat-general.html') { static async buildRollDataHtml(rollData, template = 'chat-resultat-general.html') {
rollData.ajustements = RdDResolutionTable._buildAjustements(rollData); rollData.ajustements = RdDResolutionTable._buildAjustements(rollData);
rollData.show = rollData.show || {}; rollData.show = rollData.show || {};
@ -99,6 +100,7 @@ export class RdDResolutionTable {
return await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/${template}`, rollData); return await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/${template}`, rollData);
} }
/* -------------------------------------------- */
static async displayRollData(rollData, userName, template = 'chat-resultat-general.html') { static async displayRollData(rollData, userName, template = 'chat-resultat-general.html') {
ChatUtility.chatWithRollMode( ChatUtility.chatWithRollMode(

View File

@ -207,6 +207,7 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-general.html', 'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-general.html',
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-tache.html', 'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-tache.html',
'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-sort.html', 'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-sort.html',
'systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-summary.html',
]; ];
@ -908,7 +909,7 @@ export class RdDUtility {
let actorId = event.currentTarget.attributes['data-actor-id'].value; let actorId = event.currentTarget.attributes['data-actor-id'].value;
let actor = game.actors.get( actorId ); let actor = game.actors.get( actorId );
actor.tmrApp.lancerSortEnReserve(coord, sortId); actor.tmrApp.lancerSortEnReserve(coord, sortId);
}); });
// Gestion du bouton payer // Gestion du bouton payer
html.on("click", '#payer-button', event => { html.on("click", '#payer-button', event => {
let sumdenier = event.currentTarget.attributes['data-somme-denier'].value; let sumdenier = event.currentTarget.attributes['data-somme-denier'].value;
@ -917,7 +918,6 @@ export class RdDUtility {
if ( jsondata ) { if ( jsondata ) {
objData = JSON.parse(jsondata.value) objData = JSON.parse(jsondata.value)
} }
console.log("Demande payer : ", objData);
if (game.user.character ) { if (game.user.character ) {
game.user.character.payerDenier(sumdenier, objData); game.user.character.payerDenier(sumdenier, objData);
} else { } else {
@ -980,5 +980,4 @@ export class RdDUtility {
return chatData; return chatData;
} }
} }

View File

@ -0,0 +1,9 @@
<h4>C'est au tour de {{alias}} ! </h4>
<div>{{blessuresStatus}}</div>
<div>Son état général est de : {{etatGeneral}} {{#if isSonne}} et est <strong>sonné</strong>{{/if}}</div>
{{#if isGrave}}
<div>{{alias}} souffre de Blessure(s) Grave(s) : n'oubliez pas de faire un Je de Vie toutes les SC ({{SConst}}) minutes.</div>
{{/if}}
{{#if isCritique}}
<div>{{alias}} souffre d'une <strong>Blessure Critique</strong> : faites un <a id="chat-jet-vie" data-actorId="{{actorId}}">Jet de Vie.<a></div>
{{/if}}