forked from public/foundryvtt-reve-de-dragon
Ajout support Dice So Nice
This commit is contained in:
@ -66,6 +66,7 @@ export class RdDResolutionTable {
|
||||
return table;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getResultat(code)
|
||||
{
|
||||
let resultat = reussites.filter(r => code == r.code);
|
||||
@ -75,19 +76,49 @@ export class RdDResolutionTable {
|
||||
}
|
||||
return resultat;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static roll(carac, difficulte) {
|
||||
const chances = this.computeChances(carac, difficulte);
|
||||
let rolled = this.rollChances(chances);
|
||||
return rolled;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async showDiceSoNice(roll, rollMode = "roll") {
|
||||
if (game.modules.get("dice-so-nice") && game.modules.get("dice-so-nice").active) {
|
||||
let whisper = null;
|
||||
let blind = false;
|
||||
switch (rollMode) {
|
||||
case "blindroll": //GM only
|
||||
blind = true;
|
||||
case "gmroll": //GM + rolling player
|
||||
let gmList = game.users.filter(user => user.isGM);
|
||||
let gmIDList = [];
|
||||
gmList.forEach(gm => gmIDList.push(gm.data._id));
|
||||
whisper = gmIDList;
|
||||
break;
|
||||
case "roll": //everybody
|
||||
let userList = game.users.filter(user => user.active);
|
||||
let userIDList = [];
|
||||
userList.forEach(user => userIDList.push(user.data._id));
|
||||
whisper = userIDList;
|
||||
break;
|
||||
}
|
||||
await game.dice3d.showForRoll(roll, game.user, true, whisper, blind);
|
||||
}
|
||||
}
|
||||
|
||||
static rollChances(chances) {
|
||||
chances.roll = new Roll("d100").roll().total;
|
||||
/* -------------------------------------------- */
|
||||
static async rollChances(chances) {
|
||||
let myRoll = new Roll("d100").roll();
|
||||
await this.showDiceSoNice(myRoll );
|
||||
chances.roll = myRoll.total;
|
||||
mergeObject(chances, this._computeReussite(chances, chances.roll));
|
||||
return chances;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static computeChances(carac, difficulte) {
|
||||
if (difficulte < -16) {
|
||||
return duplicate(levelImpossible);
|
||||
@ -98,6 +129,7 @@ export class RdDResolutionTable {
|
||||
return duplicate(this.resolutionTable[carac][difficulte + 10]);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static buildXpMessage(rolled, level) {
|
||||
if (rolled.isPart && level < 0) {
|
||||
const xp = Math.abs(level);
|
||||
|
Reference in New Issue
Block a user