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
Showing only changes of commit 41bb5ca919 - Show all commits

View File

@ -440,7 +440,15 @@ export class RdDActorSheet extends ActorSheet {
RdDUtility.toggleAfficheContenu(myID);
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) {
// On carac change
html.find('.carac-value').change((event) => {

View File

@ -793,6 +793,40 @@ export class RdDActor extends Actor {
await this.update({ [`data.carac.${caracName}.xp`]: caracXP ?? 0 });
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) {
@ -2002,7 +2036,7 @@ export class RdDActor extends Actor {
value: niveauSuivant,
xp: carac.xp
}
if (display){
if (display) {
ChatUtility.createChatMessage(this.name, "default", {
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-carac-xp.html`, checkXp)
});
@ -2812,7 +2846,7 @@ export class RdDActor extends Actor {
await this._xpCarac(xpData);
return xpData;
}
/* -------------------------------------------- */
async _xpCompetence(xpData) {
if (xpData.competence) {
@ -2823,7 +2857,7 @@ export class RdDActor extends Actor {
this.updateExperienceLog("XP", xpData.xp, "XP gagné en " + xpData.competence.name);
}
}
/* -------------------------------------------- */
async _xpCarac(xpData) {
if (xpData.xpCarac > 0) {

View File

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

View File

@ -471,15 +471,15 @@ table {border: 1px solid #7a7971;}
.rdd-roll-part{
align-items: center;
border-radius: 6px; padding: 3px;
background:linear-gradient(30deg, rgba(191, 149, 63, 0.3), rgba(252, 246, 186, 0.3), rgba(179, 135, 40, 0.3), rgba(251, 245, 183, 0.3), rgba(170, 119, 28, 0.3));
background: linear-gradient(30deg, rgba(191, 149, 63, 0.3), rgba(252, 246, 186, 0.3), rgba(179, 135, 40, 0.3), rgba(251, 245, 183, 0.3), rgba(170, 119, 28, 0.3));
}
.rdd-roll-sign{
border-radius: 6px; padding: 3px;
background:linear-gradient(30deg, rgba(61, 55, 93, 0.3), rgba(178, 179, 196, 0.3), rgba(59, 62, 63, 0.6), rgba(206, 204, 199, 0.3), rgba(61, 46, 49, 0.3));
background: linear-gradient(30deg, rgba(61, 55, 93, 0.3), rgba(178, 179, 196, 0.3), rgba(59, 62, 63, 0.6), rgba(206, 204, 199, 0.3), rgba(61, 46, 49, 0.3));
}
.rdd-roll-norm{
border-radius: 6px; padding: 3px;
background:linear-gradient(30deg, rgba(7, 76, 0, 0.3), rgba(66, 163, 65, 0.2), rgba(184, 226, 163, 0.1), rgba(66, 163, 65, 0.2), rgba(184, 226, 163, 0.3));
background: linear-gradient(30deg, rgba(7, 76, 0, 0.3), rgba(66, 163, 65, 0.2), rgba(184, 226, 163, 0.1), rgba(66, 163, 65, 0.2), rgba(184, 226, 163, 0.3));
}
.rdd-roll-notSign, .rdd-roll-echec{
border-radius: 6px; padding: 3px;
@ -714,7 +714,7 @@ ul, li {
border-radius: 0.25rem;
padding: 0.125rem;
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 {
@ -1473,7 +1473,7 @@ display: inline-flex;
.tooltip .ttt-xp {
width: 250px;
background: rgba(220,220,210,0.95);
background: rgba(220,220,210,0.95) !important;
border-radius: 6px;
font-size: 0.9rem;
padding: 3px 0;

View File

@ -4,6 +4,12 @@
<img class="sheet-competence-img" src="{{img}}"/>
<span class="competence-label">{{name}}</span>
</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}}"
value="{{numberFormat data.niveau decimals=0 sign=true}}" data-dtype="number"
{{#unless @root.options.editCaracComp}}disabled{{/unless}} />
@ -20,12 +26,11 @@
value="{{numberFormat data.niveau_archetype decimals=0 sign=true}}" data-dtype="number"
{{#unless @root.options.editCaracComp}}disabled{{/unless}} />
{{/if}}
{{#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>
{{/if}}
<div class="item-controls {{#if @root.options.hideControls}}hidden-controls{{/if}}">
<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>
{{#unless @root.options.hideControls}}
<div class="item-controls">
<a class="item-control item-edit" title="Modifier"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
</div>
{{/unless}}
</li>
{{/if}}

View File

@ -121,7 +121,7 @@
<ul class="carac-list alterne-list">
{{#each data.carac as |carac key|}}
{{#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}}
<li class="competence flexrow list-item" data-attribute="{{key}}">
{{/if}}
@ -136,16 +136,21 @@
<label class="carac-xp"/>
{{else}}
{{#if carac.isLevelUp}}
<span class="carac-label tooltip" name="data.carac.{{key}}.label">
<span class="tooltiptext ttt-xp">
Vous pouvez dépenser {{carac.xpNext}} points d'Experience pour augmenter de 1 votre caractéristique {{carac.label}}
</span>
<a name={{key}}>{{carac.label}}</a></span>
{{else}}
<span class="carac-label tooltip" name="data.carac.{{key}}.label"><a name={{key}}>{{carac.label}}</a></span>
<span class="carac-label tooltip" name="data.carac.{{key}}.label">
<span class="tooltiptext ttt-xp">
Vous pouvez dépenser {{carac.xpNext}} points d'Experience pour augmenter de 1 votre caractéristique {{carac.label}}
</span>
<a name={{key}}>{{carac.label}}</a></span>
{{else}}
<span class="carac-label tooltip" name="data.carac.{{key}}.label"><a name={{key}}>{{carac.label}}</a></span>
{{/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-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}}
<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}} />
{{/if}}
{{/if}}
</li>