Amélioration du moral

Les bon moments sont affichés en tooltips sur le moral

Simplification moralIncDec: Utilisation d'un seul update
This commit is contained in:
2026-05-01 22:28:55 +02:00
parent 6b0a6a268e
commit 9ccc068333
8 changed files with 37 additions and 19 deletions

View File

@@ -1,5 +1,9 @@
# 13.0
## 13.0.36 - Le bonheur des zyglutes d'Illisys
- Les bon moments sont affichés en tooltip sur le moral
## 13.0.36 - Les rêveries d'Illisys
- Corrections v14

View File

@@ -1174,7 +1174,7 @@ export class RdDActor extends RdDBaseActorSang {
/* -------------------------------------------- */
getSConst() { return RdDCarac.calculSConst(this.getConstitution()) }
async _gainXpConstitutionJetEndurance() {
await this.updateCaracXP('constitution', Misc.toInt(this.system.carac.constitution.xp) + 1)
return `${this.name} a obtenu 1 sur son Jet d'Endurance et a gagné 1 point d'Expérience en Constitution. Ce point d'XP a été ajouté automatiquement.`;
@@ -1214,22 +1214,22 @@ export class RdDActor extends RdDBaseActorSang {
/* -------------------------------------------- */
async moralIncDec(ajustement, bonmoment = "") {
let moral = parseInt(this.system.compteurs.moral.value)
const moral = parseInt(this.system.compteurs.moral.value);
if (ajustement != 0) {
if (ajustement > 0 && bonmoment != "" && bonmoment != undefined) {
await this.update({ 'system.compteurs.bonmoments': [...this.system.compteurs.bonmoments, bonmoment] })
}
const moralTheorique = moral + ajustement
if (moralTheorique > 3) { // exaltation
const exaltation = parseInt(this.system.compteurs.exaltation.value) + moralTheorique - 3
await this.update({ 'system.compteurs.exaltation.value': exaltation })
const newExaltation = parseInt(this.system.compteurs.exaltation.value) + Math.max(0, moralTheorique - 3)
const newDissolution = parseInt(this.system.compteurs.dissolution.value) + Math.max(0, - moralTheorique - 3)
const newMoral = Math.max(-3, Math.min(moralTheorique, 3))
const moralUpdates = {
'system.compteurs.exaltation.value': newExaltation,
'system.compteurs.dissolution.value': newDissolution,
'system.compteurs.moral.value': newMoral
}
if (moralTheorique < -3) { // dissolution
const dissolution = parseInt(this.system.compteurs.dissolution.value) - 3 - moralTheorique
await this.update({ 'system.compteurs.dissolution.value': dissolution })
if (ajustement > 0 && bonmoment != "" && bonmoment != undefined && !this.system.compteurs.bonmoments.includes(bonmoment)) {
moralUpdates['system.compteurs.bonmoments'] = [...this.system.compteurs.bonmoments, bonmoment]
}
moral = Math.max(-3, Math.min(moralTheorique, 3));
await this.update({ 'system.compteurs.moral.value': moral })
await this.update(moralUpdates)
return newMoral
}
return moral
}
@@ -1571,7 +1571,7 @@ export class RdDActor extends RdDBaseActorSang {
/* -------------------------------------------- */
async checkCompetenceXP(compName, newXP, display = true) {
return this.getCompetence(compName)?.checkCompetenceXP( newXP, display)
return this.getCompetence(compName)?.checkCompetenceXP(newXP, display)
}
/* -------------------------------------------- */

View File

@@ -132,9 +132,9 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/actor/carac-derivee.hbs',
'systems/foundryvtt-reve-de-dragon/templates/actor/carac-creature.hbs',
'systems/foundryvtt-reve-de-dragon/templates/actor/carac-entitee.hbs',
'systems/foundryvtt-reve-de-dragon/templates/actor/carac-total.hbs',
'systems/foundryvtt-reve-de-dragon/templates/actor/comp-creature.hbs',
'systems/foundryvtt-reve-de-dragon/templates/actor/comp-possession.hbs',
'systems/foundryvtt-reve-de-dragon/templates/actor/carac-total.hbs',
'systems/foundryvtt-reve-de-dragon/templates/actor/competence.hbs',
'systems/foundryvtt-reve-de-dragon/templates/actor/competence-categorie.hbs',
'systems/foundryvtt-reve-de-dragon/templates/actor/xp-competences.hbs',
@@ -173,6 +173,7 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/actor/liens-vehicules.hbs',
'systems/foundryvtt-reve-de-dragon/templates/actor/commerce-inventaire.hbs',
'systems/foundryvtt-reve-de-dragon/templates/actor/commerce-inventaire-item.hbs',
'systems/foundryvtt-reve-de-dragon/templates/actor/tooltip-bonmoments.hbs',
//Items
'systems/foundryvtt-reve-de-dragon/templates/scripts/autocomplete-script.hbs',
'systems/foundryvtt-reve-de-dragon/templates/scripts/autocomplete.hbs',
@@ -300,6 +301,7 @@ export class RdDUtility {
Handlebars.registerHelper('grammar-un', str => Grammar.articleIndetermine(str));
Handlebars.registerHelper('grammar-accord', (genre, ...args) => Grammar.accord(genre, args));
Handlebars.registerHelper('json-stringify', object => JSON.stringify(object))
Handlebars.registerHelper('escapeHtml', object => foundry.utils.escapeHTML(object))
// math
Handlebars.registerHelper('math-sum', (...values) => values.slice(0, -1).reduce(Misc.sum(), 0))

View File

@@ -21,7 +21,7 @@
</li>
<br>
<li class="caracteristique flexrow list-item">
<label>{{system.compteurs.moral.label}}
<label data-tooltip-html="{{> "systems/foundryvtt-reve-de-dragon/templates/actor/tooltip-bonmoments.hbs"}}">{{system.compteurs.moral.label}}
<span>
<a class="flex-shrink moral-malheureux" data-tooltip="Jet de moral situation malheureuse"><i class="fa-regular fa-face-frown"></i></a>
<a class="flex-shrink moral-neutre" data-tooltip="Jet de moral situation neutre"><i class="fa-regular fa-face-meh"></i></a>

View File

@@ -0,0 +1,10 @@
<div class=&quot;toolclip themed theme-dark&quot;>
<p><b>Bon moments du jour</b></p>
{{#if system.compteurs.bonmoments}}
{{#each system.compteurs.bonmoments as |bonmoment|}}
<p>{{bonmoment}}</p>
{{/each}}
{{else}}
<p>Rien de notable</p>
{{/if}}
</div>

View File

@@ -1,4 +1,3 @@
{{log this}}
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" data-tooltip="{{name}}"/>

View File

@@ -1,4 +1,8 @@
{{#if (gt result.qualite 0)}}
{{#if (eq result.appreciation.moral '')}}
<span>L'&oelig;uvre n'est pas prévue pour gagner du moral</span>
{{else if (lte result.qualite 0)}}
<span>Qualité de {{result.qualite}}, pas d'appréciation</span>
{{else}}
<a class='chat-card-button apprecier' data-tooltip="Aprécier">
<i class="fa-solid fa-face-smile-beam"></i>&nbsp; Apprécier
</a>

View File

@@ -26,7 +26,6 @@
{{/if}}
<div>
<span>{{rolled.roll}} : </span><span class="rdd-roll-{{rolled.code}} strong-text">{{rolled.quality}}</span>
{{log 'rolled' rolled}}
{{#if (regle-optionnelle 'afficher-colonnes-reussite')}}
<span class="rdd-niveau-requis">(Réussite colonne {{plusMoins rolled.niveauNecessaire}} / avec ajustement {{plusMoins rolled.ajustementNecessaire}}) </span>
{{/if}}