Correction du mapping
- gestion des armes une/deux mains/lancées - dommages des armes une/deux mains - correction de la voie de draconic - correction des bonus de cases - correction des retours à la ligne
This commit is contained in:
parent
43607afc12
commit
6819f1c2f5
@ -1,4 +1,3 @@
|
|||||||
import { LOG_HEAD } from "../../constants.js"
|
|
||||||
import { ACTOR_TYPES } from "../../item.js"
|
import { ACTOR_TYPES } from "../../item.js"
|
||||||
import { Misc } from "../../misc.js"
|
import { Misc } from "../../misc.js"
|
||||||
import { EXPORT_CSV_SCRIPTARIUM, OptionsAvancees } from "../../settings/options-avancees.js"
|
import { EXPORT_CSV_SCRIPTARIUM, OptionsAvancees } from "../../settings/options-avancees.js"
|
||||||
@ -28,6 +27,7 @@ export class ExportScriptarium {
|
|||||||
callback: target => this.exportActors(this.$getActors(actorDirectory, target), this.$getTargetName(actorDirectory, target))
|
callback: target => this.exportActors(this.$getActors(actorDirectory, target), this.$getTargetName(actorDirectory, target))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
$getTargetName(actorDirectory, target) {
|
$getTargetName(actorDirectory, target) {
|
||||||
const li = target.closest(".directory-item")
|
const li = target.closest(".directory-item")
|
||||||
const folderId = li.data("folderId")
|
const folderId = li.data("folderId")
|
||||||
@ -36,6 +36,7 @@ export class ExportScriptarium {
|
|||||||
? game.actors.get(actorId).name
|
? game.actors.get(actorId).name
|
||||||
: actorDirectory.folders.find(it => it.id == folderId).name
|
: actorDirectory.folders.find(it => it.id == folderId).name
|
||||||
}
|
}
|
||||||
|
|
||||||
$getActors(actorDirectory, target) {
|
$getActors(actorDirectory, target) {
|
||||||
const li = target.closest(".directory-item")
|
const li = target.closest(".directory-item")
|
||||||
const folderId = li.data("folderId")
|
const folderId = li.data("folderId")
|
||||||
@ -49,7 +50,7 @@ export class ExportScriptarium {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exportActors(actors, targetName) {
|
exportActors(actors, targetName) {
|
||||||
const eol = '\n\r'
|
const eol = '\n'
|
||||||
const header = Misc.join(this.getHeaderLine(), ';')
|
const header = Misc.join(this.getHeaderLine(), ';')
|
||||||
const actorLines = actors.map(actor => Misc.join(this.getActorLine(actor), ';'))
|
const actorLines = actors.map(actor => Misc.join(this.getActorLine(actor), ';'))
|
||||||
const data = Misc.join([header, ...actorLines], eol)
|
const data = Misc.join([header, ...actorLines], eol)
|
||||||
@ -64,6 +65,7 @@ export class ExportScriptarium {
|
|||||||
getActorLine(actor) {
|
getActorLine(actor) {
|
||||||
const context = Mapping.prepareContext(actor)
|
const context = Mapping.prepareContext(actor)
|
||||||
return this.mapping.map(it => it.getter(actor, context))
|
return this.mapping.map(it => it.getter(actor, context))
|
||||||
|
//.map(it => JSON.stringify(it))
|
||||||
.map(it => this.$escapeQuotes(it))
|
.map(it => this.$escapeQuotes(it))
|
||||||
.map(it => it.replaceAll("\n", " ").replaceAll("\r", ""))
|
.map(it => it.replaceAll("\n", " ").replaceAll("\r", ""))
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import { RdDItemSort } from "../../item-sort.js"
|
|||||||
import { ITEM_TYPES } from "../../item.js"
|
import { ITEM_TYPES } from "../../item.js"
|
||||||
import { Misc } from "../../misc.js"
|
import { Misc } from "../../misc.js"
|
||||||
import { RdDTimestamp } from "../../time/rdd-timestamp.js"
|
import { RdDTimestamp } from "../../time/rdd-timestamp.js"
|
||||||
import { TMRConstants } from "../../tmr-constants.js"
|
import { RdDBonus } from "../../rdd-bonus.js"
|
||||||
import { TMRUtility } from "../../tmr-utility.js"
|
|
||||||
|
|
||||||
const CATEGORIES_COMPETENCES = [
|
const CATEGORIES_COMPETENCES = [
|
||||||
"generale",
|
"generale",
|
||||||
@ -80,8 +80,7 @@ const MAPPING_BASE = [
|
|||||||
{ column: "armure", getter: (actor, context) => Mapping.getArmure(actor, context) },
|
{ column: "armure", getter: (actor, context) => Mapping.getArmure(actor, context) },
|
||||||
{ column: "protection", getter: (actor, context) => Mapping.getProtectionArmure(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(actor, context) },
|
{ column: "esquive", getter: (actor, context) => Mapping.getEsquiveNiveau(context) },
|
||||||
{ column: "esquive-niv", getter: (actor, context) => Mapping.getEsquiveNiveau(context) },
|
|
||||||
{ column: "competences", getter: (actor, context) => Mapping.getCompetences(actor, CATEGORIES_COMPETENCES) },
|
{ 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) },
|
||||||
]
|
]
|
||||||
@ -89,7 +88,7 @@ const MAPPING_BASE = [
|
|||||||
const MAPPING_ARMES = TABLEAU_ARMES.map(i => ColumnMappingFactory.createMappingArme('name', i))
|
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('niveau', i)))
|
||||||
.concat(TABLEAU_ARMES.map(i => ColumnMappingFactory.createMappingArme('init', i)))
|
.concat(TABLEAU_ARMES.map(i => ColumnMappingFactory.createMappingArme('init', i)))
|
||||||
.concat(TABLEAU_ARMES.map(i => ColumnMappingFactory.createMappingArme('dom', i)))
|
.concat(TABLEAU_ARMES.map(i => ColumnMappingFactory.createMappingArme('dommages', i)))
|
||||||
const MAPPING_SORTS = TABLEAU_SORTS.map(i => ColumnMappingFactory.createMappingSort('voie', i))
|
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('description', i)))
|
||||||
.concat(TABLEAU_SORTS.map(i => ColumnMappingFactory.createMappingSort('bonus', i)))
|
.concat(TABLEAU_SORTS.map(i => ColumnMappingFactory.createMappingSort('bonus', i)))
|
||||||
@ -113,29 +112,36 @@ export class Mapping {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static prepareArmes(actor) {
|
static prepareArmes(actor) {
|
||||||
return actor.items.filter(it => it.type == ITEM_TYPES.arme)
|
const armes = actor.items.filter(it => it.type == ITEM_TYPES.arme)
|
||||||
.map(arme => {
|
return armes.map(arme =>
|
||||||
// TODO: gestion armes 1 ou 2 mains
|
[
|
||||||
const compToUse = RdDItemArme.getCompetenceArme(arme, 'competence');
|
arme.system.tir != "" ? Mapping.prepareArme(actor, arme, 'tir') : undefined,
|
||||||
const comp = actor.getCompetence(compToUse);
|
arme.system.lancer = "" ? Mapping.prepareArme(actor, arme, 'lancer') : undefined,
|
||||||
const bonusDom = Mapping.calculBonusDom(comp, actor)
|
arme.system.unemain ? Mapping.prepareArme(actor, arme, 'unemain') : undefined,
|
||||||
return {
|
arme.system.deuxmains ? Mapping.prepareArme(actor, arme, 'deuxmains') : undefined,
|
||||||
name: arme.name,
|
!(arme.system.unemain || arme.system.deuxmains) ? Mapping.prepareArme(actor, arme, 'competence') : undefined
|
||||||
niveau: comp.system.niveau,
|
]
|
||||||
init: Mapping.calculBaseInit(actor, comp.system.categorie) + comp.system.niveau,
|
.filter(it => it != undefined)
|
||||||
dom: Number(arme.system.dommages) + bonusDom
|
).reduce((a, b) => a.concat(b), [])
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static calculBonusDom(comp, actor) {
|
static prepareArme(actor, arme, maniement) {
|
||||||
// TODO: reuse dmg calc?
|
const nameCompArme = RdDItemArme.getCompetenceArme(arme, maniement)
|
||||||
const appliesBonusDom = ['melee', 'lancer'].includes(comp.system.categorie)
|
const competence = actor.getCompetence(nameCompArme)
|
||||||
return appliesBonusDom ? Number(actor.system.attributs.plusdom.value) : 0
|
if (RdDItemCompetence.isNiveauBase(competence)) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
const dmgArme = RdDItemArme.dommagesReels(arme, maniement)
|
||||||
|
const dommages = dmgArme + RdDBonus.bonusDmg(actor, maniement, dmgArme)
|
||||||
|
return {
|
||||||
|
name: arme.name,
|
||||||
|
niveau: Misc.toSignedString(competence.system.niveau),
|
||||||
|
init: Mapping.calculBaseInit(actor, competence.system.categorie) + competence.system.niveau,
|
||||||
|
dommages: Misc.toSignedString(dommages)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static calculBaseInit(actor, categorie) {
|
static calculBaseInit(actor, categorie) {
|
||||||
// TODO: reuse init calc?
|
|
||||||
const mapping = MAPPING_BASE.find(it => it.column == categorie)
|
const mapping = MAPPING_BASE.find(it => it.column == categorie)
|
||||||
if (mapping) {
|
if (mapping) {
|
||||||
switch (categorie) {
|
switch (categorie) {
|
||||||
@ -175,20 +181,22 @@ export class Mapping {
|
|||||||
const esquive = esquives[0]
|
const esquive = esquives[0]
|
||||||
return {
|
return {
|
||||||
name: esquive.name,
|
name: esquive.name,
|
||||||
niveau: esquive.system.niveau
|
niveau: Misc.toSignedString(esquive.system.niveau)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
static prepareSorts(actor) {
|
static prepareSorts(actor) {
|
||||||
return actor.itemTypes[ITEM_TYPES.sort].map(it => {
|
return actor.itemTypes[ITEM_TYPES.sort].map(it => Mapping.prepareSort(it))
|
||||||
return {
|
}
|
||||||
voie: RdDItemSort.getCodeDraconic(it),
|
|
||||||
description: Mapping.descriptionSort(it),
|
static prepareSort(sort) {
|
||||||
bonus: Mapping.bonusCase(it)
|
return {
|
||||||
}
|
voie: RdDItemSort.getCodeDraconic(sort),
|
||||||
})
|
description: Mapping.descriptionSort(sort),
|
||||||
|
bonus: Mapping.bonusCase(sort)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static descriptionSort(sort) {
|
static descriptionSort(sort) {
|
||||||
@ -198,11 +206,12 @@ export class Mapping {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bonusCase(sort) {
|
static bonusCase(sort) {
|
||||||
const list = RdDItemSort.buildBonusCaseList(sort.system.bonuscase, false).sort(Misc.descending(it => it.bonus))
|
const list = RdDItemSort.bonuscaseStringToList(sort.system.bonuscase).sort(Misc.descending(it => it.bonus))
|
||||||
if (list.length > 0) {
|
if (list.length > 0) {
|
||||||
const bonus = list[0]
|
const bonus = list[0]
|
||||||
return `+${bonus.bonus}% en ${bonus.case}`
|
return `+${bonus.bonus}% en ${bonus.case}`
|
||||||
}
|
}
|
||||||
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
static getDescription(actor) {
|
static getDescription(actor) {
|
||||||
@ -233,10 +242,6 @@ export class Mapping {
|
|||||||
return context?.armure?.malus ?? 0
|
return context?.armure?.malus ?? 0
|
||||||
}
|
}
|
||||||
|
|
||||||
static getEsquive(actor, context) {
|
|
||||||
return context.esquive?.name ?? ''
|
|
||||||
}
|
|
||||||
|
|
||||||
static getEsquiveNiveau(context) {
|
static getEsquiveNiveau(context) {
|
||||||
if (context.esquive) {
|
if (context.esquive) {
|
||||||
const niveau = context.esquive.niveau + context.armure.malus
|
const niveau = context.esquive.niveau + context.armure.malus
|
||||||
@ -260,9 +265,8 @@ export class Mapping {
|
|||||||
}
|
}
|
||||||
const txtCategorieByNiveau = niveaux.map(niveau => {
|
const txtCategorieByNiveau = niveaux.map(niveau => {
|
||||||
const names = Misc.join(byNiveau[niveau].map(it => it.name).sort(Misc.ascending()), ', ')
|
const names = Misc.join(byNiveau[niveau].map(it => it.name).sort(Misc.ascending()), ', ')
|
||||||
return names + ': ' + Misc.toSignedString(niveau)
|
return names + ' ' + Misc.toSignedString(niveau)
|
||||||
}
|
})
|
||||||
)
|
|
||||||
const txtCategorie = Misc.join(txtCategorieByNiveau, ' / ')
|
const txtCategorie = Misc.join(txtCategorieByNiveau, ' / ')
|
||||||
return txtCategorie
|
return txtCategorie
|
||||||
}).filter(it => it != '')
|
}).filter(it => it != '')
|
||||||
|
Loading…
Reference in New Issue
Block a user