Fix: éliminer le risque de jets qui plante

Bloquait les rencontres en TMR.

Quand un rollData ne contient pas les sous-noeuds pouvant être
utilisés par les ajustements possibles, le jet de dés était perdu.

Le calcul d'ajustements ajoute maintenant les noeuds use/ajustements
s'ils ne sont pas fournis, pour éviter le risque.
This commit is contained in:
Vincent Vandemeulebrouck 2023-12-08 02:37:47 +01:00
parent b5dc14687e
commit 095eed9da3

View File

@ -64,19 +64,19 @@ export const referenceAjustements = {
},
encTotal: {
isVisible: (rollData, actor) => RdDCarac.isAgiliteOuDerobee(rollData.selectedCarac) && RdDItemCompetence.isMalusEncombrementTotal(rollData.competence),
isUsed: (rollData, actor) => !rollData.oeuvre && RdDCarac.isAgiliteOuDerobee(rollData.selectedCarac) && RdDItemCompetence.isMalusEncombrementTotal(rollData.competence) && rollData.use.encTotal,
isUsed: (rollData, actor) => !rollData.oeuvre && RdDCarac.isAgiliteOuDerobee(rollData.selectedCarac) && RdDItemCompetence.isMalusEncombrementTotal(rollData.competence) && rollData.use?.encTotal,
getLabel: (rollData, actor) => 'Encombrement total',
getValue: (rollData, actor) => -actor.getEncTotal()
},
surenc: {
isVisible: (rollData, actor) => RdDCarac.isActionPhysique(rollData.selectedCarac) && actor.isSurenc(),
isUsed: (rollData, actor) => rollData.use?.surenc && RdDCarac.isActionPhysique(rollData.selectedCarac),
isUsed: (rollData, actor) => rollData.use.surenc && RdDCarac.isActionPhysique(rollData.selectedCarac),
getLabel: (rollData, actor) => 'Sur-encombrement',
getValue: (rollData, actor) => actor.computeMalusSurEncombrement()
},
moral: {
isVisible: (rollData, actor) => actor.isPersonnage() && RdDCarac.isActionPhysique(rollData.selectedCarac) && rollData.use?.moral,
isUsed: (rollData, actor) => rollData.use?.moral,
isUsed: (rollData, actor) => rollData.use.moral,
getLabel: (rollData, actor) => 'Appel au moral',
getValue: (rollData, actor) => 1
},
@ -84,7 +84,7 @@ export const referenceAjustements = {
isVisible: (rollData, actor) => actor.isPersonnage() && RdDCarac.isVolonte(rollData.selectedCarac),
isUsed: (rollData, actor) => rollData.use.coeur != undefined,
getLabel: (rollData, actor) => 'Ajustement de cœur',
getValue: (rollData, actor) => -2 * (rollData.use.coeur?.coeur ?? 0)
getValue: (rollData, actor) => -2 * (rollData.use?.coeur?.coeur ?? 0)
},
moralTotal: {
isUsed: (rollData, actor) => RdDCarac.isVolonte(rollData.selectedCarac),
@ -141,7 +141,7 @@ export const referenceAjustements = {
getLabel: (rollData, actor) => "Force de l'alcool: ",
getValue: (rollData, actor) => rollData.forceAlcool,
},
ethylisme:{
ethylisme: {
isVisible: (rollData, actor) => rollData.ethylisme != undefined,
isUsed: (rollData, actor) => rollData.ethylisme != undefined,
getLabel: (rollData, actor) => "Ethylisme - " + RdDUtility.getNomEthylisme(rollData.ethylisme),
@ -159,7 +159,9 @@ export class RollDataAjustements {
/* -------------------------------------------- */
static calcul(rollData, actor) {
rollData.ajustements = {};
// s'assurer de la correction des infos rollData
mergeObject(rollData, { ajustements: {}, use: {} }, { overwrite: false })
for (var key in referenceAjustements) {
const reference = referenceAjustements[key];
rollData.ajustements[key] = {