From f6d42875ae105f0ebbed344c4e9e64b442b9101b Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sat, 10 Dec 2022 15:49:09 +0100 Subject: [PATCH] =?UTF-8?q?Stress=20et=20arch=C3=A9type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Déplacement du stress et de l'archétype avant les compétences Les lignes d'archétypes totalement réparties disparaissent --- module/item-competence.js | 43 ++++++++++++++--------------- templates/actor-sheet.html | 7 ++--- templates/actor/xp-competences.html | 33 +++++++++++++--------- 3 files changed, 43 insertions(+), 40 deletions(-) diff --git a/module/item-competence.js b/module/item-competence.js index 13b7de41..8772c75b 100644 --- a/module/item-competence.js +++ b/module/item-competence.js @@ -8,18 +8,18 @@ const xp_par_niveau = [5, 5, 5, 10, 10, 10, 10, 15, 15, 15, 15, 20, 20, 20, 20, const niveau_max = xp_par_niveau.length - 10; /* -------------------------------------------- */ const limitesArchetypes = [ - { "niveau": 0, "nombreMax": 100, "nombre": 0 }, - { "niveau": 1, "nombreMax": 10, "nombre": 0 }, - { "niveau": 2, "nombreMax": 9, "nombre": 0 }, - { "niveau": 3, "nombreMax": 8, "nombre": 0 }, - { "niveau": 4, "nombreMax": 7, "nombre": 0 }, - { "niveau": 5, "nombreMax": 6, "nombre": 0 }, - { "niveau": 6, "nombreMax": 5, "nombre": 0 }, - { "niveau": 7, "nombreMax": 4, "nombre": 0 }, - { "niveau": 8, "nombreMax": 3, "nombre": 0 }, - { "niveau": 9, "nombreMax": 2, "nombre": 0 }, - { "niveau": 10, "nombreMax": 1, "nombre": 0 }, - { "niveau": 11, "nombreMax": 1, "nombre": 0 } + { "niveau": 0, "nombreMax": 100, "reste": 100 }, + { "niveau": 1, "nombreMax": 10, "reste": 10 }, + { "niveau": 2, "nombreMax": 9, "reste": 9 }, + { "niveau": 3, "nombreMax": 8, "reste": 8 }, + { "niveau": 4, "nombreMax": 7, "reste": 7 }, + { "niveau": 5, "nombreMax": 6, "reste": 6 }, + { "niveau": 6, "nombreMax": 5, "reste": 5 }, + { "niveau": 7, "nombreMax": 4, "reste": 4 }, + { "niveau": 8, "nombreMax": 3, "reste": 3 }, + { "niveau": 9, "nombreMax": 2, "reste": 2 }, + { "niveau": 10, "nombreMax": 1, "reste": 1 }, + { "niveau": 11, "nombreMax": 1, "reste": 1 } ]; /* -------------------------------------------- */ @@ -267,23 +267,20 @@ export class RdDItemCompetence extends Item { /* -------------------------------------------- */ static computeResumeArchetype(competences) { - const archetype = RdDItemCompetence.getLimitesArchetypes(); + const computed = duplicate(limitesArchetypes); competences.map(it => Math.max(0, it.system.niveau_archetype)) - .forEach(niveau => { - archetype[niveau] = archetype[niveau] ?? { "niveau": niveau, "nombreMax": 0, "nombre": 0 }; - archetype[niveau].nombre = (archetype[niveau]?.nombre ?? 0) + 1; + .filter(n => n > 0) + .forEach(n => { + computed[n] = computed[n] ?? { niveau: n, nombreMax: 0, reste: 0 }; + computed[n].reste = computed[n].reste - 1; }); - return archetype; + return computed.filter(it => it.reste > 0 && it.niveau > 0); } /* -------------------------------------------- */ - static getLimitesArchetypes() { - return duplicate(limitesArchetypes); - } - static triVisible(competences) { return competences.filter(it => it.system.isVisible) - .sort((a, b) => RdDItemCompetence.compare(a,b)) + .sort((a, b) => RdDItemCompetence.compare(a, b)) } static $positionTri(comp) { @@ -308,7 +305,7 @@ export class RdDItemCompetence extends Item { return 0; } - static compare(a,b) { + static compare(a, b) { const diff = RdDItemCompetence.$positionTri(a) - RdDItemCompetence.$positionTri(b); return diff ? diff : a.name.localeCompare(b.name); } diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 17d4d1ae..e47d27e8 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -66,13 +66,13 @@
-
+
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/competence-categorie.html" competences=(filtreTriCompetences byCateg.generale) categorie="Compétences générales"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/competence-categorie.html" competences=(filtreTriCompetences byCateg.particuliere) categorie="Compétences Particulières"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/competence-categorie.html" competences=(filtreTriCompetences byCateg.specialisee) categorie="Compétences Spécialisées"}}
- -
+
+ {{> "systems/foundryvtt-reve-de-dragon/templates/actor/xp-competences.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/competence-categorie.html" competences=(filtreTriCompetences byCateg.melee) categorie="Compétences de Mêlée"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/competence-categorie.html" competences=(filtreTriCompetences byCateg.tir) categorie="Compétences de Tir"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/competence-categorie.html" competences=(filtreTriCompetences byCateg.lancer) categorie="Compétences de Lancer"}} @@ -80,7 +80,6 @@ {{#if (or system.attributs.hautrevant.value options.vueDetaillee)}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/competence-categorie.html" competences=(filtreTriCompetences byCateg.draconic) categorie="Draconic"}} {{/if}} - {{> "systems/foundryvtt-reve-de-dragon/templates/actor/xp-competences.html"}}
diff --git a/templates/actor/xp-competences.html b/templates/actor/xp-competences.html index 28720100..fa6f29e0 100644 --- a/templates/actor/xp-competences.html +++ b/templates/actor/xp-competences.html @@ -1,23 +1,30 @@
  • - Stress transformé - + + {{#if options.vueDetaillee}} + + {{else}} + + {{/if}}
  • - + {{#if options.vueDetaillee}}
  • Total XP compétences {{calc.competenceXPTotal}}
  • - {{#if options.vueDetaillee}} -
  • Niveaux d'archétype à répartir
  • - {{#each calc.comptageArchetype as |archetype key|}} - {{#if (lt archetype.nombre archetype.nombreMax)}} -
  • - -
  • - {{/if}} - {{/each}} - {{/if}} + {{#if calc.comptageArchetype}} +

  • +
  • Niveaux d'archétype à répartir
  • + {{#each calc.comptageArchetype as |archetype key|}} + {{#if (gt archetype.reste 0)}} +
  • + +
  • + {{/if}} + {{/each}} + {{/if}} + {{/if}} +
  •