Vincent Vandemeulebrouck 3ae461bb71 Nettoyage de data
* séparation de options, calc, ...
* extraction de méthodes pour clarifier ce qui est fait dans getData
* fix de la feuille: utiliser data.data
* fix d'Actor:  update({ data.data
2021-03-05 03:42:45 +01:00

49 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Grammar } from "./grammar.js";
import { RdDUtility } from "./rdd-utility.js";
export class RdDCarac {
static isAgiliteOuDerivee(selectedCarac) {
return selectedCarac?.label.match(/(Agilité|Dérobée)/);
}
static isVolonte(selectedCarac) {
return selectedCarac?.label == 'Volonté';
}
static isChance(selectedCarac) {
return selectedCarac?.label?.toLowerCase()?.match(/chance( actuelle)?/);
}
static isReve(selectedCarac) {
return selectedCarac?.label?.toLowerCase()?.match(/r(e|ê)ve(( |-)actuel)?/);
}
static isIgnoreEtatGeneral(selectedCarac, competence) {
return !selectedCarac ||
RdDCarac.isChance(selectedCarac) ||
(RdDCarac.isReve(selectedCarac) && !competence);
}
static computeTotal(carac, beaute=undefined) {
const total = Object.values(carac).filter(c => !c.derivee)
.map(it => parseInt(it.value))
.reduce((a, b) => a + b, 0);
const beauteSuperieur10 = Math.max((beaute ?? 10) - 10, 0);
return total + beauteSuperieur10;
}
static setLevelUp(carac) {
Object.values(carac).forEach(it => {
it.xpNext = RdDUtility.getCaracNextXp(it.value);
it.isLevelUp = (it.xp >= it.xpNext);
});
}
/**
* Lappel à la chance nest possible que pour recommencer les jets dactions physiques :
* tous les jets de combat, de FORCE, dAGILITÉ, de DEXTÉRITÉ, de Dérobée, dAPPARENCE,
* ainsi que de Perception active et volontaire.
*/
static isActionPhysique(selectedCarac) {
return Grammar.toLowerCaseNoAccent(selectedCarac?.label).match(/(apparence|force|agilite|dexterite|vue|ouie|odorat|empathie|melee|tir|lancer|derobee)/);
}
}