diff --git a/module/actor.js b/module/actor.js index 90b15898..2465332c 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1259,9 +1259,8 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ - async _appliquerAjoutExperience(rollData) { - // TODO: si pas de compétence, minimum 1 pour carac - // TODO: appliquer l'expérience automatiquement + async _appliquerAjoutExperience(rollData) { + this.appliquerExperience( rollData.rolled, rollData.selectedCarac.label, (rollData.competence) ? rollData.competence.data.name: undefined ); let xpmsg = RdDResolutionTable.buildXpMessage(rollData.rolled, rollData.finalLevel); let message = ChatUtility.prepareChatMessage('gmroll', this.name); message.content = "" + rollData.selectedCarac.label + "" @@ -1515,8 +1514,31 @@ export class RdDActor extends Actor { return game.system.rdd.calendrier.getAjustementAstrologique(this.data.data.heure); } + /* -------------------------------------------- */ + appliquerExperience( rolled, caracName, competenceName = undefined ) { + // TODO gestion derobe/tir/lance/melee + if (caracName == 'derobee') caracName = 'agilite'; + + if ( rolled.isPart && rolled.finalLevel < 0) { + if ( !compentenceName) { + this.actor.data.data.carac[caracName].xp += 1; + } else { + let competence = RdDUtility.findCompetence( this.data.items, competenceName ); + let xpCarac = Math.floor(Math.abs(rolled.finalLevel) / 2); + if ( xpCarac == 0 ) { + competence.data.xp += 1; // XP en priorité à la compétencence + } else + competence.data.xp += Math.ceil(Math.abs(rolled.finalLevel) / 2); // XP majoritaire en compentece (ie cas impair) + this.actor.data.data.carac[caracName].xp += xpCarac; + } + } + } + /* -------------------------------------------- */ async ajouteNombreAstral( data ) { + // Gestion expérience (si existante) + this.appliquerExperience( request.rolled, "vue", "astrologie"); + // Ajout du nombre astral const item = {name: "Nombre Astral", type: "nombreastral", data: { value: data.nbAstral, istrue: data.isvalid, jourindex: Number(data.date), jourlabel: game.system.rdd.calendrier.getDateFromIndex( Number(data.date) ) } }; diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js index a8e66c93..2040fee1 100644 --- a/module/rdd-calendrier.js +++ b/module/rdd-calendrier.js @@ -239,6 +239,7 @@ export class RdDCalendrier extends Application { let nbAstral = this.getNombreAstral( request.date ); let nbAstralFaux = nbAstral; request.isValid = true; + request.rolled = rolled; if ( !rolled .isSuccess ) { request.isValid = false; while ( nbAstralFaux == nbAstral ) { diff --git a/templates/calendar-astrologie-template.html b/templates/calendar-astrologie-template.html index 250cd644..aa554949 100644 --- a/templates/calendar-astrologie-template.html +++ b/templates/calendar-astrologie-template.html @@ -1,7 +1,7 @@
-

Astrologie

+

Horoscope