forked from public/foundryvtt-reve-de-dragon
Ajout bouton augmenter niveau
This commit is contained in:
@ -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) {
|
||||
|
Reference in New Issue
Block a user