forked from public/foundryvtt-reve-de-dragon
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:
@ -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);
|
||||
|
Reference in New Issue
Block a user