forked from public/foundryvtt-reve-de-dragon
Ajout feuille encart
Feuille de PNJ au format des encarts Scriptarium. Aucune possibilité de jets de dés pour l'instant.
This commit is contained in:
@ -6,6 +6,7 @@ import { ITEM_TYPES } from "../../item.js"
|
||||
import { Misc } from "../../misc.js"
|
||||
import { RdDTimestamp } from "../../time/rdd-timestamp.js"
|
||||
import { RdDBonus } from "../../rdd-bonus.js"
|
||||
import { TMRType } from "../../tmr-utility.js"
|
||||
|
||||
|
||||
const CATEGORIES_COMPETENCES = [
|
||||
@ -37,11 +38,11 @@ const NIVEAU_BASE = {
|
||||
|
||||
class ColumnMappingFactory {
|
||||
static createMappingArme(part, i) {
|
||||
return { column: `arme-${part}-${i}`, getter: (actor, context) => Mapping.getArme(actor, context, part, i) }
|
||||
return { column: `arme_${part}_${i}`, getter: (actor, context) => Mapping.getArme(actor, context, part, i) }
|
||||
}
|
||||
|
||||
static createMappingSort(part, i) {
|
||||
return { column: `sort-${part}-${i}`, getter: (actor, context) => Mapping.getSort(actor, context, part, i) }
|
||||
return { column: `sort_${part}_${i}`, getter: (actor, context) => Mapping.getSort(actor, context, part, i) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,40 +52,40 @@ const TABLEAU_ARMES = [...Array(NB_ARMES).keys()]
|
||||
const TABLEAU_SORTS = [...Array(NB_SORTS).keys()]
|
||||
|
||||
const MAPPING_BASE = [
|
||||
{ column: "ID", getter: (actor, context) => actor.id },
|
||||
{ column: "ID", colName: 'ID', getter: (actor, context) => actor.id },
|
||||
{ column: "name", getter: (actor, context) => actor.name },
|
||||
{ column: "metier", getter: (actor, context) => actor.system.metier },
|
||||
// { column: "biographie", getter: (actor, context) => actor.system.biographie },
|
||||
{ column: "metier", colName: 'Métier', getter: (actor, context) => actor.system.metier },
|
||||
{ column: "biographie", colName: 'Biographie', getter: (actor, context) => actor.system.biographie },
|
||||
{ column: "taille", getter: (actor, context) => actor.system.carac.taille.value },
|
||||
{ column: "apparence", getter: (actor, context) => actor.system.carac.apparence.value },
|
||||
{ column: "constitution", getter: (actor, context) => actor.system.carac.constitution.value },
|
||||
{ column: "force", getter: (actor, context) => actor.system.carac.force.value },
|
||||
{ column: "agilite", getter: (actor, context) => actor.system.carac.agilite.value },
|
||||
{ column: "dexterite", getter: (actor, context) => actor.system.carac.dexterite.value },
|
||||
{ column: "agilite", colName: 'Agilité', getter: (actor, context) => actor.system.carac.agilite.value },
|
||||
{ column: "dexterite", colName: 'Dextérité', getter: (actor, context) => actor.system.carac.dexterite.value },
|
||||
{ column: "vue", getter: (actor, context) => actor.system.carac.vue.value },
|
||||
{ column: "ouie", getter: (actor, context) => actor.system.carac.ouie.value },
|
||||
{ column: "odoratgout", getter: (actor, context) => actor.system.carac.odoratgout.value },
|
||||
{ column: "volonte", getter: (actor, context) => actor.system.carac.volonte.value },
|
||||
{ column: "ouie", colName: 'Ouïe', getter: (actor, context) => actor.system.carac.ouie.value },
|
||||
{ column: "odoratgout", colName: 'Odo-goût', getter: (actor, context) => actor.system.carac.odoratgout.value },
|
||||
{ column: "volonte", colName: 'Volonté', getter: (actor, context) => actor.system.carac.volonte.value },
|
||||
{ column: "intellect", getter: (actor, context) => actor.system.carac.intellect.value },
|
||||
{ column: "empathie", getter: (actor, context) => actor.system.carac.empathie.value },
|
||||
{ column: "reve", getter: (actor, context) => actor.system.carac.reve.value },
|
||||
{ column: "reve", colName: 'Rêve', getter: (actor, context) => actor.system.carac.reve.value },
|
||||
{ column: "chance", getter: (actor, context) => actor.system.carac.chance.value },
|
||||
{ column: "melee", getter: (actor, context) => actor.system.carac.melee.value },
|
||||
{ column: "melee", colName: 'Mêlée', getter: (actor, context) => actor.system.carac.melee.value },
|
||||
{ column: "tir", getter: (actor, context) => actor.system.carac.tir.value },
|
||||
{ column: "lancer", getter: (actor, context) => actor.system.carac.lancer.value },
|
||||
{ column: "derobee", getter: (actor, context) => actor.system.carac.derobee.value },
|
||||
{ column: "derobee", colName: 'Dérobée', getter: (actor, context) => actor.system.carac.derobee.value },
|
||||
{ column: "vie", getter: (actor, context) => actor.system.sante.vie.max },
|
||||
{ column: "plusdom", getter: (actor, context) => actor.system.attributs.plusdom.value },
|
||||
{ column: "protectionnaturelle", getter: (actor, context) => actor.system.attributs.protection.value },
|
||||
{ column: "plusdom", colName: '+dom', getter: (actor, context) => actor.system.attributs.plusdom.value },
|
||||
{ column: "protectionnaturelle", colName: 'Protection naturelle', getter: (actor, context) => actor.system.attributs.protection.value > 0 ? actor.system.attributs.protection.value : '' },
|
||||
{ column: "endurance", getter: (actor, context) => actor.system.sante.endurance.max },
|
||||
{ column: "description", getter: (actor, context) => Mapping.getDescription(actor) },
|
||||
{ column: "armure", getter: (actor, context) => Mapping.getArmure(actor, context) },
|
||||
{ column: "protection", getter: (actor, context) => Mapping.getProtectionArmure(actor, context) },
|
||||
{ column: "malus-armure", getter: (actor, context) => Mapping.getMalusArmure(actor, context) },
|
||||
{ column: "malus_armure", getter: (actor, context) => Mapping.getMalusArmure(actor, context) },
|
||||
{ column: "esquive", getter: (actor, context) => Mapping.getEsquive(context) },
|
||||
{ column: "esquive-armure", getter: (actor, context) => Mapping.getEsquiveArmure(context) },
|
||||
{ column: "esquive_armure", getter: (actor, context) => Mapping.getEsquiveArmure(context) },
|
||||
{ column: "competences", getter: (actor, context) => Mapping.getCompetences(actor, CATEGORIES_COMPETENCES) },
|
||||
{ column: "draconic", getter: (actor, context) => Mapping.getCompetences(actor, CATEGORIES_DRACONIC) },
|
||||
{ column: "draconic", getter: (actor, context) => Mapping.getCompetences(actor, CATEGORIES_DRACONIC) },
|
||||
]
|
||||
|
||||
const MAPPING_ARMES = TABLEAU_ARMES.map(i => ColumnMappingFactory.createMappingArme('name', i))
|
||||
@ -104,6 +105,27 @@ export class Mapping {
|
||||
return MAPPING
|
||||
}
|
||||
|
||||
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))
|
||||
}
|
||||
|
||||
static prepareContext(actor) {
|
||||
return {
|
||||
armes: Mapping.prepareArmes(actor),
|
||||
@ -190,12 +212,16 @@ export class Mapping {
|
||||
}
|
||||
|
||||
static prepareSorts(actor) {
|
||||
return actor.itemTypes[ITEM_TYPES.sort].map(it => Mapping.prepareSort(it))
|
||||
const codeVoies = Mapping.getCompetencesCategorie(actor, CATEGORIES_DRACONIC)
|
||||
.map(it => RdDItemSort.getVoieCode(it))
|
||||
|
||||
return actor.itemTypes[ITEM_TYPES.sort].map(it => Mapping.prepareSort(it, codeVoies))
|
||||
.sort(Misc.ascending(it => `${it.voie} : ${it.description}`))
|
||||
}
|
||||
|
||||
static prepareSort(sort) {
|
||||
static prepareSort(sort, voies) {
|
||||
return {
|
||||
voie: RdDItemSort.getCodeDraconic(sort),
|
||||
voie: RdDItemSort.getCodeDraconic(sort, voies),
|
||||
description: Mapping.descriptionSort(sort),
|
||||
bonus: Mapping.bonusCase(sort)
|
||||
}
|
||||
@ -203,8 +229,18 @@ export class Mapping {
|
||||
|
||||
static descriptionSort(sort) {
|
||||
const ptSeuil = Array(sort.system.coutseuil).map(it => '*')
|
||||
const caseTMR = sort.system.caseTMRspeciale.length > 0 ? sort.system.caseTMRspeciale : sort.system.caseTMR
|
||||
return `${sort.name}${ptSeuil} (${caseTMR}) R${sort.system.difficulte} r${sort.system.ptreve}`
|
||||
const caseTMR = sort.system.caseTMRspeciale.length > 0 ? Mapping.toVar(sort.system.caseTMRspeciale) : Misc.upperFirst(TMRType[sort.system.caseTMR].name)
|
||||
const ptreve = Mapping.addSpaceToNonNumeric(sort.system.ptreve)
|
||||
const diff = Mapping.addSpaceToNonNumeric(sort.system.difficulte)
|
||||
return `${sort.name}${ptSeuil} (${caseTMR}) R${diff} r${ptreve}`
|
||||
}
|
||||
|
||||
static addSpaceToNonNumeric(value) {
|
||||
return Number.isNumeric(value) ? value : ' ' + Mapping.toVar(value)
|
||||
}
|
||||
|
||||
static toVar(value) {
|
||||
return value.replace('variable', 'var')
|
||||
}
|
||||
|
||||
static bonusCase(sort) {
|
||||
@ -237,7 +273,14 @@ export class Mapping {
|
||||
}
|
||||
|
||||
static getProtectionArmure(actor, context) {
|
||||
return Number(context?.armure?.protection ?? 0) + Number(actor.system.attributs.protection.value)
|
||||
const protection = Number(actor.system.attributs.protection.value)
|
||||
if (context?.armure?.protection == undefined) {
|
||||
return protection
|
||||
}
|
||||
if (Number.isNumeric(context?.armure?.protection)) {
|
||||
return Number(context?.armure?.protection ?? 0) + protection
|
||||
}
|
||||
return context?.armure.protection + (protection > 0 ? `+${protection}` : '')
|
||||
}
|
||||
|
||||
static getMalusArmure(actor, context) {
|
||||
|
Reference in New Issue
Block a user