diff --git a/module/rdd-tmr-dialog.js b/module/rdd-tmr-dialog.js index d3a24fd2..e2f27793 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.roll > scoreDef.score ) { + if ( !roll.isSuccess) { 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 + @@ -159,28 +159,16 @@ export class RdDTMRDialog extends Dialog { async manageRencontre(coordTMR, cellDescr) { // Roll until diffent than '8' - let rencontre this.currentRencontre = undefined; - for (let previousRencontre of this.rencontresExistantes ) { - if ( previousRencontre.coord == coordTMR) - rencontre = previousRencontre.rencontre; + + let rencontre = this.rencontresExistantes.find(prev => prev.coord == coordTMR); + if (rencontre == undefined && new Roll("d7").roll().total == 7) { + rencontre = TMRUtility.rencontreTMRRoll(coordTMR, cellDescr); } - if ( rencontre == undefined ) { - let val = 8; - while (val == 8) { - let myroll = new Roll("d7"); - myroll.roll(); - val = myroll.total; - if ( val == 7 ) { - rencontre = TMRUtility.rencontreTMRRoll(coordTMR, cellDescr); - rencontre.force = new Roll(rencontre.data.force).roll().total; - } - } - } - + if (rencontre) { // Manages it this.currentRencontre = duplicate(rencontre); - let diag = new Dialog( { title: "Rencontre en TMR!", + let dialog = new Dialog( { title: "Rencontre en TMR!", content: "Vous recontrez un " + rencontre.name + " de force " + rencontre.force + "
", buttons: { derober: { @@ -200,7 +188,7 @@ export class RdDTMRDialog extends Dialog { } } } ); - diag.render(true); + dialog.render(true); } } diff --git a/module/tmr-utility.js b/module/tmr-utility.js index b3df2293..7ed0a3b1 100644 --- a/module/tmr-utility.js +++ b/module/tmr-utility.js @@ -269,13 +269,14 @@ export class TMRUtility { let val = new Roll("d100").roll().total; //console.log("Rencontre !!!!", val, coordTMR, cellDescr); - for( let renc of rencontresTable) { - let scoreDef = renc.data[cellDescr.type]; + for( let rencontre of rencontresTable) { + let scoreDef = rencontre.data[cellDescr.type]; let min = scoreDef.substr(0,2); let max = scoreDef.substr(3,2); //console.log(val, scoreDef, min, max); if ( val >= min && val <= max) { - return renc; + rencontre.force = new Roll(rencontre.data.force).roll().total; + return rencontre; } } }