Fix esquive avec armure

- ajout de champ sans armure/avec armure
- calcul correct avec armure
This commit is contained in:
Vincent Vandemeulebrouck 2024-09-28 17:45:31 +02:00
parent 74b184aa32
commit b8f236fa97

View File

@ -80,7 +80,8 @@ 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.getEsquiveNiveau(context) }, { column: "esquive", getter: (actor, context) => Mapping.getEsquive(context) },
{ column: "esquive-armure", getter: (actor, context) => Mapping.getEsquiveArmure(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) },
] ]
@ -181,7 +182,7 @@ export class Mapping {
const esquive = esquives[0] const esquive = esquives[0]
return { return {
name: esquive.name, name: esquive.name,
niveau: Misc.toSignedString(esquive.system.niveau) niveau: esquive.system.niveau
} }
} }
return undefined return undefined
@ -242,10 +243,16 @@ export class Mapping {
return context?.armure?.malus ?? 0 return context?.armure?.malus ?? 0
} }
static getEsquiveNiveau(context) { static getEsquive(context) {
if (context.esquive) {
return Misc.toSignedString(context.esquive.niveau)
}
return ''
}
static getEsquiveArmure(context) {
if (context.esquive) { if (context.esquive) {
const niveau = context.esquive.niveau + context.armure.malus const niveau = context.esquive.niveau + context.armure.malus
return niveau > 0 ? ('+' + niveau) : ('' + niveau) return Misc.toSignedString(niveau)
} }
return '' return ''
} }