Ajout support Dice So Nice

This commit is contained in:
sladecraven 2020-11-15 16:38:45 +01:00
parent 25742d811f
commit 267a72f87e
3 changed files with 39 additions and 7 deletions

View File

@ -122,7 +122,7 @@ export class RdDActor extends Actor {
async performRoll(rollData) {
// Perform the roll
let rolled = RdDResolutionTable.rollChances(rollData.rollTarget);
let rolled = await RdDResolutionTable.rollChances(rollData.rollTarget);
//rolled.isPart = true; // Pour tester le particulières
rollData.rolled = rolled; // garder le résultat
this.currentRollData = rollData;
@ -719,8 +719,8 @@ export class RdDActor extends Actor {
}
/* -------------------------------------------- */
_stressRoll(target) {
let result = RdDResolutionTable.rollChances(target)
async _stressRoll(target) {
let result = await RdDResolutionTable.rollChances(target)
switch (result.quality) {
case "sign": return { factor: 0.75, comment: "Significative (75%) - " + result.roll }
case "norm": return { factor: 0.5, comment: "Normale (50%) - " + result.roll }
@ -728,7 +728,7 @@ export class RdDActor extends Actor {
case "epart": return { factor: 0.1, comment: "Echec particulier(10%) - " + result.roll }
case "etotal": return { factor: 0, comment: "Echec Total (0%) - " + result.roll }
}
let second = RdDResolutionTable.rollChances(target)
let second = await RdDResolutionTable.rollChances(target)
switch (second.quality) {
case "part": case "sign":
return { factor: 1.5, comment: "Double Particulière (150%) - " + result.roll + " puis " + second.roll }

View File

@ -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);

View File

@ -2,7 +2,7 @@
"name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon",
"description": "Rêve de Dragon RPG for FoundryVTT",
"version": "0.9.46",
"version": "0.9.47",
"minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.6",
"templateVersion": 46,