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:
+14
-14
@@ -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)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user