Foundry: Roll#evaluate sera async
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import { RdDDice } from "./rdd-dice.js";
|
||||
|
||||
/**
|
||||
* This class is intended as a placeholder for utility methods unrelated
|
||||
@ -22,13 +23,13 @@ export class Misc {
|
||||
return (a, b) => a + b;
|
||||
}
|
||||
|
||||
static ascending(orderFunction = x=>x) {
|
||||
static ascending(orderFunction = x => x) {
|
||||
return (a, b) => Misc.sortingBy(orderFunction(a), orderFunction(b));
|
||||
}
|
||||
}
|
||||
|
||||
static descending(orderFunction = x=>x) {
|
||||
static descending(orderFunction = x => x) {
|
||||
return (a, b) => Misc.sortingBy(orderFunction(b), orderFunction(a));
|
||||
}
|
||||
}
|
||||
|
||||
static sortingBy(a, b) {
|
||||
if (a > b) return 1;
|
||||
@ -49,7 +50,7 @@ export class Misc {
|
||||
}
|
||||
|
||||
static keepDecimals(num, decimals) {
|
||||
if (decimals<=0 || decimals>6) return num;
|
||||
if (decimals <= 0 || decimals > 6) return num;
|
||||
const decimal = Math.pow(10, parseInt(decimals));
|
||||
return Math.round(num * decimal) / decimal;
|
||||
}
|
||||
@ -92,10 +93,6 @@ export class Misc {
|
||||
}
|
||||
}
|
||||
|
||||
static rollOneOf(array) {
|
||||
return array[new Roll("1d" + array.length).evaluate({ async: false }).total - 1];
|
||||
}
|
||||
|
||||
static distinct(array) {
|
||||
return [...new Set(array)];
|
||||
}
|
||||
@ -112,7 +109,7 @@ export class Misc {
|
||||
}
|
||||
|
||||
static connectedGMOrUser(ownerId = undefined) {
|
||||
if (ownerId && game.user.id == ownerId){
|
||||
if (ownerId && game.user.id == ownerId) {
|
||||
return ownerId;
|
||||
}
|
||||
return (game.user.isGM ? game.user.id : game.users.entities.find(u => u.isGM && u.active)?.id) ?? game.user.id;
|
||||
|
Reference in New Issue
Block a user