From 368a5b369b028597c9dab036187d6e49710873b8 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 13 Nov 2020 15:40:53 +0100 Subject: [PATCH] fix: autoclose TMR on success MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ajout de isSuccess aux cas possibles pour lisibilité et éviter les erreurs bêtes --- module/rdd-resolution-table.js | 27 +++++++++++++-------------- module/rdd-tmr-dialog.js | 8 ++++---- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/module/rdd-resolution-table.js b/module/rdd-resolution-table.js index a2427989..d10b16f5 100644 --- a/module/rdd-resolution-table.js +++ b/module/rdd-resolution-table.js @@ -40,13 +40,13 @@ const specialResults = [ const reussites = [ - { code: "etotal", isPart: false, isSign: false, isSuccess: false, isEPart: true, isETotal: true, tache: -4, qualite: -6, quality: "Echec total", condition: (target, roll) => roll >= target.etotal && roll <= 100 }, - { code: "epart", isPart: false, isSign: false, isSuccess: false, isEPart: true, isETotal: false, tache: -2, qualite: -4, quality: "Echec particulier", condition: (target, roll) => (roll >= target.epart && roll < target.etotal) }, - { code: "echec", isPart: false, isSign: false, isSuccess: false, isEPart: false, isETotal: false, tache: 0, qualite: -2, quality: "Echec normal", condition: (target, roll) => (roll > target.score && roll < target.etotal) }, - { code: "norm", isPart: false, isSign: false, isSuccess: true, isEPart: false, isETotal: false, tache: 1, qualite: 0, quality: "Réussite normale", condition: (target, roll) => (roll > target.sign && roll <= target.score) }, - { code: "sign", isPart: false, isSign: true, isSuccess: true, isEPart: false, isETotal: false, tache: 2, qualite: 1, quality: "Réussite significative", condition: (target, roll) => (roll > target.part && roll <= target.sign) }, - { code: "part", isPart: true, isSign: true, isSuccess: true, isEPart: false, isETotal: false, tache: 3, qualite: 2, quality: "Réussite Particulière!", condition: (target, roll) => (roll > 0 && roll <= target.part) }, - { code: "error", isPart: false, isSign: false, isSuccess: false, isEPart: true, isETotal: true, tache: 0, qualite: 0, quality: "Jet de dés invalide", condition: (target, roll) => (roll <= 0 || roll > 100) } + { code: "etotal", isPart: false, isSign: false, isSuccess: false, isEchec: true, isEPart: true, isETotal: true, tache: -4, qualite: -6, quality: "Echec total", condition: (target, roll) => roll >= target.etotal && roll <= 100 }, + { code: "epart", isPart: false, isSign: false, isSuccess: false, isEchec: true, isEPart: true, isETotal: false, tache: -2, qualite: -4, quality: "Echec particulier", condition: (target, roll) => (roll >= target.epart && roll < target.etotal) }, + { code: "echec", isPart: false, isSign: false, isSuccess: false, isEchec: true, isEPart: false, isETotal: false, tache: 0, qualite: -2, quality: "Echec normal", condition: (target, roll) => (roll > target.score && roll < target.etotal) }, + { code: "norm", isPart: false, isSign: false, isSuccess: true, isEchec: false, isEPart: false, isETotal: false, tache: 1, qualite: 0, quality: "Réussite normale", condition: (target, roll) => (roll > target.sign && roll <= target.score) }, + { code: "sign", isPart: false, isSign: true, isSuccess: true, isEchec: false, isEPart: false, isETotal: false, tache: 2, qualite: 1, quality: "Réussite significative", condition: (target, roll) => (roll > target.part && roll <= target.sign) }, + { code: "part", isPart: true, isSign: true, isSuccess: true, isEchec: false, isEPart: false, isETotal: false, tache: 3, qualite: 2, quality: "Réussite Particulière!", condition: (target, roll) => (roll > 0 && roll <= target.part) }, + { code: "error", isPart: false, isSign: false, isSuccess: false, isEchec: true, isEPart: true, isETotal: true, tache: 0, qualite: 0, quality: "Jet de dés invalide", condition: (target, roll) => (roll <= 0 || roll > 100) } ]; const reussiteSignificative = reussites.find(r => r.code == "sign"); @@ -86,13 +86,12 @@ export class RdDResolutionTable { return duplicate(this.resolutionTable[carac][difficulte + 10]); } - static buildXpMessage(rolled, level) - { + static buildXpMessage(rolled, level) { if (rolled.isPart && level < 0) { - const xp = Math.abs(level); - const xpcarac = Math.floor(xp / 2); - const xpcomp = xp - xpcarac; - return "
Points d'expérience gagnés ! Carac: " + xpcarac + ", Comp: " + xpcomp; + const xp = Math.abs(level); + const xpcarac = Math.floor(xp / 2); + const xpcomp = xp - xpcarac; + return "
Points d'expérience gagnés ! Carac: " + xpcarac + ", Comp: " + xpcomp; } return ""; } @@ -105,7 +104,7 @@ export class RdDResolutionTable { if (reussite.isSign) { return reussiteNormale; } - if (reussite.isSuccess){ + if (reussite.isSuccess) { return echecNormal; } } diff --git a/module/rdd-tmr-dialog.js b/module/rdd-tmr-dialog.js index e2f27793..5774d3dd 100644 --- a/module/rdd-tmr-dialog.js +++ b/module/rdd-tmr-dialog.js @@ -138,7 +138,7 @@ export class RdDTMRDialog extends Dialog { const roll = RdDResolutionTable.roll(carac, difficulte); - if ( !roll.isSuccess) { + if (roll.isEchec) { TMRUtility.processRencontreEchec( this.actor, this.currentRencontre); ChatMessage.create( { title: "TMR", content: "Vous avez échoué à votre maîtrise d'un " . this.currentRencontre.name + " de force " + this.currentRencontre.force + @@ -230,11 +230,11 @@ export class RdDTMRDialog extends Dialog { let level = draconic.data.niveau - 7; let rolled = RdDResolutionTable.roll(carac, level);//RdDResolutionTable.computeChances(carac, level); - console.log(">>>>", rolled); + console.log("manageCaseHumide >>", rolled); - this.toclose = rolled.isSuccess; let content = ""; - if (!rolled.isSuccess) { + this.toclose = rolled.isEchec; + if (rolled.isEchec) { content += "Vous êtes entré sur une case humide, et vous avez raté votre maîtrise ! Vous quittez les Terres Médianes !" } else {