Filtrer les catégories sans compétences

This commit is contained in:
Vincent Vandemeulebrouck 2022-08-27 22:48:08 +02:00
parent 6e361a5531
commit e4da124579
2 changed files with 61 additions and 55 deletions

View File

@ -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);
}

View File

@ -1,27 +1,31 @@
<header class="competence-header flexrow">
<span class="competence-title">{{categorie}}</span>
</header>
<ul class="item-list alterne-list competence-list">
{{#if @root.options.vueDetaillee}}
<li class="item flexrow list-item ">
{{#if competences}}
<div class="flex-shrink">
<header class="competence-header flexrow">
<span class="competence-title">{{categorie}}</span>
</header>
<ul class="item-list alterne-list competence-list">
{{#if @root.options.vueDetaillee}}
<li class="item flexrow list-item ">
<span class="competence-label"></span>
<span class="competence-value" >Niv.</span>
<span class="competence-xp">xp</span>
{{#if (eq categorie 'Draconic')}}
<span class="competence-xp-sort">sort</span>
{{/if}}
<div class="item-controls">
<i class="far fa-arrow-alt-circle-up"></i>
<span class="competence-archetype">Arch</span>
<i class="far fa-edit"></i>
{{#if @root.options.isGM}}
<i class="far fa-trash"></i>
<span class="competence-label"></span>
<span class="competence-value" >Niv.</span>
<span class="competence-xp">xp</span>
{{#if (eq categorie 'Draconic')}}
<span class="competence-xp-sort">sort</span>
{{/if}}
</div>
</li>
{{/if}}
{{#each competences as |comp key|}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-competence-partial.html" comp}}
{{/each}}
</ul>
<div class="item-controls">
<i class="far fa-arrow-alt-circle-up"></i>
<span class="competence-archetype">Arch</span>
<i class="far fa-edit"></i>
{{#if @root.options.isGM}}
<i class="far fa-trash"></i>
{{/if}}
</div>
</li>
{{/if}}
{{#each competences as |comp key|}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-competence-partial.html" comp}}
{{/each}}
</ul>
</div>
{{/if}}