|
|
|
@@ -2,19 +2,14 @@ import { ChatUtility } from "./chat-utility.js";
|
|
|
|
|
import { HIDE_DICE, SHOW_DICE } from "./constants.js";
|
|
|
|
|
import { Misc } from "./misc.js";
|
|
|
|
|
|
|
|
|
|
function img(src) {
|
|
|
|
|
return `<img src="${src}" class="dice-img" />`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function iconHeure(heure) {
|
|
|
|
|
const imgHeures = [1, 2, 3, 4, 5, 6, 7, 9, 9, 10, 11, 12].map(heure => {
|
|
|
|
|
if (heure < 10) {
|
|
|
|
|
heure = '0' + heure;
|
|
|
|
|
}
|
|
|
|
|
return `systems/foundryvtt-reve-de-dragon/icons/heures/hd${heure}.webp`
|
|
|
|
|
}
|
|
|
|
|
const imagesHeures = [1, 2, 3, 4, 5, 6, 7, 9, 9, 10, 11, 12].map(it => iconHeure(it));
|
|
|
|
|
return `<img src="systems/foundryvtt-reve-de-dragon/icons/heures/hd${heure}.webp" class="dice-img" />`
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const imgSigneDragon = img(imagesHeures[4]);
|
|
|
|
|
const imgSigneDragon = imgHeures[4]
|
|
|
|
|
|
|
|
|
|
/** De pour les jets de rencontre */
|
|
|
|
|
export class DeTMR extends Die {
|
|
|
|
@@ -25,7 +20,7 @@ export class DeTMR extends Die {
|
|
|
|
|
return {
|
|
|
|
|
type: "dt",
|
|
|
|
|
font: "HeuresDraconiques",
|
|
|
|
|
fontScale: 0.7,
|
|
|
|
|
fontScale: 0.8,
|
|
|
|
|
labels: ['1', '2', '3', '4', '5', '6', 'd', '0'],
|
|
|
|
|
system: system
|
|
|
|
|
}
|
|
|
|
@@ -37,13 +32,13 @@ export class DeTMR extends Die {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async evaluate(options) {
|
|
|
|
|
await super.evaluate(options);
|
|
|
|
|
this.explode("x=8");
|
|
|
|
|
await super.evaluate(options)
|
|
|
|
|
await this.reroll('r=8', { recursive: true })
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get total() {
|
|
|
|
|
return this.values.filter(it => it != 8).reduce(Misc.sum(), 0);
|
|
|
|
|
return this.values.map(it => Misc.modulo(it, 8)).reduce(Misc.sum(), 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getResultLabel(diceTerm) {
|
|
|
|
@@ -56,13 +51,14 @@ export class DeTMR extends Die {
|
|
|
|
|
|
|
|
|
|
/** DeDraconique pour le D8 sans limite avec 8=>0 */
|
|
|
|
|
export class DeDraconique extends Die {
|
|
|
|
|
/** @override */
|
|
|
|
|
static DENOMINATION = "r";
|
|
|
|
|
|
|
|
|
|
static diceSoNiceData(system) {
|
|
|
|
|
return {
|
|
|
|
|
type: "dr",
|
|
|
|
|
font: "HeuresDraconiques",
|
|
|
|
|
fontScale: 0.7,
|
|
|
|
|
fontScale: 0.8,
|
|
|
|
|
labels: ['1', '2', '3', '4', '5', '6', 'd', '0'],
|
|
|
|
|
system: system
|
|
|
|
|
}
|
|
|
|
@@ -75,7 +71,7 @@ export class DeDraconique extends Die {
|
|
|
|
|
|
|
|
|
|
async evaluate(options) {
|
|
|
|
|
await super.evaluate(options);
|
|
|
|
|
this.explode("x=7");
|
|
|
|
|
await this.explode("x=7");
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -85,7 +81,7 @@ export class DeDraconique extends Die {
|
|
|
|
|
|
|
|
|
|
getResultLabel(diceTerm) {
|
|
|
|
|
switch (diceTerm.result) {
|
|
|
|
|
case 7: return imgSigneDragon;
|
|
|
|
|
case 7: return imgSigneDragon
|
|
|
|
|
case 8: return '0';
|
|
|
|
|
}
|
|
|
|
|
return diceTerm.result.toString();
|
|
|
|
@@ -102,6 +98,7 @@ export class DeHeure extends Die {
|
|
|
|
|
return {
|
|
|
|
|
type: "dh",
|
|
|
|
|
font: "HeuresDraconiques",
|
|
|
|
|
fontScale: 1.2,
|
|
|
|
|
labels: ['v', 'i', 'f', 'o', 'd', 'e', 'l', 's', 'p', 'a', 'r', 'c'],
|
|
|
|
|
system: system
|
|
|
|
|
}
|
|
|
|
@@ -113,15 +110,15 @@ export class DeHeure extends Die {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getResultLabel(diceTerm) {
|
|
|
|
|
return img(imagesHeures[diceTerm.result - 1]);
|
|
|
|
|
return imgHeures[diceTerm.result - 1]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class RdDDice {
|
|
|
|
|
static init() {
|
|
|
|
|
CONFIG.Dice.terms[DeTMR.DENOMINATION] = DeTMR;
|
|
|
|
|
CONFIG.Dice.terms[DeDraconique.DENOMINATION] = DeDraconique;
|
|
|
|
|
CONFIG.Dice.terms[DeHeure.DENOMINATION] = DeHeure;
|
|
|
|
|
CONFIG.Dice.terms[DeTMR.DENOMINATION] = DeTMR
|
|
|
|
|
CONFIG.Dice.terms[DeDraconique.DENOMINATION] = DeDraconique
|
|
|
|
|
CONFIG.Dice.terms[DeHeure.DENOMINATION] = DeHeure
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static onReady() {
|
|
|
|
@@ -132,6 +129,14 @@ export class RdDDice {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static diceSoNiceReady(dice3d) {
|
|
|
|
|
dice3d.DiceFactory.systems.keys().forEach(system => {
|
|
|
|
|
dice3d.addDicePreset(DeTMR.diceSoNiceData(system));
|
|
|
|
|
dice3d.addDicePreset(DeDraconique.diceSoNiceData(system));
|
|
|
|
|
dice3d.addDicePreset(DeHeure.diceSoNiceData(system));
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static async rollHeure(options = { showDice: HIDE_DICE }) {
|
|
|
|
|
return await RdDDice.rollTotal("1dh", options) - 1
|
|
|
|
|
}
|
|
|
|
@@ -155,14 +160,6 @@ export class RdDDice {
|
|
|
|
|
return array[roll - 1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static diceSoNiceReady(dice3d) {
|
|
|
|
|
for (const system of Object.keys(dice3d.DiceFactory.systems)) {
|
|
|
|
|
dice3d.addDicePreset(DeTMR.diceSoNiceData(system));
|
|
|
|
|
dice3d.addDicePreset(DeDraconique.diceSoNiceData(system));
|
|
|
|
|
dice3d.addDicePreset(DeHeure.diceSoNiceData(system));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
static async showDiceSoNice(roll, options) {
|
|
|
|
|
if (options.showDice == HIDE_DICE || !game.modules.get("dice-so-nice")?.active || !game.dice3d) {
|
|
|
|
|