From 40027882e40321ae5983346d3ab9cb136635cbed Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sat, 21 Nov 2020 09:10:31 +0100 Subject: [PATCH] #27 Gestion des rencontres --- module/actor.js | 12 ++++++------ module/rdd-dice.js | 10 ++++++---- module/rdd-resolution-table.js | 8 ++++---- system.json | 2 +- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/module/actor.js b/module/actor.js index 6aa2251a..79d9cd52 100644 --- a/module/actor.js +++ b/module/actor.js @@ -126,7 +126,7 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async performRoll(rollData) { - let rolled = RdDResolutionTable.roll(rollData.carac, rollData.finalLevel); + let rolled = await RdDResolutionTable.roll(rollData.carac, rollData.finalLevel); //rolled.isPart = true; // Pour tester le particulières rollData.rolled = rolled; // garder le résultat console.log("performRoll", rollData, rolled) @@ -411,13 +411,13 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ - combattreReveDeDragon(force){ + async combattreReveDeDragon(force){ let draconic = this.getBestDraconic(); let niveau = Math.max(0, draconic.data.niveau); let etat = this.data.data.compteurs.etat.value; let difficulte = niveau - etat - force; let reveActuel = this.getReveActuel(); - let rolled = RdDResolutionTable.roll(reveActuel, difficulte); + let rolled = await RdDResolutionTable.roll(reveActuel, difficulte); // TODO: xp particulière console.log("combattreReveDeDragon", rolled ); return this.appliquerReveDeDragon(rolled, force); @@ -913,8 +913,8 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ - _stressRoll() { - let result = RdDResolutionTable.roll(this.data.data.carac.reve.value, 0); + async _stressRoll() { + let result = await RdDResolutionTable.roll(this.data.data.carac.reve.value, 0); console.log("_stressRoll", result); switch (result.code) { case "sign": return { factor: 0.75, comment: " (75%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" } @@ -924,7 +924,7 @@ export class RdDActor extends Actor { case "etotal": return { factor: 0, comment: " (0%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" } case "part": { - let second = RdDResolutionTable.roll(this.data.data.carac.reve.value, 0); + let second = await RdDResolutionTable.roll(this.data.data.carac.reve.value, 0); console.log("_stressRoll", second); switch (second.code) { case "part": case "sign": diff --git a/module/rdd-dice.js b/module/rdd-dice.js index e2524185..3d208c13 100644 --- a/module/rdd-dice.js +++ b/module/rdd-dice.js @@ -1,15 +1,17 @@ export class RdDDice { - static deDraconique(rollMode="selfroll") { + /* -------------------------------------------- */ + static async deDraconique(rollMode="selfroll") { let roll = new Roll("1d8x8").evaluate(); - this.show(roll, rollMode); + await this.show(roll, rollMode); return roll.total - Math.ceil(roll.total / 8); } - static show(roll, rollMode = "roll") { + /* -------------------------------------------- */ + static async show(roll, rollMode = "roll") { if (roll.showDice || game.settings.get("foundryvtt-reve-de-dragon", "dice-so-nice") == true) { - this.showDiceSoNice(roll, rollMode); + await this.showDiceSoNice(roll, rollMode); } return roll; } diff --git a/module/rdd-resolution-table.js b/module/rdd-resolution-table.js index 3ea5d350..7e769c01 100644 --- a/module/rdd-resolution-table.js +++ b/module/rdd-resolution-table.js @@ -85,20 +85,20 @@ export class RdDResolutionTable { } /* -------------------------------------------- */ - static roll(carac, finalLevel) { + static async roll(carac, finalLevel) { let chances = this.computeChances(carac, finalLevel); chances.showDice = true; - let rolled = this.rollChances(chances); + let rolled = await this.rollChances(chances); rolled.carac = carac; rolled.finalLevel = finalLevel; return rolled; } /* -------------------------------------------- */ - static rollChances(chances) { + static async rollChances(chances) { let myRoll = new Roll("d100").roll(); myRoll.showDice = chances.showDice; - RdDDice.show(myRoll); + await RdDDice.show(myRoll); chances.roll = myRoll.total; mergeObject(chances, this._computeReussite(chances, chances.roll)); return chances; diff --git a/system.json b/system.json index 02d84440..073acf67 100644 --- a/system.json +++ b/system.json @@ -2,7 +2,7 @@ "name": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", "description": "Rêve de Dragon RPG for FoundryVTT", - "version": "0.9.68", + "version": "0.9.69", "minimumCoreVersion": "0.7.5", "compatibleCoreVersion": "0.7.6", "templateVersion": 47,