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 23:20:58 +02:00
parent 6b0a6a268e
commit 9ccc068333
8 changed files with 37 additions and 19 deletions
+14 -14
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)
}
/* -------------------------------------------- */