Clean rencontres

This commit is contained in:
Vincent Vandemeulebrouck 2020-11-12 23:35:29 +01:00
parent 1cb7d1f251
commit a9d005310f
2 changed files with 12 additions and 23 deletions

View File

@ -138,7 +138,7 @@ export class RdDTMRDialog extends Dialog {
const roll = RdDResolutionTable.roll(carac, difficulte); const roll = RdDResolutionTable.roll(carac, difficulte);
if ( roll.roll > scoreDef.score ) { if ( !roll.isSuccess) {
TMRUtility.processRencontreEchec( this.actor, this.currentRencontre); TMRUtility.processRencontreEchec( this.actor, this.currentRencontre);
ChatMessage.create( { title: "TMR", content: "Vous avez <strong>échoué</strong> à votre maîtrise d'un " . this.currentRencontre.name + " de force " + ChatMessage.create( { title: "TMR", content: "Vous avez <strong>échoué</strong> à votre maîtrise d'un " . this.currentRencontre.name + " de force " +
this.currentRencontre.force + this.currentRencontre.force +
@ -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) {
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 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;
} }
} }
} }