2021-02-09 23:23:40 +01:00
|
|
|
|
import { Grammar } from "./grammar.js";
|
2021-03-05 03:42:45 +01:00
|
|
|
|
import { RdDUtility } from "./rdd-utility.js";
|
2021-02-09 23:23:40 +01:00
|
|
|
|
|
2021-01-05 18:43:13 +01:00
|
|
|
|
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)?/);
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-13 17:30:44 +01:00
|
|
|
|
static isIgnoreEtatGeneral(selectedCarac, competence) {
|
2021-01-05 18:43:13 +01:00
|
|
|
|
return !selectedCarac ||
|
|
|
|
|
RdDCarac.isChance(selectedCarac) ||
|
2021-01-13 17:30:44 +01:00
|
|
|
|
(RdDCarac.isReve(selectedCarac) && !competence);
|
2021-01-05 18:43:13 +01:00
|
|
|
|
}
|
2021-03-05 03:42:45 +01:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-01-05 18:43:13 +01:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* L’appel à la chance n’est possible que pour recommencer les jets d’actions physiques :
|
|
|
|
|
* tous les jets de combat, de FORCE, d’AGILITÉ, de DEXTÉRITÉ, de Dérobée, d’APPARENCE,
|
|
|
|
|
* ainsi que de Perception active et volontaire.
|
|
|
|
|
*/
|
|
|
|
|
static isActionPhysique(selectedCarac) {
|
2021-02-09 23:23:40 +01:00
|
|
|
|
return Grammar.toLowerCaseNoAccent(selectedCarac?.label).match(/(apparence|force|agilite|dexterite|vue|ouie|odorat|empathie|melee|tir|lancer|derobee)/);
|
2021-01-05 18:43:13 +01:00
|
|
|
|
}
|
2021-02-09 23:23:40 +01:00
|
|
|
|
}
|