Ajout bouton augmenter niveau #475

Merged
vincent.vandeme merged 1 commits from v1.4-xp-up into v1.4 2021-05-28 07:16:21 +02:00
6 changed files with 78 additions and 26 deletions

View File

@ -440,6 +440,14 @@ export class RdDActorSheet extends ActorSheet {
RdDUtility.toggleAfficheContenu(myID); RdDUtility.toggleAfficheContenu(myID);
this.render(true); this.render(true);
}); });
html.find('.carac-xp-augmenter').click((event) => {
let caracName = event.currentTarget.name.replace("augmenter.", "");
this.actor.updateCaracXPAuto(caracName);
});
html.find('.competence-xp-augmenter').click((event) => {
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCompetenceXPAuto(compName);
});
if (this.options.editCaracComp) { if (this.options.editCaracComp) {
// On carac change // On carac change

View File

@ -793,6 +793,40 @@ export class RdDActor extends Actor {
await this.update({ [`data.carac.${caracName}.xp`]: caracXP ?? 0 }); await this.update({ [`data.carac.${caracName}.xp`]: caracXP ?? 0 });
this.checkCaracXP(caracName); this.checkCaracXP(caracName);
} }
async updateCaracXPAuto(caracName) {
if (caracName == 'Taille') {
return;
}
let carac = RdDActor._findCaracByName(Misc.templateData(this).carac, caracName);
if (carac) {
carac = duplicate(carac);
let xp = Number(carac.xp);
let value = Number(carac.value);
while (xp >= RdDCarac.getCaracNextXp(value) && xp > 0) {
xp -= RdDCarac.getCaracNextXp(value);
value++;
}
carac.xp = xp;
carac.value = value;
await this.update({ [`data.carac.${caracName}`]: carac });
}
}
async updateCompetenceXPAuto(compName) {
let competence = this.getCompetence(compName);
if (competence) {
let compData = Misc.data(competence);
let xp = Number(compData.data.xp);
let niveau = Number(compData.data.niveau);
while (xp >= RdDItemCompetence.getCompetenceNextXp(niveau) && xp > 0) {
xp -= RdDItemCompetence.getCompetenceNextXp(niveau);
niveau++;
}
competence.update({
"data.xp": xp,
"data.niveau": niveau,
});
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async updateCreatureCompetence(compName, fieldName, compValue) { async updateCreatureCompetence(compName, fieldName, compValue) {

View File

@ -219,7 +219,7 @@ export class RdDUtility {
Handlebars.registerHelper('caseTmr-label', coord => TMRUtility.getTMRLabel(coord)); Handlebars.registerHelper('caseTmr-label', coord => TMRUtility.getTMRLabel(coord));
Handlebars.registerHelper('caseTmr-type', coord => TMRUtility.getTMRType(coord)); Handlebars.registerHelper('caseTmr-type', coord => TMRUtility.getTMRType(coord));
Handlebars.registerHelper('typeTmr-name', coord => TMRUtility.typeTmrName(coord)); Handlebars.registerHelper('typeTmr-name', coord => TMRUtility.typeTmrName(coord));
Handlebars.registerHelper('equals', (a, b) => a == b);
Handlebars.registerHelper('sortCompetence', competences => competences.sort((a, b) => { Handlebars.registerHelper('sortCompetence', competences => competences.sort((a, b) => {
if (a.name.startsWith("Survie") && b.name.startsWith("Survie")) { if (a.name.startsWith("Survie") && b.name.startsWith("Survie")) {
if (a.name.includes("Cité")) return -1; if (a.name.includes("Cité")) return -1;

View File

@ -714,7 +714,7 @@ ul, li {
border-radius: 0.25rem; border-radius: 0.25rem;
padding: 0.125rem; padding: 0.125rem;
flex: 1 1 5rem; flex: 1 1 5rem;
background: rgba(195, 152, 22, 0.5) !important; background: linear-gradient(30deg, rgba(191, 149, 63, 0.5), rgba(252, 246, 186, 0.5), rgba(179, 135, 40, 0.5), rgba(251, 245, 183, 0.5), rgba(170, 119, 28, 0.3)) !important;
} }
.blessures-list ul { .blessures-list ul {
@ -1473,7 +1473,7 @@ display: inline-flex;
.tooltip .ttt-xp { .tooltip .ttt-xp {
width: 250px; width: 250px;
background: rgba(220,220,210,0.95); background: rgba(220,220,210,0.95) !important;
border-radius: 6px; border-radius: 6px;
font-size: 0.9rem; font-size: 0.9rem;
padding: 3px 0; padding: 3px 0;

View File

@ -4,6 +4,12 @@
<img class="sheet-competence-img" src="{{img}}"/> <img class="sheet-competence-img" src="{{img}}"/>
<span class="competence-label">{{name}}</span> <span class="competence-label">{{name}}</span>
</a> </a>
{{#if data.isLevelUp}}
<span class="tooltiptext ttt-xp">Vous pouvez dépenser {{data.xpNext}} points d'Experience pour augmenter de 1 votre compétence {{name}}</span>
<a class="item-control competence-xp-augmenter" compname="{{name}}" title="Augmenter">
<i class="fas fa-arrow-alt-circle-up"></i>
</a>
{{/if}}
<input class="competence-value" type="text" compname="{{name}}" <input class="competence-value" type="text" compname="{{name}}"
value="{{numberFormat data.niveau decimals=0 sign=true}}" data-dtype="number" value="{{numberFormat data.niveau decimals=0 sign=true}}" data-dtype="number"
{{#unless @root.options.editCaracComp}}disabled{{/unless}} /> {{#unless @root.options.editCaracComp}}disabled{{/unless}} />
@ -20,12 +26,11 @@
value="{{numberFormat data.niveau_archetype decimals=0 sign=true}}" data-dtype="number" value="{{numberFormat data.niveau_archetype decimals=0 sign=true}}" data-dtype="number"
{{#unless @root.options.editCaracComp}}disabled{{/unless}} /> {{#unless @root.options.editCaracComp}}disabled{{/unless}} />
{{/if}} {{/if}}
{{#if data.isLevelUp}} {{#unless @root.options.hideControls}}
<span class="tooltiptext ttt-xp">Vous pouvez dépenser {{data.xpNext}} points d'Experience pour augmenter de 1 votre compétence {{name}}</span> <div class="item-controls">
{{/if}} <a class="item-control item-edit" title="Modifier"><i class="fas fa-edit"></i></a>
<div class="item-controls {{#if @root.options.hideControls}}hidden-controls{{/if}}"> <a class="item-control item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div> </div>
{{/unless}}
</li> </li>
{{/if}} {{/if}}

View File

@ -121,7 +121,7 @@
<ul class="carac-list alterne-list"> <ul class="carac-list alterne-list">
{{#each data.carac as |carac key|}} {{#each data.carac as |carac key|}}
{{#if carac.isLevelUp}} {{#if carac.isLevelUp}}
<li class="competence flexrow xp-level-up" data-attribute="{{key}}"> <li class="competence flexrow item-list xp-level-up" data-attribute="{{key}}">
{{else}} {{else}}
<li class="competence flexrow list-item" data-attribute="{{key}}"> <li class="competence flexrow list-item" data-attribute="{{key}}">
{{/if}} {{/if}}
@ -146,6 +146,11 @@
{{/if}} {{/if}}
<input class="carac-value" type="text" name="data.carac.{{key}}.value" value="{{carac.value}}" data-dtype="{{carac.type}}" {{#unless @root.options.editCaracComp}}disabled{{/unless}} /> <input class="carac-value" type="text" name="data.carac.{{key}}.value" value="{{carac.value}}" data-dtype="{{carac.type}}" {{#unless @root.options.editCaracComp}}disabled{{/unless}} />
<input class="carac-xp" type="text" name="data.carac.{{key}}.xp" value="{{carac.xp}}" data-dtype="number" {{#unless @root.options.editCaracComp}}disabled{{/unless}} /> <input class="carac-xp" type="text" name="data.carac.{{key}}.xp" value="{{carac.xp}}" data-dtype="number" {{#unless @root.options.editCaracComp}}disabled{{/unless}} />
{{#if carac.isLevelUp}}
<a class="item-control carac-xp-augmenter" name="augmenter.{{key}}" title="Augmenter">
<i class="fas fa-arrow-alt-circle-up"></i>
</a>
{{/if}}
{{/if}} {{/if}}
{{/if}} {{/if}}
</li> </li>