v9 - roll now async (sync is removed in v10)

This commit is contained in:
Vlyan
2021-12-21 12:50:59 +01:00
parent 8080016b6a
commit 2173cc6150
5 changed files with 11 additions and 11 deletions

View File

@@ -79,14 +79,14 @@ export class L5rBaseDie extends DiceTerm {
* @return {L5rBaseDie} The evaluated RollTerm
* @override
*/
evaluate({ minimize = false, maximize = false, async = false } = {}) {
async evaluate({ minimize = false, maximize = false, async = true } = {}) {
if (this._evaluated) {
throw new Error(`This ${this.constructor.name} has already been evaluated and is immutable`);
}
// Roll the initial number of dice
for (let n = 1; n <= this.number; n++) {
this.roll({ minimize, maximize, async }); // TODO async/await in v10.x currently the inline roll is sync
await this.roll({ minimize, maximize, async });
}
// Apply modifiers

View File

@@ -583,7 +583,7 @@ export class RollnKeepDialog extends FormApplication {
};
// Fill the data
roll.evaluate({ async: false });
await roll.evaluate();
// Modify results
roll.terms.map((term) => {

View File

@@ -56,7 +56,7 @@ export class RollL5r5e extends Roll {
* Execute the Roll, replacing dice and evaluating the total result
* @override
**/
evaluate({ minimize = false, maximize = false, async = false } = {}) {
async evaluate({ minimize = false, maximize = false, async = true } = {}) {
if (this._evaluated) {
throw new Error("This Roll object has already been rolled.");
}
@@ -71,7 +71,7 @@ export class RollL5r5e extends Roll {
this._total = 0;
// Roll
super.evaluate({ minimize, maximize, async });
await super.evaluate({ minimize, maximize, async });
this._evaluated = true;
// Save initial formula
@@ -297,7 +297,7 @@ export class RollL5r5e extends Roll {
async toMessage(messageData = {}, { rollMode = null, create = true } = {}) {
// Perform the roll, if it has not yet been rolled
if (!this._evaluated) {
this.evaluate({ async: false });
await this.evaluate();
}
// RollMode