From 40b0d7e6dc26797e53bc48d0071db704896aa4f6 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sat, 5 Oct 2024 12:41:28 +0200 Subject: [PATCH] =?UTF-8?q?Jets=20de=20carac/comp=C3=A9tences=20sur=20feui?= =?UTF-8?q?lle=20encart?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 2 + module/actor/base-actor-reve-sheet.js | 4 +- module/actor/base-actor-reve.js | 3 ++ .../export-scriptarium/actor-export-sheet.js | 40 +++++++++++++++-- module/actor/export-scriptarium/mapping.js | 8 ++-- styles/simple.css | 4 +- templates/actor/carac-main.html | 4 +- templates/actor/combat.html | 2 +- templates/actor/comp-creature.html | 2 +- templates/actor/competence.html | 2 +- .../export-scriptarium/actor-export-sheet.hbs | 44 +++++++++---------- .../export-scriptarium/carac-derivee.hbs | 2 +- templates/actor/export-scriptarium/carac.hbs | 5 ++- .../actor/export-scriptarium/competences.hbs | 10 +++++ 14 files changed, 91 insertions(+), 41 deletions(-) create mode 100644 templates/actor/export-scriptarium/competences.hbs diff --git a/changelog.md b/changelog.md index 20967d6b..04d5b726 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,8 @@ ## 12.0.12 - L'étalage d'Astrobazzarh - Fix: On peut de nouveau vendre des items sans propriétaire, depuis les compendiums ou depuis l'onglet des Objets - Début de Feuille PNJ au format des encarts Scriptarium + - support des jets de caractéristiques + - support des jets de compétences ## 12.0.11 - Le scriptorium d'Astrobazzarh - ajout d'un bouton pour générer les éléments de description d'un personnage diff --git a/module/actor/base-actor-reve-sheet.js b/module/actor/base-actor-reve-sheet.js index 901c7423..ad3e5dea 100644 --- a/module/actor/base-actor-reve-sheet.js +++ b/module/actor/base-actor-reve-sheet.js @@ -25,8 +25,8 @@ export class RdDBaseActorReveSheet extends RdDBaseActorSheet { if (!this.options.editable) return; this.html.find('.encaisser-direct').click(async event => this.actor.encaisser()) - this.html.find('.carac-label a').click(async event => this.actor.rollCarac(Grammar.toLowerCaseNoAccent(event.currentTarget.attributes.name.value))); - this.html.find('a.competence-label').click(async event => this.actor.rollCompetence(RdDSheetUtility.getItemId(event))); + this.html.find('.roll-carac').click(async event => this.actor.rollCarac(Grammar.toLowerCaseNoAccent(event.currentTarget.attributes.name.value))); + this.html.find('.roll-competence').click(async event => this.actor.rollCompetence(RdDSheetUtility.getItemId(event))); this.html.find('.endurance-plus').click(async event => this.actor.santeIncDec("endurance", 1)); this.html.find('.endurance-moins').click(async event => this.actor.santeIncDec("endurance", -1)); diff --git a/module/actor/base-actor-reve.js b/module/actor/base-actor-reve.js index 60ebb6f1..f695cce1 100644 --- a/module/actor/base-actor-reve.js +++ b/module/actor/base-actor-reve.js @@ -296,6 +296,9 @@ export class RdDBaseActorReve extends RdDBaseActor { /* -------------------------------------------- */ async rollCarac(caracName, jetResistance = undefined) { + if (Grammar.equalsInsensitive(caracName, 'taille')){ + return + } RdDEmpoignade.checkEmpoignadeEnCours(this) let selectedCarac = this.getCaracByName(caracName) await this.openRollDialog({ diff --git a/module/actor/export-scriptarium/actor-export-sheet.js b/module/actor/export-scriptarium/actor-export-sheet.js index bfe4a8c3..dd2cd2e5 100644 --- a/module/actor/export-scriptarium/actor-export-sheet.js +++ b/module/actor/export-scriptarium/actor-export-sheet.js @@ -2,7 +2,7 @@ import { RdDActorSheet } from "../../actor-sheet.js" import { SYSTEM_RDD } from "../../constants.js"; import { Misc } from "../../misc.js"; import { ExportScriptarium } from "./export-scriptarium.js"; -import { Mapping } from "./mapping.js"; +import { CATEGORIES_COMPETENCES, CATEGORIES_DRACONIC, Mapping } from "./mapping.js"; export class RdDActorExportSheet extends RdDActorSheet { static async init() { @@ -10,6 +10,7 @@ export class RdDActorExportSheet extends RdDActorSheet { "systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/arme.hbs", "systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/carac.hbs", "systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/carac-derivee.hbs", + "systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/competences.hbs", "systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/esquive.hbs", "systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/protection.hbs", "systems/foundryvtt-reve-de-dragon/templates/actor/export-scriptarium/sort.hbs", @@ -31,12 +32,45 @@ export class RdDActorExportSheet extends RdDActorSheet { async getData() { const formData = await super.getData() - const values = Mapping.getAsObject(this.actor); // Add any structured, precomputed list of data - formData.export = values + formData.export = this.getMappingValues(); + formData.competences = this.getCompetences(CATEGORIES_COMPETENCES) + formData.draconic = this.getCompetences(CATEGORIES_DRACONIC) return formData } + getMappingValues() { + const context = Mapping.prepareContext(this.actor) + return Object.fromEntries(Mapping.getMapping().map(it => [it.column, { + colName: it.colName ?? it.column, + column: it.column, + value: it.getter(this.actor, context) + }])) + } + + getCompetences(categories) { + const competences = Mapping.getCompetencesCategorie(this.actor, categories) + if (competences.length == 0) { + return '' + } + const byCategories = Mapping.competencesByCategoriesByNiveau(competences, categories) + const listByCategories = Object.values(byCategories) + .map(it => it.competencesParNiveau) + .map(byNiveau => { + const niveaux = Object.keys(byNiveau).map(it => Number(it)).sort(Misc.ascending()) + if (niveaux.length == 0) { + return undefined + } + const listCategorieByNiveau = niveaux.map(niveau => { + const list = byNiveau[niveau].sort(Misc.ascending(it => it.name)) + return {niveau, list} + }) + return Misc.concat(listCategorieByNiveau) + }).filter(it => it != undefined) + + return Misc.concat(listByCategories) + } + activateListeners(html) { super.activateListeners(html); this.html.find('.button-export').click(async event => { diff --git a/module/actor/export-scriptarium/mapping.js b/module/actor/export-scriptarium/mapping.js index e0e7a7d7..eb79530b 100644 --- a/module/actor/export-scriptarium/mapping.js +++ b/module/actor/export-scriptarium/mapping.js @@ -9,13 +9,13 @@ import { RdDBonus } from "../../rdd-bonus.js" import { TMRType } from "../../tmr-utility.js" -const CATEGORIES_COMPETENCES = [ +export const CATEGORIES_COMPETENCES = [ "generale", "particuliere", "specialisee", "connaissance", ] -const CATEGORIES_DRACONIC = [ +export const CATEGORIES_DRACONIC = [ "draconic", ] @@ -306,8 +306,8 @@ export class Mapping { if (competences.length == 0) { return '' } - const byCartegories = Mapping.competencesByCategoriesByNiveau(competences, categories) - const txtByCategories = Object.values(byCartegories) + const byCategories = Mapping.competencesByCategoriesByNiveau(competences, categories) + const txtByCategories = Object.values(byCategories) .map(it => it.competencesParNiveau) .map(byNiveau => { const niveaux = Object.keys(byNiveau).map(it => Number(it)).sort(Misc.ascending()) diff --git a/styles/simple.css b/styles/simple.css index 9e5d6299..92ec5536 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -680,6 +680,7 @@ input:is(.blessure-premiers_soins, .blessure-soins_complets) { } .carac-label { + font-weight: bold; flex-basis: 40%; } .rdd.sheet .window-content .sheet-body .carac-list .caracteristique > .utiliser-attribut { @@ -1188,9 +1189,6 @@ ul.chat-list li:nth-child(odd) { padding: 0.5rem; cursor: pointer; } -.carac-label { - font-weight: bold; -} .list-item { margin: 0.1rem; box-shadow: inset 0px 0px 1px #00000096; diff --git a/templates/actor/carac-main.html b/templates/actor/carac-main.html index c842223e..8f31c909 100644 --- a/templates/actor/carac-main.html +++ b/templates/actor/carac-main.html @@ -7,7 +7,7 @@