2024-09-25 23:03:05 +02:00
|
|
|
import { Grammar } from "../../grammar.js"
|
|
|
|
import { RdDItemArme } from "../../item-arme.js"
|
|
|
|
import { RdDItemCompetence } from "../../item-competence.js"
|
|
|
|
import { RdDItemSort } from "../../item-sort.js"
|
|
|
|
import { ITEM_TYPES } from "../../item.js"
|
|
|
|
import { Misc } from "../../misc.js"
|
|
|
|
import { RdDTimestamp } from "../../time/rdd-timestamp.js"
|
2024-09-27 02:35:02 +02:00
|
|
|
import { RdDBonus } from "../../rdd-bonus.js"
|
2024-10-05 00:37:55 +02:00
|
|
|
import { TMRType } from "../../tmr-utility.js"
|
2024-09-27 02:35:02 +02:00
|
|
|
|
2024-09-25 23:03:05 +02:00
|
|
|
|
2024-10-05 12:41:28 +02:00
|
|
|
export const CATEGORIES_COMPETENCES = [
|
2024-09-25 23:03:05 +02:00
|
|
|
"generale",
|
|
|
|
"particuliere",
|
|
|
|
"specialisee",
|
|
|
|
"connaissance",
|
|
|
|
]
|
2024-10-05 12:41:28 +02:00
|
|
|
export const CATEGORIES_DRACONIC = [
|
2024-09-25 23:03:05 +02:00
|
|
|
"draconic",
|
|
|
|
]
|
|
|
|
|
|
|
|
const CATEGORIES_COMBAT = [
|
|
|
|
"melee",
|
|
|
|
"tir",
|
|
|
|
"lancer"
|
|
|
|
]
|
|
|
|
|
|
|
|
const NIVEAU_BASE = {
|
|
|
|
"generale": -4,
|
|
|
|
"particuliere": -8,
|
|
|
|
"specialisee": -11,
|
|
|
|
"connaissance": -11,
|
|
|
|
"draconic": -11,
|
|
|
|
"melee": -6,
|
|
|
|
"tir": -8,
|
|
|
|
"lancer": -8,
|
|
|
|
}
|
|
|
|
|
|
|
|
class ColumnMappingFactory {
|
|
|
|
static createMappingArme(part, i) {
|
2024-10-05 00:37:55 +02:00
|
|
|
return { column: `arme_${part}_${i}`, getter: (actor, context) => Mapping.getArme(actor, context, part, i) }
|
2024-09-25 23:03:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static createMappingSort(part, i) {
|
2024-10-05 00:37:55 +02:00
|
|
|
return { column: `sort_${part}_${i}`, getter: (actor, context) => Mapping.getSort(actor, context, part, i) }
|
2024-09-25 23:03:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const NB_ARMES = 10
|
|
|
|
const NB_SORTS = 20
|
|
|
|
const TABLEAU_ARMES = [...Array(NB_ARMES).keys()]
|
|
|
|
const TABLEAU_SORTS = [...Array(NB_SORTS).keys()]
|
|
|
|
|
|
|
|
const MAPPING_BASE = [
|
2024-10-05 00:37:55 +02:00
|
|
|
{ column: "ID", colName: 'ID', getter: (actor, context) => actor.id },
|
2024-09-25 23:03:05 +02:00
|
|
|
{ column: "name", getter: (actor, context) => actor.name },
|
2024-10-05 00:37:55 +02:00
|
|
|
{ column: "metier", colName: 'Métier', getter: (actor, context) => actor.system.metier },
|
|
|
|
{ column: "biographie", colName: 'Biographie', getter: (actor, context) => actor.system.biographie },
|
2024-09-25 23:03:05 +02:00
|
|
|
{ column: "taille", getter: (actor, context) => actor.system.carac.taille.value },
|
2024-10-05 15:13:29 +02:00
|
|
|
{ column: "apparence", rollClass: 'roll-carac', getter: (actor, context) => actor.system.carac.apparence.value },
|
|
|
|
{ column: "constitution", rollClass: 'roll-carac', getter: (actor, context) => actor.system.carac.constitution.value },
|
|
|
|
{ column: "force", rollClass: 'roll-carac', getter: (actor, context) => actor.system.carac.force.value },
|
|
|
|
{ column: "agilite", rollClass: 'roll-carac', colName: 'Agilité', getter: (actor, context) => actor.system.carac.agilite.value },
|
|
|
|
{ column: "dexterite", rollClass: 'roll-carac', colName: 'Dextérité', getter: (actor, context) => actor.system.carac.dexterite.value },
|
|
|
|
{ column: "vue", rollClass: 'roll-carac', getter: (actor, context) => actor.system.carac.vue.value },
|
|
|
|
{ column: "ouie", rollClass: 'roll-carac', colName: 'Ouïe', getter: (actor, context) => actor.system.carac.ouie.value },
|
|
|
|
{ column: "odoratgout", rollClass: 'roll-carac', colName: 'Odo-goût', getter: (actor, context) => actor.system.carac.odoratgout.value },
|
|
|
|
{ column: "volonte", rollClass: 'roll-carac', colName: 'Volonté', getter: (actor, context) => actor.system.carac.volonte.value },
|
|
|
|
{ column: "intellect", rollClass: 'roll-carac', getter: (actor, context) => actor.system.carac.intellect.value },
|
|
|
|
{ column: "empathie", rollClass: 'roll-carac', getter: (actor, context) => actor.system.carac.empathie.value },
|
|
|
|
{ column: "reve", rollClass: 'roll-carac', colName: 'Rêve', getter: (actor, context) => actor.system.carac.reve.value },
|
|
|
|
{ column: "chance", rollClass: 'roll-carac', getter: (actor, context) => actor.system.carac.chance.value },
|
|
|
|
{ column: "melee", rollClass: 'roll-carac', colName: 'Mêlée', getter: (actor, context) => actor.system.carac.melee.value },
|
|
|
|
{ column: "tir", rollClass: 'roll-carac', getter: (actor, context) => actor.system.carac.tir.value },
|
|
|
|
{ column: "lancer", rollClass: 'roll-carac', getter: (actor, context) => actor.system.carac.lancer.value },
|
|
|
|
{ column: "derobee", rollClass: 'roll-carac', colName: 'Dérobée', getter: (actor, context) => actor.system.carac.derobee.value },
|
2024-09-25 23:03:05 +02:00
|
|
|
{ column: "vie", getter: (actor, context) => actor.system.sante.vie.max },
|
2024-10-05 15:13:29 +02:00
|
|
|
{ column: "endurance", getter: (actor, context) => actor.system.sante.endurance.max },
|
2024-12-04 15:55:09 +01:00
|
|
|
{ column: "plusdom", colName: '+dom', getter: (actor, context) => actor.getBonusDegat() },
|
2024-10-05 00:37:55 +02:00
|
|
|
{ column: "protectionnaturelle", colName: 'Protection naturelle', getter: (actor, context) => actor.system.attributs.protection.value > 0 ? actor.system.attributs.protection.value : '' },
|
2024-09-25 23:03:05 +02:00
|
|
|
{ column: "description", getter: (actor, context) => Mapping.getDescription(actor) },
|
|
|
|
{ column: "armure", getter: (actor, context) => Mapping.getArmure(actor, context) },
|
2024-10-05 12:57:02 +02:00
|
|
|
{ column: "protectionarmure", colName: 'Protection', getter: (actor, context) => Mapping.getProtectionArmure(actor, context) },
|
2024-10-05 00:37:55 +02:00
|
|
|
{ column: "malus_armure", getter: (actor, context) => Mapping.getMalusArmure(actor, context) },
|
2024-10-05 15:13:29 +02:00
|
|
|
{ column: "reve_actuel", rollClass: 'roll-reve-actuel', colName: 'Rêve actuel', getter: (actor, context) => actor.system.reve.reve.value },
|
2024-12-14 00:33:31 +01:00
|
|
|
{ column: "chance_actuel", rollClass: 'roll-chance-actuelle', colName: 'Chance actuelle', getter: (actor, context) => actor.system.compteurs.chance.value },
|
2024-10-05 15:13:29 +02:00
|
|
|
{ column: "vie_actuel", rollClass: 'jet-vie', getter: (actor, context) => actor.system.sante.vie.value },
|
2024-11-03 22:00:06 +01:00
|
|
|
{ column: "endurance_actuel", rollClass: 'jet-endurance', getter: (actor, context) => actor.system.sante.endurance.value },
|
2024-09-28 17:45:31 +02:00
|
|
|
{ column: "esquive", getter: (actor, context) => Mapping.getEsquive(context) },
|
2024-10-05 00:37:55 +02:00
|
|
|
{ column: "esquive_armure", getter: (actor, context) => Mapping.getEsquiveArmure(context) },
|
2024-09-25 23:03:05 +02:00
|
|
|
{ column: "competences", getter: (actor, context) => Mapping.getCompetences(actor, CATEGORIES_COMPETENCES) },
|
2024-10-05 15:13:29 +02:00
|
|
|
{ column: "draconic", getter: (actor, context) => Mapping.getCompetences(actor, CATEGORIES_DRACONIC) },
|
2024-09-25 23:03:05 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
const MAPPING_ARMES = TABLEAU_ARMES.map(i => ColumnMappingFactory.createMappingArme('name', i))
|
|
|
|
.concat(TABLEAU_ARMES.map(i => ColumnMappingFactory.createMappingArme('niveau', i)))
|
|
|
|
.concat(TABLEAU_ARMES.map(i => ColumnMappingFactory.createMappingArme('init', i)))
|
2024-09-27 02:35:02 +02:00
|
|
|
.concat(TABLEAU_ARMES.map(i => ColumnMappingFactory.createMappingArme('dommages', i)))
|
2024-09-25 23:03:05 +02:00
|
|
|
const MAPPING_SORTS = TABLEAU_SORTS.map(i => ColumnMappingFactory.createMappingSort('voie', i))
|
|
|
|
.concat(TABLEAU_SORTS.map(i => ColumnMappingFactory.createMappingSort('description', i)))
|
|
|
|
.concat(TABLEAU_SORTS.map(i => ColumnMappingFactory.createMappingSort('bonus', i)))
|
|
|
|
const MAPPING = MAPPING_BASE
|
|
|
|
.concat(MAPPING_ARMES)
|
|
|
|
.concat(MAPPING_SORTS)
|
|
|
|
|
|
|
|
export class Mapping {
|
|
|
|
|
|
|
|
static getMapping() {
|
|
|
|
return MAPPING
|
|
|
|
}
|
|
|
|
|
2024-10-05 00:37:55 +02:00
|
|
|
static getColumns() {
|
|
|
|
return MAPPING.map(it => it.column)
|
|
|
|
}
|
|
|
|
|
|
|
|
static getValues(actor) {
|
|
|
|
const context = Mapping.prepareContext(actor)
|
|
|
|
return MAPPING.map(it => it.getter(actor, context))
|
|
|
|
}
|
|
|
|
static getAsObject(actor) {
|
|
|
|
const context = Mapping.prepareContext(actor)
|
|
|
|
return Object.fromEntries(MAPPING.map(it => [it.column, {
|
|
|
|
colName: it.colName ?? it.column,
|
|
|
|
value: it.getter(actor, context)
|
|
|
|
}]))
|
|
|
|
}
|
|
|
|
|
|
|
|
static getValues(actor) {
|
|
|
|
const context = Mapping.prepareContext(actor)
|
|
|
|
return MAPPING.map(it => it.getter(actor, context))
|
|
|
|
}
|
|
|
|
|
2024-09-25 23:03:05 +02:00
|
|
|
static prepareContext(actor) {
|
|
|
|
return {
|
|
|
|
armes: Mapping.prepareArmes(actor),
|
|
|
|
armure: Mapping.prepareArmure(actor),
|
|
|
|
esquive: Mapping.prepareEsquive(actor),
|
|
|
|
sorts: Mapping.prepareSorts(actor)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static prepareArmes(actor) {
|
2024-09-27 02:35:02 +02:00
|
|
|
const armes = actor.items.filter(it => it.type == ITEM_TYPES.arme)
|
2024-11-26 23:23:34 +01:00
|
|
|
armes.push(RdDItemArme.corpsACorps(actor));
|
|
|
|
armes.push(RdDItemArme.empoignade(actor));
|
2024-10-27 00:02:03 +02:00
|
|
|
return armes.map(arme => [
|
|
|
|
arme.system.unemain ? Mapping.prepareArme(actor, arme, 'unemain') : undefined,
|
|
|
|
arme.system.deuxmains ? Mapping.prepareArme(actor, arme, 'deuxmains') : undefined,
|
|
|
|
!(arme.system.unemain || arme.system.deuxmains) ? Mapping.prepareArme(actor, arme, 'competence') : undefined,
|
|
|
|
arme.system.lancer != "" ? Mapping.prepareArme(actor, arme, 'lancer') : undefined,
|
|
|
|
arme.system.tir != "" ? Mapping.prepareArme(actor, arme, 'tir') : undefined]
|
|
|
|
.filter(it => it != undefined))
|
|
|
|
.reduce((a, b) => a.concat(b), [])
|
2024-09-25 23:03:05 +02:00
|
|
|
}
|
|
|
|
|
2024-09-27 02:35:02 +02:00
|
|
|
static prepareArme(actor, arme, maniement) {
|
2024-11-06 23:24:53 +01:00
|
|
|
const nameCompetenceArme = RdDItemArme.getCompetenceArme(arme, maniement)
|
|
|
|
const competence = actor.getCompetence(nameCompetenceArme)
|
2024-09-27 02:35:02 +02:00
|
|
|
if (RdDItemCompetence.isNiveauBase(competence)) {
|
|
|
|
return undefined
|
|
|
|
}
|
2024-10-11 01:16:22 +02:00
|
|
|
const categorie = Mapping.complementCategorie(arme, maniement)
|
2024-10-27 00:02:03 +02:00
|
|
|
const dommages = Mapping.dommagesArme(actor, arme, maniement)
|
2024-09-27 02:35:02 +02:00
|
|
|
return {
|
2024-10-11 01:16:22 +02:00
|
|
|
name: arme.name + categorie,
|
2024-09-27 02:35:02 +02:00
|
|
|
niveau: Misc.toSignedString(competence.system.niveau),
|
|
|
|
init: Mapping.calculBaseInit(actor, competence.system.categorie) + competence.system.niveau,
|
2024-10-27 00:02:03 +02:00
|
|
|
dommages: dommages,
|
2024-10-11 01:16:22 +02:00
|
|
|
competence: competence,
|
|
|
|
arme: arme
|
2024-09-27 02:35:02 +02:00
|
|
|
}
|
2024-09-25 23:03:05 +02:00
|
|
|
}
|
2024-12-04 00:23:54 +01:00
|
|
|
static dommagesArme(actor, arme, maniement) {
|
2024-10-27 00:02:03 +02:00
|
|
|
const dmgArme = RdDItemArme.dommagesReels(arme, maniement)
|
|
|
|
const dommages = Misc.toSignedString(dmgArme + RdDBonus.bonusDmg(actor, maniement, dmgArme))
|
2024-12-04 00:23:54 +01:00
|
|
|
switch (arme.system.mortalite) {
|
2024-10-27 00:02:03 +02:00
|
|
|
case 'non-mortel': return `(${dommages})`
|
|
|
|
case 'empoignade': return '-'
|
|
|
|
}
|
|
|
|
return dommages
|
|
|
|
}
|
2024-09-25 23:03:05 +02:00
|
|
|
|
2024-10-11 01:16:22 +02:00
|
|
|
static complementCategorie(arme, maniement) {
|
|
|
|
switch (maniement) {
|
2024-10-27 00:02:03 +02:00
|
|
|
case 'unemain': return (arme.system.deuxmains) ? ' 1 main' : (arme.system.lancer || arme.system.tir) ? ' mêlée' : ''
|
|
|
|
case 'deuxmains': return (arme.system.unemain) ? ' 2 mains' : (arme.system.lancer || arme.system.tir) ? ' mêlée' : ''
|
2024-10-11 01:16:22 +02:00
|
|
|
case 'lancer': return (arme.system.unemain || arme.system.deuxmains || arme.system.tir) ? ' jet' : ''
|
|
|
|
case 'tir': return (arme.system.unemain || arme.system.deuxmains || arme.system.lancer) ? ' tir' : ''
|
|
|
|
}
|
2024-10-27 00:02:03 +02:00
|
|
|
return ''
|
2024-10-11 01:16:22 +02:00
|
|
|
}
|
|
|
|
|
2024-09-25 23:03:05 +02:00
|
|
|
static calculBaseInit(actor, categorie) {
|
|
|
|
const mapping = MAPPING_BASE.find(it => it.column == categorie)
|
|
|
|
if (mapping) {
|
|
|
|
switch (categorie) {
|
|
|
|
case 'melee':
|
|
|
|
case 'tir':
|
|
|
|
case 'lancer':
|
|
|
|
const caracteristique = Number(actor.system.carac[categorie].value)
|
|
|
|
return Math.floor(caracteristique / 2)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
static prepareArmure(actor) {
|
|
|
|
const armures = actor.itemTypes[ITEM_TYPES.armure].filter(it => it.system.equipe)
|
|
|
|
if (armures.length > 1) {
|
|
|
|
console.warn(`${actor.name} a équipé ${armures.length} armures, seule la première sera considérée`)
|
|
|
|
}
|
|
|
|
if (armures.length > 0) {
|
|
|
|
const armure = armures[0]
|
|
|
|
return {
|
|
|
|
name: armure.name,
|
|
|
|
protection: armure.system.protection,
|
|
|
|
malus: armure.system.malus ?? 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
name: '',
|
|
|
|
protection: actor.system.attributs.protection.value,
|
|
|
|
malus: 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static prepareEsquive(actor) {
|
|
|
|
const esquives = actor.getCompetences("Esquive")
|
|
|
|
if (esquives.length > 0) {
|
|
|
|
const esquive = esquives[0]
|
|
|
|
return {
|
|
|
|
name: esquive.name,
|
2024-10-11 01:30:43 +02:00
|
|
|
niveau: esquive.system.niveau,
|
|
|
|
competence: esquive
|
2024-09-25 23:03:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return undefined
|
|
|
|
}
|
|
|
|
|
|
|
|
static prepareSorts(actor) {
|
2024-10-05 15:13:29 +02:00
|
|
|
const codeVoies = Mapping.getCompetencesCategorie(actor, CATEGORIES_DRACONIC)
|
2024-11-29 23:32:21 +01:00
|
|
|
.map(it => RdDItemSort.getCodeVoie(it.name))
|
2024-10-05 00:37:55 +02:00
|
|
|
|
|
|
|
return actor.itemTypes[ITEM_TYPES.sort].map(it => Mapping.prepareSort(it, codeVoies))
|
|
|
|
.sort(Misc.ascending(it => `${it.voie} : ${it.description}`))
|
2024-09-27 02:35:02 +02:00
|
|
|
}
|
|
|
|
|
2024-10-05 00:37:55 +02:00
|
|
|
static prepareSort(sort, voies) {
|
2024-09-27 02:35:02 +02:00
|
|
|
return {
|
2024-11-29 23:32:21 +01:00
|
|
|
voie: RdDItemSort.getCode(sort, voies),
|
2024-09-27 02:35:02 +02:00
|
|
|
description: Mapping.descriptionSort(sort),
|
|
|
|
bonus: Mapping.bonusCase(sort)
|
|
|
|
}
|
2024-09-25 23:03:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static descriptionSort(sort) {
|
|
|
|
const ptSeuil = Array(sort.system.coutseuil).map(it => '*')
|
2024-10-05 00:37:55 +02:00
|
|
|
const caseTMR = sort.system.caseTMRspeciale.length > 0 ? Mapping.toVar(sort.system.caseTMRspeciale) : Misc.upperFirst(TMRType[sort.system.caseTMR].name)
|
2024-11-29 23:32:21 +01:00
|
|
|
const coutReve = 'r' + RdDItemSort.addSpaceToNonNumeric(sort.system.ptreve)
|
|
|
|
const diff = 'R' + RdDItemSort.addSpaceToNonNumeric(sort.system.difficulte)
|
|
|
|
return `${sort.name}${ptSeuil} (${caseTMR}) ${diff} ${coutReve}`
|
2024-09-25 23:03:05 +02:00
|
|
|
}
|
2024-12-04 00:23:54 +01:00
|
|
|
static toVar(caseSpeciale) {
|
|
|
|
return Grammar.toLowerCaseNoAccent(caseSpeciale).startsWith('var') ? 'var' : caseSpeciale
|
|
|
|
}
|
2024-09-25 23:03:05 +02:00
|
|
|
|
|
|
|
static bonusCase(sort) {
|
2024-11-28 00:38:34 +01:00
|
|
|
const list = RdDItemSort.stringToBonuscases(sort.system.bonuscase).sort(Misc.descending(it => it.bonus))
|
2024-09-25 23:03:05 +02:00
|
|
|
if (list.length > 0) {
|
|
|
|
const bonus = list[0]
|
|
|
|
return `+${bonus.bonus}% en ${bonus.case}`
|
|
|
|
}
|
2024-09-27 02:35:02 +02:00
|
|
|
return ''
|
2024-09-25 23:03:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static getDescription(actor) {
|
|
|
|
const sexe = actor.system.sexe
|
|
|
|
const sexeFeminin = sexe.length > 0 && sexe.charAt(0).toLowerCase() == 'f' ? 'Née' : 'Né'
|
|
|
|
const race = ['', 'humain'].includes(Grammar.toLowerCaseNoAccent(actor.system.race)) ? '' : (actor.system.race + ' ')
|
|
|
|
const heure = actor.system.heure
|
|
|
|
const hn = `${sexeFeminin} à l'heure ${RdDTimestamp.definition(heure).avecArticle}`
|
2024-12-18 17:28:50 +01:00
|
|
|
const age = (actor.system.age && actor.system.age >0) ? `${actor.system.age} ans` : undefined
|
2024-09-25 23:03:05 +02:00
|
|
|
const taille = actor.system.taille
|
|
|
|
const poids = actor.system.poids
|
|
|
|
const cheveux = actor.system.cheveux ? `cheveux ${actor.system.cheveux}` : undefined
|
|
|
|
const yeux = actor.system.yeux ? `yeux ${actor.system.yeux}` : undefined
|
2024-10-05 15:13:29 +02:00
|
|
|
const beaute = actor.system.beaute ? `beauté ${actor.system.beaute}` : undefined
|
2024-09-25 23:03:05 +02:00
|
|
|
const list = [race, hn, age, taille, poids, cheveux, yeux, beaute]
|
|
|
|
return Misc.join(list.filter(it => it), ', ')
|
|
|
|
}
|
|
|
|
|
|
|
|
static getArmure(actor, context) {
|
|
|
|
return context.armure?.name ?? ''
|
|
|
|
}
|
|
|
|
|
|
|
|
static getProtectionArmure(actor, context) {
|
2024-10-05 12:57:02 +02:00
|
|
|
const naturelle = Number(actor.system.attributs.protection.value)
|
2024-10-05 00:37:55 +02:00
|
|
|
if (context?.armure?.protection == undefined) {
|
2024-10-05 12:57:02 +02:00
|
|
|
return naturelle
|
2024-10-05 00:37:55 +02:00
|
|
|
}
|
|
|
|
if (Number.isNumeric(context?.armure?.protection)) {
|
2024-10-05 12:57:02 +02:00
|
|
|
return Number(context?.armure?.protection ?? 0) + naturelle
|
2024-10-05 00:37:55 +02:00
|
|
|
}
|
2024-10-05 12:57:02 +02:00
|
|
|
return context?.armure.protection + (naturelle > 0 ? `+${naturelle}` : '')
|
2024-09-25 23:03:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static getMalusArmure(actor, context) {
|
|
|
|
return context?.armure?.malus ?? 0
|
|
|
|
}
|
|
|
|
|
2024-09-28 17:45:31 +02:00
|
|
|
static getEsquive(context) {
|
|
|
|
if (context.esquive) {
|
|
|
|
return Misc.toSignedString(context.esquive.niveau)
|
|
|
|
}
|
|
|
|
return ''
|
|
|
|
}
|
|
|
|
static getEsquiveArmure(context) {
|
2024-09-25 23:03:05 +02:00
|
|
|
if (context.esquive) {
|
|
|
|
const niveau = context.esquive.niveau + context.armure.malus
|
2024-09-28 17:45:31 +02:00
|
|
|
return Misc.toSignedString(niveau)
|
2024-09-25 23:03:05 +02:00
|
|
|
}
|
|
|
|
return ''
|
|
|
|
}
|
|
|
|
|
|
|
|
static getCompetences(actor, categories) {
|
|
|
|
const competences = Mapping.getCompetencesCategorie(actor, categories)
|
|
|
|
if (competences.length == 0) {
|
|
|
|
return ''
|
|
|
|
}
|
2024-10-05 12:41:28 +02:00
|
|
|
const byCategories = Mapping.competencesByCategoriesByNiveau(competences, categories)
|
|
|
|
const txtByCategories = Object.values(byCategories)
|
2024-09-25 23:03:05 +02:00
|
|
|
.map(it => it.competencesParNiveau)
|
|
|
|
.map(byNiveau => {
|
2024-10-26 21:37:47 +02:00
|
|
|
const niveaux = Object.keys(byNiveau)
|
|
|
|
.map(it => Number(it)).sort(Misc.ascending())
|
2024-09-25 23:03:05 +02:00
|
|
|
if (niveaux.length == 0) {
|
|
|
|
return ''
|
|
|
|
}
|
|
|
|
const txtCategorieByNiveau = niveaux.map(niveau => {
|
|
|
|
const names = Misc.join(byNiveau[niveau].map(it => it.name).sort(Misc.ascending()), ', ')
|
2024-09-27 02:35:02 +02:00
|
|
|
return names + ' ' + Misc.toSignedString(niveau)
|
|
|
|
})
|
2024-09-25 23:03:05 +02:00
|
|
|
const txtCategorie = Misc.join(txtCategorieByNiveau, ' / ')
|
|
|
|
return txtCategorie
|
|
|
|
}).filter(it => it != '')
|
|
|
|
|
|
|
|
return Misc.join(txtByCategories, ' / ')
|
|
|
|
}
|
|
|
|
|
|
|
|
static competencesByCategoriesByNiveau(competences, categories) {
|
|
|
|
return categories.map(c => {
|
|
|
|
return {
|
|
|
|
categorie: c,
|
|
|
|
competencesParNiveau: Misc.classify(
|
|
|
|
competences.filter(comp => comp.system.categorie == c),
|
|
|
|
comp => comp.system.niveau)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
static getArme(actor, context, part, numero) {
|
|
|
|
if (numero < context.armes.length) {
|
|
|
|
return context.armes[numero][part] ?? ''
|
|
|
|
}
|
|
|
|
return ''
|
|
|
|
}
|
|
|
|
|
|
|
|
static getCompetencesCategorie(actor, categories) {
|
|
|
|
return actor.itemTypes[ITEM_TYPES.competence]
|
|
|
|
.filter(it => categories.includes(it.system.categorie))
|
|
|
|
.filter(it => !RdDItemCompetence.isNiveauBase(it))
|
|
|
|
}
|
|
|
|
|
|
|
|
static getSort(actor, context, part, numero) {
|
|
|
|
if (numero < context.sorts.length) {
|
|
|
|
return context.sorts[numero][part]
|
|
|
|
}
|
|
|
|
return ''
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|