From 94136b88797d41f400971ba656de73e6a84cdc61 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 29 Apr 2021 02:57:56 +0200 Subject: [PATCH] =?UTF-8?q?Jolis=20d=C3=A9s=20draconiques?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- icons/heures/hdragon.webp | Bin 0 -> 2116 bytes module/actor.js | 3 +- module/constants.js | 1 + module/de-draconique.js | 26 ------------ module/rdd-commands.js | 3 +- module/rdd-dice.js | 84 +++++++++++++++++++++++++++++++++++++- module/rdd-main.js | 9 +++- module/tmr-rencontres.js | 3 +- 8 files changed, 94 insertions(+), 35 deletions(-) create mode 100644 icons/heures/hdragon.webp create mode 100644 module/constants.js delete mode 100644 module/de-draconique.js diff --git a/icons/heures/hdragon.webp b/icons/heures/hdragon.webp new file mode 100644 index 0000000000000000000000000000000000000000..48659c684006b41c1f75af8fd13668768ee6c366 GIT binary patch literal 2116 zcmb`I=|9ws8peN<>`P+}HMYTIIS64gq_M<2lE}U`WGPF=*5tu>3PZNg3>s3l!I(6b z&{!(V7_u+fRkmVm6$v>$=e#)oz_~y7{pxyi-7l`|Yhz(%hTsAK2UDcAy|tbr4*&q* z<2(A#UbeJ0kK_aZP+`K+Go{zReY37g)YJz~MMMR{h;@Na%LDbvfl$>iBUdAK58O$) z@S4C45-|zST^MlWyMJlwXyQ+Qn%7F}tl~?!`{A-#-pwrZwy7dY!u!SEL= z2N@mw!*SarXtnU#GmrP&&(BsNwhoV)+1p+rTF>`{@gJzTW#d(O!vN}^MU_?EK5n6x z(gYA)Y98%v*bYTifCqzf`Q{Hh$HbK8LK7rqX!SW*c<7@_$J64`qgRs1*X4MP4pz`Y zlOfLHLoU2aqL^0o%}pQ0ABWj^l;J!mt;l0R+vf4&W+wVaR5e5eC5YvZIt8?<2(lLl z0~v;`2|3a#afWRVC?h)U0Z-UvD(i(Fcd^R?4oBOfn`pORz~6x>#0yFKAVAGI8-HS5 z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5hs9C|yXc_;YjongZWo48-Oz-;*PXIztcZ z&4}kde!FA9nWHmLlDZ$p-zEYj>{Il8@MJeRT$MXIHZHIxM~=tv#QfgI`ibWeeY~38 zgg7TasB9z@Do0GX(l&R8fLD$;KHA=H*<1z(`WN7vt{8vDXpX{-(R{4>JQcZdfu|lx zdWwyi+>yaLe#5yBYiqlF#q3J|2TrOya7<*Gf@2zQf`NRHG5`WVhJ${uY|kmmzbHHh z0wlTpgFZ#PI%CAW#x@r~N^F^cpNghor1rfR40gI1QLL= 7) { // Rêve de Dragon ! diff --git a/module/constants.js b/module/constants.js new file mode 100644 index 00000000..708e4ab5 --- /dev/null +++ b/module/constants.js @@ -0,0 +1 @@ +export const SYSTEM_RDD = "foundryvtt-reve-de-dragon"; diff --git a/module/de-draconique.js b/module/de-draconique.js deleted file mode 100644 index 4cd5d6bd..00000000 --- a/module/de-draconique.js +++ /dev/null @@ -1,26 +0,0 @@ -import { RdDDice } from "./rdd-dice.js"; - -export class DeDraconique extends Roll{ - - static async ddr(rollMode=undefined) { - let ddr = new DeDraconique().evaluate(); - await RdDDice.show(ddr, rollMode); - return ddr; - } - - constructor(){ - super("1d8x8 - 0") - } - - evaluate() { - super.evaluate(); - const rerolls = Math.ceil(this.total / 8); - this.terms[this.terms.length - 1].number = rerolls; - this._total -= rerolls; - return this; - } - - async render(chatOptions) { - return super.render(chatOptions) - } -} \ No newline at end of file diff --git a/module/rdd-commands.js b/module/rdd-commands.js index 996b6972..f8b44405 100644 --- a/module/rdd-commands.js +++ b/module/rdd-commands.js @@ -1,6 +1,5 @@ /* -------------------------------------------- */ -import { DeDraconique } from "./de-draconique.js"; import { RdDItemCompetence } from "./item-competence.js"; import { Misc } from "./misc.js"; import { RdDCarac } from "./rdd-carac.js"; @@ -272,7 +271,7 @@ export class RdDCommands { /* -------------------------------------------- */ async rollDeDraconique(msg) { - let ddr = new DeDraconique().evaluate(); + let ddr = new Roll("1dr + 7").evaluate(); ddr.showDice = true; await RdDDice.showDiceSoNice(ddr); RdDCommands._chatAnswer(msg, `Lancer d'un Dé draconique: ${ddr.total}`); diff --git a/module/rdd-dice.js b/module/rdd-dice.js index 94df5543..03e74da4 100644 --- a/module/rdd-dice.js +++ b/module/rdd-dice.js @@ -1,15 +1,95 @@ import { ChatUtility } from "./chat-utility.js"; +import { SYSTEM_RDD } from "./constants.js"; +import { Misc } from "./misc.js"; + +const signeDragon = 'systems/foundryvtt-reve-de-dragon/icons/heures/hdragon.webp'; +const imgSigneDragon = ``; +const labelsDeDragon = ['1', '2', '3', '4', '5', '6', signeDragon, '0']; +const bumpsDeDragon = [, , , , , , signeDragon, ]; + +/** De7 pour les jets de rencontre */ +export class De7 extends Die { + /** @override */ + static DENOMINATION = "7"; + + static diceSoNiceData() { + return { type: "d7", labels: labelsDeDragon, bumpMaps: bumpsDeDragon, system: SYSTEM_RDD } + } + + constructor(termData) { + termData.faces = 8; + super(termData); + } + + evaluate() { + super.evaluate(); + this.explode("x=8"); + return this; + } + + get total() { + return this.values.filter(it => it != 8).reduce(Misc.sum(), 0); + } + + static getResultLabel(result) { + switch (result) { + case '7': return imgSigneDragon + } + return result; + } +} + +/** DeDraconique pour le D8 sans limite avec 8=>0 */ +export class DeDraconique extends Die { + static DENOMINATION = "r"; + + static diceSoNiceData() { + return { type: "dr", labels: labelsDeDragon, bumpMaps: bumpsDeDragon, system: SYSTEM_RDD } + } + + constructor(termData) { + termData.faces = 8; + super(termData); + } + + evaluate() { + super.evaluate(); + this.explode("x=7"); + return this; + } + + get total() { + return this.values.filter(it => it != 8).reduce(Misc.sum(), 0); + } + + static getResultLabel(result) { + switch (result) { + case '7': return imgSigneDragon + } + return result; + } +} export class RdDDice { + static init() { + CONFIG.Dice.terms[De7.DENOMINATION] = De7; + CONFIG.Dice.terms[DeDraconique.DENOMINATION] = DeDraconique; + } + + static diceSoNiceReady(dice3d) { + dice3d.addSystem({ id: SYSTEM_RDD, name: "Rêve de Dragon" }); + dice3d.addDicePreset(De7.diceSoNiceData()); + dice3d.addDicePreset(DeDraconique.diceSoNiceData()); + } /* -------------------------------------------- */ static async show(roll, rollMode = undefined) { - if (roll.showDice || game.settings.get("foundryvtt-reve-de-dragon", "dice-so-nice") == true) { + if (roll.showDice || game.settings.get(SYSTEM_RDD, "dice-so-nice") == true) { await this.showDiceSoNice(roll, rollMode); } return roll; } - + /* -------------------------------------------- */ static async showDiceSoNice(roll, rollMode = undefined) { if (game.modules.get("dice-so-nice") && game.modules.get("dice-so-nice").active) { diff --git a/module/rdd-main.js b/module/rdd-main.js index f76c177c..5e9cadcc 100644 --- a/module/rdd-main.js +++ b/module/rdd-main.js @@ -30,6 +30,7 @@ import { RdDHotbar } from "./rdd-hotbar-drop.js" import { EffetsDraconiques } from "./tmr/effets-draconiques.js"; import { RdDHerbes } from "./rdd-herbes.js"; import { RdDItem } from "./item.js"; +import { RdDDice } from "./rdd-dice.js"; /* -------------------------------------------- */ /* Foundry VTT Initialization */ @@ -171,6 +172,7 @@ Hooks.once("init", async function () { // préparation des différents modules RdDUtility.init(); + RdDDice.init(); RdDCommands.init(); RdDCombat.init(); RdDCombatManager.init(), @@ -230,7 +232,12 @@ Hooks.once("ready", function () { }); /* -------------------------------------------- */ -/* Foundry VTT Initialization */ +/* Dice-so-nice ready */ +/* -------------------------------------------- */ +Hooks.once('diceSoNiceReady', (dice3d) => RdDDice.diceSoNiceReady(dice3d)); + +/* -------------------------------------------- */ +/* Foundry VTT chat message */ /* -------------------------------------------- */ Hooks.on("chatMessage", (html, content, msg) => { if (content[0] == '/') { diff --git a/module/tmr-rencontres.js b/module/tmr-rencontres.js index 0a98c6cf..4c03dd19 100644 --- a/module/tmr-rencontres.js +++ b/module/tmr-rencontres.js @@ -1,4 +1,3 @@ -import { DeDraconique } from "./de-draconique.js"; import { Grammar } from "./grammar.js"; import { Misc } from "./misc.js"; import { TMRUtility } from "./tmr-utility.js"; @@ -382,7 +381,7 @@ export class TMRRencontres { /* -------------------------------------------- */ static async evaluerForceRencontre(rencontre) { if (TMRRencontres.isReveDeDragon(rencontre)) { - const ddr = await DeDraconique.ddr("selfroll") + const ddr = new Roll("1dr + 7").evaluate(); rencontre.force = 7 + ddr.total; } else {