Construction du message de jet de constitution par template hbs
This commit is contained in:
Vincent Vandemeulebrouck 2022-12-07 14:21:48 +01:00
parent e652027b02
commit f02959adee
4 changed files with 19 additions and 15 deletions

View File

@ -590,11 +590,14 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
async _jetRecuperationConstitution(bonusSoins, message = undefined) {
const tData = this.system;
let difficulte = Misc.toInt(bonusSoins) + Math.min(0, tData.sante.vie.value - tData.sante.vie.max);
let rolled = await RdDResolutionTable.roll(tData.carac.constitution.value, difficulte);
let difficulte = Misc.toInt(bonusSoins) + Math.min(0, this.system.sante.vie.value - this.system.sante.vie.max);
let rolled = await RdDResolutionTable.roll(this.system.carac.constitution.value, difficulte);
if (message) {
message.content += RdDResolutionTable.explain(rolled).replace(/Jet :/, "Constitution :");
message.content = await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/roll/explain.hbs", {
actor: this,
carac: this.system.carac.constitution,
rolled
})
}
return rolled;
}

View File

@ -89,17 +89,6 @@ export class RdDResolutionTable {
return resultat;
}
/* -------------------------------------------- */
static explain(rolled) {
let message = "<br>Jet : <strong>" + rolled.roll + "</strong> sur " + rolled.score + "% ";
if (rolled.caracValue != undefined && rolled.finalLevel != undefined) {
message += (rolled.diviseurSignificative > 1 ? `(1/${rolled.diviseurSignificative} de ` : "(")
+ rolled.caracValue + " à " + Misc.toSignedString(rolled.finalLevel) + ") ";
}
message += '<strong>' + rolled.quality + '</strong>'
return message;
}
/* -------------------------------------------- */
static async displayRollData(rollData, actor = undefined, template = 'chat-resultat-general.html') {
return await ChatUtility.createChatWithRollMode(actor?.userName ?? game.user.name, {

View File

@ -238,6 +238,7 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/partial-item-hautrevant.html',
'systems/foundryvtt-reve-de-dragon/templates/partial-item-frequence.html',
'systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html',
'systems/foundryvtt-reve-de-dragon/templates/roll/explain.hbs',
'systems/foundryvtt-reve-de-dragon/templates/resolution-table.html',
// Dialogs
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-resolution.html',

View File

@ -0,0 +1,11 @@
<img class="chat-icon" src="{{actor.img}}" title="{{actor.name}}" alt="{{actor.name}}" />
<p>Jet de {{carac.label}} à {{rolled.finalLevel}}:
<strong>
{{rolled.roll}}
</strong> sur {{rolled.score}}%
{{#if (and rolled.caracValue rolled.finalLevel)}}
({{#if (gt rolled.diviseurSignificative 1)}}1/{{rolled.diviseurSignificative}}{{/if}}
de {{rolled.caracValue}} à {{numberFormat rolled.finalLevel decimals=0 sign=true}})
{{/if}}
<strong>{{rolled.quality}}</strong>
</p>