2020-11-24 15:20:05 +01:00
|
|
|
import { ChatUtility } from "./chat-utility.js";
|
|
|
|
|
2020-11-16 03:54:43 +01:00
|
|
|
export class RdDDice {
|
|
|
|
|
2020-11-21 09:10:31 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
static async deDraconique(rollMode="selfroll") {
|
2020-11-16 03:54:43 +01:00
|
|
|
let roll = new Roll("1d8x8").evaluate();
|
2020-11-21 09:10:31 +01:00
|
|
|
await this.show(roll, rollMode);
|
2020-11-16 03:54:43 +01:00
|
|
|
return roll.total - Math.ceil(roll.total / 8);
|
|
|
|
}
|
|
|
|
|
2020-11-17 11:35:05 +01:00
|
|
|
|
2020-11-21 09:10:31 +01:00
|
|
|
/* -------------------------------------------- */
|
2020-11-24 15:20:05 +01:00
|
|
|
static async show(roll, rollMode = undefined) {
|
2020-11-17 11:35:05 +01:00
|
|
|
if (roll.showDice || game.settings.get("foundryvtt-reve-de-dragon", "dice-so-nice") == true) {
|
2020-11-21 09:10:31 +01:00
|
|
|
await this.showDiceSoNice(roll, rollMode);
|
2020-11-17 11:35:05 +01:00
|
|
|
}
|
2020-11-16 03:54:43 +01:00
|
|
|
return roll;
|
|
|
|
}
|
2020-11-24 15:20:05 +01:00
|
|
|
|
2020-11-16 03:54:43 +01:00
|
|
|
/* -------------------------------------------- */
|
2020-11-24 15:20:05 +01:00
|
|
|
static async showDiceSoNice(roll, rollMode = undefined) {
|
2020-11-16 03:54:43 +01:00
|
|
|
if (game.modules.get("dice-so-nice") && game.modules.get("dice-so-nice").active) {
|
|
|
|
let whisper = null;
|
|
|
|
let blind = false;
|
2020-11-24 15:20:05 +01:00
|
|
|
rollMode = rollMode == undefined ? game.settings.get("core", "rollMode") : rollMode;
|
2020-11-16 03:54:43 +01:00
|
|
|
switch (rollMode) {
|
|
|
|
case "blindroll": //GM only
|
|
|
|
blind = true;
|
|
|
|
case "gmroll": //GM + rolling player
|
2020-11-24 18:39:27 +01:00
|
|
|
whisper = ChatUtility.getUsers(user => user.isGM);
|
2020-11-16 03:54:43 +01:00
|
|
|
break;
|
|
|
|
case "roll": //everybody
|
2020-11-24 18:39:27 +01:00
|
|
|
whisper = ChatUtility.getUsers(user => user.active);
|
2020-11-24 15:20:05 +01:00
|
|
|
break;
|
|
|
|
case "selfroll":
|
|
|
|
whisper = [game.user._id];
|
2020-11-16 03:54:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
await game.dice3d.showForRoll(roll, game.user, true, whisper, blind);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|