Nouvelle fenêtre de jets de dés
This commit is contained in:
@@ -38,6 +38,12 @@ export class Misc {
|
||||
return (a, b) => Number(a) + Number(b);
|
||||
}
|
||||
|
||||
static and(predicates) {
|
||||
return value => predicates.map(predicate => predicate(value))
|
||||
.reduce((v1, v2) => v1 && v2, true);
|
||||
}
|
||||
|
||||
|
||||
static ascending(orderFunction = x => x) {
|
||||
return (a, b) => Misc.sortingBy(orderFunction(a), orderFunction(b));
|
||||
}
|
||||
@@ -60,6 +66,11 @@ export class Misc {
|
||||
static arrayOrEmpty(items) {
|
||||
return items?.length ? items : [];
|
||||
}
|
||||
|
||||
static findOrFirst(list, predicate) {
|
||||
return list.find(predicate) ?? list[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the value to an integer, or to 0 if undefined/null/not representing integer
|
||||
* @param {*} value value to convert to an integer using parseInt
|
||||
@@ -75,13 +86,17 @@ export class Misc {
|
||||
return Math.round(num * power10n) / power10n;
|
||||
}
|
||||
|
||||
static getFractionHtml(diviseur) {
|
||||
if (!diviseur || diviseur <= 1) return undefined;
|
||||
switch (diviseur || 1) {
|
||||
case 2: return '½';
|
||||
case 4: return '¼';
|
||||
default: return '1/' + diviseur;
|
||||
|
||||
static getFractionOneN(divider) {
|
||||
if (!divider || divider == 1) {
|
||||
return 1
|
||||
}
|
||||
switch (divider) {
|
||||
case 2: return '½'
|
||||
case 4: return '¼'
|
||||
case 8: return '⅛'
|
||||
}
|
||||
return `1/${divider}`
|
||||
}
|
||||
|
||||
static indexLowercase(list) {
|
||||
@@ -216,7 +231,7 @@ export class Misc {
|
||||
static isFirstConnectedGM() {
|
||||
return game.user == Misc.firstConnectedGM();
|
||||
}
|
||||
|
||||
|
||||
static hasConnectedGM() {
|
||||
return Misc.firstConnectedGM();
|
||||
}
|
||||
|
Reference in New Issue
Block a user