Clean Recontres

1d7 ne peut pas être 8
This commit is contained in:
Vincent Vandemeulebrouck 2020-11-12 18:44:47 +01:00
parent 1cb7d1f251
commit 6b50dc20d6
2 changed files with 11 additions and 22 deletions

View File

@ -159,28 +159,16 @@ export class RdDTMRDialog extends Dialog {
async manageRencontre(coordTMR, cellDescr) async manageRencontre(coordTMR, cellDescr)
{ {
// Roll until diffent than '8' // Roll until diffent than '8'
let rencontre
this.currentRencontre = undefined; this.currentRencontre = undefined;
for (let previousRencontre of this.rencontresExistantes ) {
if ( previousRencontre.coord == coordTMR) let rencontre = this.rencontresExistantes.find(prev => prev.coord == coordTMR);
rencontre = previousRencontre.rencontre; if (rencontre == undefined && new Roll("d7").roll().total == 7) {
}
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 = TMRUtility.rencontreTMRRoll(coordTMR, cellDescr);
rencontre.force = new Roll(rencontre.data.force).roll().total;
}
}
} }
if (rencontre) { // Manages it if (rencontre) { // Manages it
this.currentRencontre = duplicate(rencontre); 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 + "<br>", content: "Vous recontrez un " + rencontre.name + " de force " + rencontre.force + "<br>",
buttons: { buttons: {
derober: { derober: {
@ -200,7 +188,7 @@ export class RdDTMRDialog extends Dialog {
} }
} }
} ); } );
diag.render(true); dialog.render(true);
} }
} }

View File

@ -269,13 +269,14 @@ export class TMRUtility {
let val = new Roll("d100").roll().total; let val = new Roll("d100").roll().total;
//console.log("Rencontre !!!!", val, coordTMR, cellDescr); //console.log("Rencontre !!!!", val, coordTMR, cellDescr);
for( let renc of rencontresTable) { for( let rencontre of rencontresTable) {
let scoreDef = renc.data[cellDescr.type]; let scoreDef = rencontre.data[cellDescr.type];
let min = scoreDef.substr(0,2); let min = scoreDef.substr(0,2);
let max = scoreDef.substr(3,2); let max = scoreDef.substr(3,2);
//console.log(val, scoreDef, min, max); //console.log(val, scoreDef, min, max);
if ( val >= min && val <= max) { if ( val >= min && val <= max) {
return renc; rencontre.force = new Roll(rencontre.data.force).roll().total;
return rencontre;
} }
} }
} }