forked from public/foundryvtt-reve-de-dragon
Séparation de l'Actor Entités
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { Grammar } from "./grammar.js";
|
||||
import { Misc } from "./misc.js";
|
||||
|
||||
const tableCaracDerivee = {
|
||||
const TABLE_CARACTERISTIQUES_DERIVEES = {
|
||||
// xp: coût pour passer du niveau inférieur à ce niveau
|
||||
1: { xp: 3, poids: "moins de 1kg", plusdom: -5, sconst: 0.5, sust: 0.1 },
|
||||
2: { xp: 3, poids: "1-5", plusdom: -4, sconst: 0.5, sust: 0.3 },
|
||||
@ -58,6 +58,10 @@ export class RdDCarac {
|
||||
selectedCarac?.label.match(/(Apparence|Force|Agilité|Dextérité|Vue|Ouïe|Odorat-Goût|Empathie|Dérobée|Mêlée|Tir|Lancer)/);
|
||||
}
|
||||
|
||||
static getCaracDerivee(value) {
|
||||
return TABLE_CARACTERISTIQUES_DERIVEES[Math.min(Math.max(Number(value), 1), 32)];
|
||||
}
|
||||
|
||||
static computeTotal(carac, beaute = undefined) {
|
||||
const total = Object.values(carac ?? {}).filter(c => !c.derivee)
|
||||
.map(it => parseInt(it.value))
|
||||
@ -73,7 +77,7 @@ export class RdDCarac {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static calculSConst(constitution) {
|
||||
return Number(tableCaracDerivee[Number(constitution)].sconst);
|
||||
return RdDCarac.getCaracDerivee(constitution).sconst;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -84,7 +88,7 @@ export class RdDCarac {
|
||||
}
|
||||
|
||||
static getCaracXp(targetValue) {
|
||||
return tableCaracDerivee[targetValue]?.xp ?? 200;
|
||||
return RdDCarac.getCaracDerivee(targetValue)?.xp ?? 200;
|
||||
}
|
||||
|
||||
|
||||
@ -97,37 +101,4 @@ export class RdDCarac {
|
||||
return Grammar.toLowerCaseNoAccent(selectedCarac?.label)?.match(/(apparence|force|agilite|dexterite|vue|ouie|odorat|empathie|melee|tir|lancer|derobee)/);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static computeCarac(system) {
|
||||
system.carac.force.value = Math.min(system.carac.force.value, parseInt(system.carac.taille.value) + 4);
|
||||
|
||||
system.carac.derobee.value = Math.floor(parseInt(((21 - system.carac.taille.value)) + parseInt(system.carac.agilite.value)) / 2);
|
||||
let bonusDomKey = Math.floor((parseInt(system.carac.force.value) + parseInt(system.carac.taille.value)) / 2);
|
||||
bonusDomKey = Math.min(Math.max(bonusDomKey, 0), 32); // Clamp de securite
|
||||
|
||||
let tailleData = tableCaracDerivee[bonusDomKey];
|
||||
system.attributs.plusdom.value = tailleData.plusdom;
|
||||
|
||||
system.attributs.sconst.value = RdDCarac.calculSConst(system.carac.constitution.value);
|
||||
system.attributs.sust.value = tableCaracDerivee[Number(system.carac.taille.value)].sust;
|
||||
|
||||
system.attributs.encombrement.value = (parseInt(system.carac.force.value) + parseInt(system.carac.taille.value)) / 2;
|
||||
system.carac.melee.value = Math.floor((parseInt(system.carac.force.value) + parseInt(system.carac.agilite.value)) / 2);
|
||||
system.carac.tir.value = Math.floor((parseInt(system.carac.vue.value) + parseInt(system.carac.dexterite.value)) / 2);
|
||||
system.carac.lancer.value = Math.floor((parseInt(system.carac.tir.value) + parseInt(system.carac.force.value)) / 2);
|
||||
|
||||
system.sante.vie.max = Math.ceil((parseInt(system.carac.taille.value) + parseInt(system.carac.constitution.value)) / 2);
|
||||
|
||||
system.sante.vie.value = Math.min(system.sante.vie.value, system.sante.vie.max)
|
||||
system.sante.endurance.max = Math.max(parseInt(system.carac.taille.value) + parseInt(system.carac.constitution.value), parseInt(system.sante.vie.max) + parseInt(system.carac.volonte.value));
|
||||
system.sante.endurance.value = Math.min(system.sante.endurance.value, system.sante.endurance.max);
|
||||
system.sante.fatigue.max = system.sante.endurance.max * 2;
|
||||
system.sante.fatigue.value = Math.min(system.sante.fatigue.value, system.sante.fatigue.max);
|
||||
|
||||
//Compteurs
|
||||
system.reve.reve.max = system.carac.reve.value;
|
||||
system.compteurs.chance.max = system.carac.chance.value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user