Expérience par le stress

- Vue détaillée (regroupe archétype et contrôles)
- Ajout d'un bouton pour mettre du stress dans une compétence
This commit is contained in:
Vincent Vandemeulebrouck 2021-11-23 02:11:24 +01:00
parent 863218f03c
commit b6b6acc4e3
7 changed files with 86 additions and 39 deletions

View File

@ -30,8 +30,7 @@ export class RdDActorSheet extends ActorSheet {
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }],
editCaracComp: false,
showCompNiveauBase: false,
montrerArchetype: false,
hideControls: true
vueDetaillee: false
});
}
@ -80,7 +79,7 @@ export class RdDActorSheet extends ActorSheet {
formData.competences.forEach(item => {
item.visible = !this.options.showCompNiveauBase || !RdDItemCompetence.isNiveauBase(item);
RdDItemCompetence.levelUp(item);
RdDItemCompetence.levelUp(item, formData.data.compteurs.experience.value);
});
Object.values(formData.data.carac).forEach(c => {
@ -414,7 +413,7 @@ export class RdDActorSheet extends ActorSheet {
});
}
html.find('#show-hide-competences').click(async event => {
html.find('.show-hide-competences').click(async event => {
this.options.showCompNiveauBase = !this.options.showCompNiveauBase;
this.render(true);
});
@ -422,13 +421,9 @@ export class RdDActorSheet extends ActorSheet {
this.options.editCaracComp = !this.options.editCaracComp;
this.render(true);
});
html.find('#show-hide-archetype').click(async event => {
this.options.montrerArchetype = !this.options.montrerArchetype;
this.render(true);
});
html.find('.lock-unlock-controls').click(async event => {
console.log("CONTROLS", this.options.hideControls)
this.options.hideControls = !this.options.hideControls;
html.find('.vue-detaillee').click(async event => {
console.log("CONTROLS", this.options.vueDetaillee)
this.options.vueDetaillee = !this.options.vueDetaillee;
this.render(true);
});

View File

@ -922,6 +922,36 @@ export class RdDActor extends Actor {
}
}
async updateCompetenceStress(idOrName) {
const competence = this.getCompetence(idOrName);
if (!competence) {
return;
}
const compData = Misc.data(competence);
const niveau = Number(compData.data.niveau);
const stressTransforme = Misc.data(this).data.compteurs.experience.value;
const xpRequis = RdDItemCompetence.getCompetenceNextXp(niveau) - compData.data.xp;
if (stressTransforme <= 0 || niveau >= compData.data.niveau_archetype || xpRequis <=0) {
ui.notifications.info(`La compétence ne peut pas augmenter!
stress disponible: ${stressTransforme}
expérience requise: ${xpRequis}
niveau : ${niveau}
archétype : ${compData.data.niveau_archetype}`);
return;
}
const xpUtilise = Math.min(stressTransforme, xpRequis);
const stressTransformeRestant = Math.max(0, stressTransforme - xpUtilise);
const gainNiveau = xpUtilise>=xpRequis ? 1 : 0;
await this.update({ "data.compteurs.experience.value": stressTransformeRestant });
const nouveauNiveau = niveau + gainNiveau;
await competence.update({
"data.xp": Math.max(compData.data.xp - xpRequis, 0),
"data.niveau": nouveauNiveau,
});
this.updateExperienceLog('Dépense stress', xpUtilise, `Stress en ${competence.name} ${gainNiveau? "pour passer à "+nouveauNiveau : ""}`);
}
/* -------------------------------------------- */
async updateCreatureCompetence(idOrName, fieldName, compValue) {
let competence = this.getCompetence(idOrName);

View File

@ -160,7 +160,6 @@ export class RdDItemCompetence extends Item {
return competence_xp_cumul[to] - competence_xp_cumul[from];
}
/* -------------------------------------------- */
static computeCompetenceXPCost(competence) {
const compData = Misc.data(competence);
@ -186,9 +185,15 @@ export class RdDItemCompetence extends Item {
}
/* -------------------------------------------- */
static levelUp(itemData) {
static levelUp(itemData, stressTransforme) {
itemData.data.xpNext = RdDItemCompetence.getCompetenceNextXp(itemData.data.niveau);
itemData.data.isLevelUp = itemData.data.xp >= itemData.data.xpNext;
const xpManquant = itemData.data.xpNext - itemData.data.xp;
itemData.data.isLevelUp = xpManquant <= 0;
itemData.data.isStressLevelUp = (xpManquant > 0 && stressTransforme >= xpManquant && itemData.data.niveau < itemData.data.niveau_archetype);
itemData.data.stressXpMax = 0;
if (xpManquant > 0 && stressTransforme > 0 && itemData.data.niveau < itemData.data.niveau_archetype) {
itemData.data.stressXpMax = Math.min(xpManquant , stressTransforme);
}
}
/* -------------------------------------------- */

File diff suppressed because one or more lines are too long

View File

@ -738,6 +738,15 @@ ul, li {
flex: 1 1 5rem;
background: var(--gradient-gold) !important;
}
.niveau-archetype {
background: var(--gradient-silver-light) !important;
}
.fa-arrow-alt-circle-up.allouer-stress {
color: rgba(83, 60, 14, 0.8);
}
.fa-arrow-alt-circle-up.allouer-stress-level-up {
color: rgba(191, 149, 63, 0.8);
}
.blessures-list ul {
display: flex;

View File

@ -21,16 +21,22 @@
value="{{numberFormat data.xp_sort decimals=0 sign=false}}" data-dtype="number"
{{#unless @root.options.editCaracComp}}disabled{{/unless}}/>
{{/if}}
{{#if @root.options.montrerArchetype}}
<input class="competence-archetype" type="text" compname="{{name}}" name="comp-archetype-{{name}}"
{{#if @root.options.vueDetaillee}}
<div class="item-controls">
{{#if data.stressXpMax}}
<a class="item-control competence-stress-augmenter" compname="{{name}}"
title="Dépenser {{data.stressXpMax}} points de stress {{#if data.isStressLevelUp}} pour augmenter d'un niveau {{/if}}">
<i class="fas fa-arrow-alt-circle-up allouer-stress{{#if data.isStressLevelUp}}-level-up{{/if}}"></i>
</a>
{{/if}}
<input class="competence-archetype niveau-archetype" type="text" compname="{{name}}" name="comp-archetype-{{name}}"
value="{{numberFormat data.niveau_archetype decimals=0 sign=true}}" data-dtype="number"
{{#unless @root.options.editCaracComp}}disabled{{/unless}} />
{{/if}}
{{#unless @root.options.hideControls}}
<div class="item-controls">
<a class="item-control item-edit" title="Modifier"><i class="fas fa-edit"></i></a>
{{#if @root.options.isGM}}
<a class="item-control item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
{{/if}}
</div>
{{/unless}}
{{/if}}
</li>
{{/if}}

View File

@ -212,15 +212,14 @@
<span><a class="lock-unlock-sheet"><img class="small-button-container"
src="systems/foundryvtt-reve-de-dragon/icons/{{#if options.editCaracComp}}unlocked.svg{{else}}locked.svg{{/if}}" alt="blocker/débloquer"
>{{#if options.editCaracComp}}Verrouiller{{else}}Déverrouiller{{/if}}</a></span>
<span><a id="show-hide-competences"><img class="small-button-container"
src="systems/foundryvtt-reve-de-dragon/icons/{{#if options.showCompNiveauBase}}no-filter.svg{{else}}filter.svg{{/if}}" alt="filter/montrer tout"
>{{#if options.showCompNiveauBase}}Montrer tout{{else}}Filtrer{{/if}}</a></span>
<span><a id="show-hide-archetype"><img class="small-button-container"
src="systems/foundryvtt-reve-de-dragon/icons/{{#if options.montrerArchetype}}no-filter.svg{{else}}filter.svg{{/if}}" alt="filter/montrer l'archétype"
>{{#if options.montrerArchetype}}Masquer l'archétype{{else}}Voir l'archétype{{/if}}</a></span>
<span><a class="lock-unlock-controls"><i class="fas fa-lock{{#if options.hideControls}}-open{{/if}}"></i>
{{#if options.hideControls}}Contrôles On{{else}}Contrôles Off{{/if}}
</a></span>
<span><a class="show-hide-competences"><img class="small-button-container"
src="systems/foundryvtt-reve-de-dragon/icons/{{#if options.showCompNiveauBase}}no-filter.svg{{else}}filter.svg{{/if}}" alt="filter/montrer tout">
{{#if options.showCompNiveauBase}}Montrer tout{{else}}Filtrer{{/if}}</a>
</span>
<span><a class="vue-detaillee">
<i class="fas {{#if options.vueDetaillee}}fa-eye-slash{{else}}fa-eye{{/if}}"></i>
{{#if options.vueDetaillee}}Vue simplifiée{{else}}Vue détaillée{{/if}}</a>
</span>
</div>
<div class="grid grid-2col">
<div class="flex-group-left flexcol competence-column">
@ -234,7 +233,7 @@
{{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-categorie-competences-partial.html" competences=(sortCompetence competenceByCategory.tir) categorie="Compétences de Tir"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-categorie-competences-partial.html" competences=(sortCompetence competenceByCategory.lancer) categorie="Compétences de Lancer"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-categorie-competences-partial.html" competences=(sortCompetence competenceByCategory.connaissance) categorie="Connaissances"}}
{{#if (or data.attributs.hautrevant.value options.montrerArchetype)}}
{{#if (or data.attributs.hautrevant.value options.vueDetaillee)}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor-sheet-categorie-competences-partial.html" competences=(sortCompetence competenceByCategory.draconic) categorie="Draconic"}}
{{/if}}
@ -249,11 +248,14 @@
<span class="generic-label">Total XP compétences</span>
<span class="competence-value">{{calc.competenceXPTotal}}</span>
</li>
{{#if options.montrerArchetype}}
{{#if options.vueDetaillee}}
<li>Niveaux d'archétype à répartir</li>
{{#each calc.comptageArchetype as |archetype key|}}
{{#if (lt archetype.nombre archetype.nombreMax)}}
<li class="item flexrow">
<label class="generic-label">Archetype {{archetype.niveau}} : {{archetype.nombre}} / {{archetype.nombreMax}}</label>
</li>
{{/if}}
{{/each}}
{{/if}}
</ul>