From 2aa8fcb98094d86842d09606fe3f9a6899e30813 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 26 Sep 2024 00:55:08 +0200 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20export=20voies=20draconique?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actor.js | 15 +--------- module/actor/export-scriptarium/mapping.js | 3 +- module/item-sort.js | 33 ++++++++++++++++++++++ templates/enum-draconic.html | 2 ++ 4 files changed, 38 insertions(+), 15 deletions(-) diff --git a/module/actor.js b/module/actor.js index 6e11783a..50666844 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1602,7 +1602,7 @@ export class RdDActor extends RdDBaseActorSang { computeDraconicAndSortIndex(sortList) { let draconicList = this.getDraconicList(); for (let sort of sortList) { - let draconicsSort = this.getDraconicsSort(draconicList, sort).map(it => it.name); + let draconicsSort = RdDItemSort.getDraconicsSort(draconicList, sort).map(it => it.name); for (let index = 0; index < draconicList.length && sort.system.listIndex == undefined; index++) { if (draconicsSort.includes(draconicList[index].name)) { sort.system.listIndex = index; @@ -1612,19 +1612,6 @@ export class RdDActor extends RdDBaseActorSang { return draconicList; } - /* -------------------------------------------- */ - getDraconicsSort(draconicList, sort) { - //console.log(draconicList, bestDraconic, draconic, voie); - switch (Grammar.toLowerCaseNoAccent(sort.name)) { - case "lecture d'aura": - case "detection d'aura": - return draconicList; - case "annulation de magie": - return draconicList.filter(it => !RdDItemCompetence.isThanatos(it)); - } - return [RdDItemCompetence.getVoieDraconic(draconicList, sort.system.draconic)]; - } - /* -------------------------------------------- */ async rollUnSort(coord) { RdDEmpoignade.checkEmpoignadeEnCours(this) diff --git a/module/actor/export-scriptarium/mapping.js b/module/actor/export-scriptarium/mapping.js index 567645d8..ea0cca8c 100644 --- a/module/actor/export-scriptarium/mapping.js +++ b/module/actor/export-scriptarium/mapping.js @@ -115,6 +115,7 @@ export class Mapping { static prepareArmes(actor) { return actor.items.filter(it => it.type == ITEM_TYPES.arme) .map(arme => { + // TODO: gestion armes 1 ou 2 mains const compToUse = RdDItemArme.getCompetenceArme(arme, 'competence'); const comp = actor.getCompetence(compToUse); const bonusDom = Mapping.calculBonusDom(comp, actor) @@ -183,7 +184,7 @@ export class Mapping { static prepareSorts(actor) { return actor.itemTypes[ITEM_TYPES.sort].map(it => { return { - voie: it.system.voie, + voie: RdDItemSort.getCodeDraconic(it), description: Mapping.descriptionSort(it), bonus: Mapping.bonusCase(it) } diff --git a/module/item-sort.js b/module/item-sort.js index e8141407..a8b038b4 100644 --- a/module/item-sort.js +++ b/module/item-sort.js @@ -1,10 +1,43 @@ +import { Grammar } from "./grammar.js"; +import { RdDItemCompetence } from "./item-competence.js"; import { ITEM_TYPES } from "./item.js"; import { Misc } from "./misc.js"; import { TMRUtility } from "./tmr-utility.js"; +const VOIES_DRACONIC = [ + { code: 'O', label: "Voie d'Oniros", short: 'Oniros'}, + { code: 'H', label: "Voie d'Hypnos" , short:'Hypnos' }, + { code: 'N', label: "Voie de Narcos", short: 'Narcos' }, + { code: 'T', label: "Voie de Thanatos", short:'Thanatos' }, + { code: 'O/H/N/T', label: "Oniros/Hypnos/Narcos/Thanatos", short:'Oniros/Hypnos/Narcos/Thanatos' }, + { code: 'O/H/N', label: "Oniros/Hypnos/Narcos" } +] + /* -------------------------------------------- */ export class RdDItemSort extends Item { + static getDraconicsSort(draconicList, sort) { + switch (Grammar.toLowerCaseNoAccent(sort.name)) { + case "lecture d'aura": + case "detection d'aura": + return draconicList; + case "annulation de magie": + return draconicList.filter(it => !RdDItemCompetence.isThanatos(it)); + } + return [RdDItemCompetence.getVoieDraconic(draconicList, sort.system.draconic)]; + } + + static getCodeDraconic(sort) { + switch (Grammar.toLowerCaseNoAccent(sort.name)) { + case "lecture d'aura": + case "detection d'aura": + return 'O/H/N/T' + case "annulation de magie": + return 'O/H/N' + } + const voie = VOIES_DRACONIC.find(it => it.label.includes(sort.system.draconic)) + return voie?.code ?? sort.system.draconic + } /* -------------------------------------------- */ static isDifficulteVariable(sort) { return sort && (sort.system.difficulte.toLowerCase() == "variable"); diff --git a/templates/enum-draconic.html b/templates/enum-draconic.html index 340c669b..b86b8839 100644 --- a/templates/enum-draconic.html +++ b/templates/enum-draconic.html @@ -3,3 +3,5 @@ {{/if}} {{/each}} + +