diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 6c43d5c1..6ec548c6 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -249,7 +249,7 @@ export class RdDActorSheet extends RdDBaseActorSheet { // Points de reve actuel this.html.find('.ptreve-actuel a').click(async event => { - this.actor.rollCarac('reve-actuel'); + this.actor.rollCarac('reve-actuel', true); }); // Roll Weapon1 diff --git a/module/actor.js b/module/actor.js index 59a3402f..db382a10 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1764,6 +1764,7 @@ export class RdDActor extends RdDBaseActor { forceAlcool: forceAlcool, nbDoses: nbDoses, selectedCarac: this.system.sante.vie, + jetResistance: 'ethylisme', carac: this.system.carac, caracValue: this.system.sante.vie.max, finalLevel: etat + forceAlcool - nbDoses @@ -1972,7 +1973,7 @@ export class RdDActor extends RdDBaseActor { async appliquerAjoutExperience(rollData, hideChatMessage = 'show') { if (!this.isPersonnage()) return; hideChatMessage = hideChatMessage == 'hide' || (Misc.isRollModeHiddenToPlayer() && !game.user.isGM) - let xpData = await this._appliquerExperience(rollData.rolled, rollData.selectedCarac.label, rollData.competence); + let xpData = await this._appliquerExperience(rollData.rolled, rollData.selectedCarac.label, rollData.competence, rollData.jetResistance); if (xpData) { const content = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-gain-xp.html`, xpData); if (hideChatMessage) { @@ -2197,10 +2198,11 @@ export class RdDActor extends RdDBaseActor { } /* -------------------------------------------- */ - async rollCarac(caracName) { + async rollCarac(caracName, jetResistance = undefined) { let rollData = { selectedCarac: this.getCaracByName(caracName), - competences: this.itemTypes['competence'] + competences: this.itemTypes['competence'], + jetResistance: jetResistance ? caracName : undefined }; const dialog = await RdDRoll.create(this, rollData, @@ -2754,7 +2756,7 @@ export class RdDActor extends RdDBaseActor { } /* -------------------------------------------- */ - async _appliquerExperience(rolled, caracName, competence) { + async _appliquerExperience(rolled, caracName, competence, jetResistance) { if (!this.isPersonnage()) return; // Pas d'XP if (!rolled.isPart || rolled.finalLevel >= 0) { @@ -2771,16 +2773,19 @@ export class RdDActor extends RdDBaseActor { if (caracName == 'Vie') caracName = 'constitution'; if (caracName == 'derobee') caracName = 'agilite'; if (caracName == 'reve-actuel') caracName = 'reve'; - let xp = Math.abs(rolled.finalLevel); // impair: arrondi inférieur en carac let xpCarac = competence ? Math.floor(xp / 2) : Math.max(Math.floor(xp / 2), 1); - let xpData = { - alias: this.name, - caracName: caracName, xpCarac: xpCarac, - competence: competence, xpCompetence: competence ? xp - xpCarac : 0 - }; + const xpCompetence = competence ? xp - xpCarac : 0; + if (jetResistance) { + const message = `Jet de résistance ${jetResistance}, l'expérience est limitée à 1`; + ui.notifications.info(message); + console.log(message) + // max 1 xp sur jets de résistance + xpCarac = Math.min(1, xpCarac); + } + let xpData = { alias: this.name, caracName, xpCarac, competence, xpCompetence }; await this._xpCompetence(xpData); await this._xpCarac(xpData);