From e4da1245799f72e0d919b74e4a445296d9972b24 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sat, 27 Aug 2022 22:48:08 +0200 Subject: [PATCH] =?UTF-8?q?Filtrer=20les=20cat=C3=A9gories=20sans=20comp?= =?UTF-8?q?=C3=A9tences?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/rdd-utility.js | 60 ++++++++++--------- ...r-sheet-categorie-competences-partial.html | 56 +++++++++-------- 2 files changed, 61 insertions(+), 55 deletions(-) diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 3b927d64..e16f28db 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -239,36 +239,38 @@ export class RdDUtility { Handlebars.registerHelper('typeTmr-name', coord => TMRUtility.typeTmrName(coord)); Handlebars.registerHelper('min', (...args) => Math.min(...args.slice(0, -1))); - Handlebars.registerHelper('sortCompetence', competences => competences.sort((a, b) => { - if (a.name.startsWith("Survie") && b.name.startsWith("Survie")) { - if (a.name.includes("Cité")) return -1; - if (b.name.includes("Cité")) return 1; - if (a.name.includes("Extérieur")) return -1; - if (b.name.includes("Extérieur")) return 1; + Handlebars.registerHelper('filtreTriCompetences', competences => competences.filter(it => it.visible) + .sort((a, b) => { + if (a.name.startsWith("Survie") && b.name.startsWith("Survie")) { + if (a.name.includes("Cité")) return -1; + if (b.name.includes("Cité")) return 1; + if (a.name.includes("Extérieur")) return -1; + if (b.name.includes("Extérieur")) return 1; + return a.name.localeCompare(b.name); + } + if (a.data.categorie.startsWith("melee") && b.data.categorie.startsWith("melee")) { + if (a.name.includes("Corps")) return -1; + if (b.name.includes("Corps")) return 1; + if (a.name.includes("Dague")) return -1; + if (b.name.includes("Dague")) return 1; + if (a.name.includes("Esquive")) return -1; + if (b.name.includes("Esquive")) return 1; + return a.name.localeCompare(b.name); + } + if (a.name.startsWith("Voie") && b.name.startsWith("Voie")) { + if (a.name.includes("Oniros")) return -1; + if (b.name.includes("Oniros")) return 1; + if (a.name.includes("Hypnos")) return -1; + if (b.name.includes("Hypnos")) return 1; + if (a.name.includes("Narcos")) return -1; + if (b.name.includes("Narcos")) return 1; + if (a.name.includes("Thanatos")) return -1; + if (b.name.includes("Thanatos")) return 1; + return a.name.localeCompare(b.name); + } return a.name.localeCompare(b.name); - } - if (a.data.categorie.startsWith("melee") && b.data.categorie.startsWith("melee")) { - if (a.name.includes("Corps")) return -1; - if (b.name.includes("Corps")) return 1; - if (a.name.includes("Dague")) return -1; - if (b.name.includes("Dague")) return 1; - if (a.name.includes("Esquive")) return -1; - if (b.name.includes("Esquive")) return 1; - return a.name.localeCompare(b.name); - } - if (a.name.startsWith("Voie") && b.name.startsWith("Voie")) { - if (a.name.includes("Oniros")) return -1; - if (b.name.includes("Oniros")) return 1; - if (a.name.includes("Hypnos")) return -1; - if (b.name.includes("Hypnos")) return 1; - if (a.name.includes("Narcos")) return -1; - if (b.name.includes("Narcos")) return 1; - if (a.name.includes("Thanatos")) return -1; - if (b.name.includes("Thanatos")) return 1; - return a.name.localeCompare(b.name); - } - return a.name.localeCompare(b.name); - })); + }) + ); return loadTemplates(templatePaths); } diff --git a/templates/actor-sheet-categorie-competences-partial.html b/templates/actor-sheet-categorie-competences-partial.html index 75ea7bd4..26d7a1db 100644 --- a/templates/actor-sheet-categorie-competences-partial.html +++ b/templates/actor-sheet-categorie-competences-partial.html @@ -1,27 +1,31 @@ -
- {{categorie}} -
- +
+ + Arch + + {{#if @root.options.isGM}} + + {{/if}} +
+ + {{/if}} + {{#each competences as |comp key|}} + {{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-competence-partial.html" comp}} + {{/each}} + + +{{/if}}