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
This commit is contained in:
Vincent Vandemeulebrouck
2021-03-05 03:42:45 +01:00
parent 2cb7647fc4
commit 3ae461bb71
110 changed files with 600 additions and 433 deletions

View File

@@ -1,4 +1,5 @@
import { Grammar } from "./grammar.js";
import { RdDUtility } from "./rdd-utility.js";
export class RdDCarac {
@@ -20,6 +21,21 @@ export class RdDCarac {
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 :