Stress et archétype

Déplacement du stress et de l'archétype avant les compétences

Les lignes d'archétypes totalement réparties disparaissent
This commit is contained in:
Vincent Vandemeulebrouck 2022-12-10 15:49:09 +01:00
parent 450cb8e899
commit f6d42875ae
3 changed files with 43 additions and 40 deletions

View File

@ -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 niveau_max = xp_par_niveau.length - 10;
/* -------------------------------------------- */ /* -------------------------------------------- */
const limitesArchetypes = [ const limitesArchetypes = [
{ "niveau": 0, "nombreMax": 100, "nombre": 0 }, { "niveau": 0, "nombreMax": 100, "reste": 100 },
{ "niveau": 1, "nombreMax": 10, "nombre": 0 }, { "niveau": 1, "nombreMax": 10, "reste": 10 },
{ "niveau": 2, "nombreMax": 9, "nombre": 0 }, { "niveau": 2, "nombreMax": 9, "reste": 9 },
{ "niveau": 3, "nombreMax": 8, "nombre": 0 }, { "niveau": 3, "nombreMax": 8, "reste": 8 },
{ "niveau": 4, "nombreMax": 7, "nombre": 0 }, { "niveau": 4, "nombreMax": 7, "reste": 7 },
{ "niveau": 5, "nombreMax": 6, "nombre": 0 }, { "niveau": 5, "nombreMax": 6, "reste": 6 },
{ "niveau": 6, "nombreMax": 5, "nombre": 0 }, { "niveau": 6, "nombreMax": 5, "reste": 5 },
{ "niveau": 7, "nombreMax": 4, "nombre": 0 }, { "niveau": 7, "nombreMax": 4, "reste": 4 },
{ "niveau": 8, "nombreMax": 3, "nombre": 0 }, { "niveau": 8, "nombreMax": 3, "reste": 3 },
{ "niveau": 9, "nombreMax": 2, "nombre": 0 }, { "niveau": 9, "nombreMax": 2, "reste": 2 },
{ "niveau": 10, "nombreMax": 1, "nombre": 0 }, { "niveau": 10, "nombreMax": 1, "reste": 1 },
{ "niveau": 11, "nombreMax": 1, "nombre": 0 } { "niveau": 11, "nombreMax": 1, "reste": 1 }
]; ];
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -267,23 +267,20 @@ export class RdDItemCompetence extends Item {
/* -------------------------------------------- */ /* -------------------------------------------- */
static computeResumeArchetype(competences) { static computeResumeArchetype(competences) {
const archetype = RdDItemCompetence.getLimitesArchetypes(); const computed = duplicate(limitesArchetypes);
competences.map(it => Math.max(0, it.system.niveau_archetype)) competences.map(it => Math.max(0, it.system.niveau_archetype))
.forEach(niveau => { .filter(n => n > 0)
archetype[niveau] = archetype[niveau] ?? { "niveau": niveau, "nombreMax": 0, "nombre": 0 }; .forEach(n => {
archetype[niveau].nombre = (archetype[niveau]?.nombre ?? 0) + 1; 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) { static triVisible(competences) {
return competences.filter(it => it.system.isVisible) return competences.filter(it => it.system.isVisible)
.sort((a, b) => RdDItemCompetence.compare(a,b)) .sort((a, b) => RdDItemCompetence.compare(a, b))
} }
static $positionTri(comp) { static $positionTri(comp) {
@ -308,7 +305,7 @@ export class RdDItemCompetence extends Item {
return 0; return 0;
} }
static compare(a,b) { static compare(a, b) {
const diff = RdDItemCompetence.$positionTri(a) - RdDItemCompetence.$positionTri(b); const diff = RdDItemCompetence.$positionTri(a) - RdDItemCompetence.$positionTri(b);
return diff ? diff : a.name.localeCompare(b.name); return diff ? diff : a.name.localeCompare(b.name);
} }

View File

@ -66,13 +66,13 @@
</span> </span>
</div> </div>
<div class="grid grid-2col"> <div class="grid grid-2col">
<div class="flex-group-left flexcol competence-column"> <div class="competence-column">
{{> "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.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.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/competence-categorie.html" competences=(filtreTriCompetences byCateg.specialisee) categorie="Compétences Spécialisées"}}
</div> </div>
<div class="competence-column">
<div class="flex-group-left flexcol competence-column"> {{> "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.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.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"}} {{> "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)}} {{#if (or system.attributs.hautrevant.value options.vueDetaillee)}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/competence-categorie.html" competences=(filtreTriCompetences byCateg.draconic) categorie="Draconic"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/competence-categorie.html" competences=(filtreTriCompetences byCateg.draconic) categorie="Draconic"}}
{{/if}} {{/if}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/xp-competences.html"}}
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,23 +1,30 @@
<div> <div>
<ul class="item-list"> <ul class="item-list">
<li class="item flexrow"> <li class="item flexrow">
<span class="generic-label">Stress transformé</span> <label class="attribut-label" for="system.compteurs.experience.value">Stress transformé</label>
<input class="compteur-edit" type="text" name="experience" value="{{system.compteurs.experience.value}}" data-dtype="number" size="3"/> {{#if options.vueDetaillee}}
<input class="compteur-edit" type="text" name="system.compteurs.experience.value" value="{{system.compteurs.experience.value}}" data-dtype="number" size="3"/>
{{else}}
<label name="system.compteurs.experience.value">{{system.compteurs.experience.value}}</label>
{{/if}}
</li> </li>
{{#if options.vueDetaillee}}
<li class="item flexrow"> <li class="item flexrow">
<span class="generic-label">Total XP compétences</span> <span class="generic-label">Total XP compétences</span>
<span class="competence-value">{{calc.competenceXPTotal}}</span> <span class="competence-value">{{calc.competenceXPTotal}}</span>
</li> </li>
{{#if options.vueDetaillee}} {{#if calc.comptageArchetype}}
<li><hr></li>
<li>Niveaux d'archétype à répartir</li> <li>Niveaux d'archétype à répartir</li>
{{#each calc.comptageArchetype as |archetype key|}} {{#each calc.comptageArchetype as |archetype key|}}
{{#if (lt archetype.nombre archetype.nombreMax)}} {{#if (gt archetype.reste 0)}}
<li class="item flexrow"> <li class="item flexrow">
<label class="generic-label">Archetype {{archetype.niveau}} : {{archetype.nombre}} / {{archetype.nombreMax}}</label> <label class="generic-label">Reste {{archetype.reste}} niveaux {{numberFormat archetype.niveau decimals=0 sign=true}} sur {{archetype.nombreMax}}</label>
</li> </li>
{{/if}} {{/if}}
{{/each}} {{/each}}
{{/if}} {{/if}}
{{/if}}
<li>&nbsp;</li>
</ul> </ul>
</div> </div>