Gestion des signes draconiques #455
BIN
icons/heures/hdragon.webp
Normal file
BIN
icons/heures/hdragon.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
@ -13,7 +13,6 @@ import { RdDItemSort } from "./item-sort.js";
|
||||
import { Grammar } from "./grammar.js";
|
||||
import { RdDEncaisser } from "./rdd-roll-encaisser.js";
|
||||
import { RdDCombat } from "./rdd-combat.js";
|
||||
import { DeDraconique } from "./de-draconique.js";
|
||||
import { RdDAudio } from "./rdd-audio.js";
|
||||
import { RdDItemCompetence } from "./item-competence.js";
|
||||
import { RdDItemArme } from "./item-arme.js";
|
||||
@ -629,7 +628,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
}
|
||||
else {
|
||||
let deRecuperation = (await DeDraconique.ddr("selfroll")).total;
|
||||
let deRecuperation = new Roll("1dr + 7").evaluate().total;
|
||||
console.log("recuperationReve", deRecuperation);
|
||||
if (deRecuperation >= 7) {
|
||||
// Rêve de Dragon !
|
||||
|
1
module/constants.js
Normal file
1
module/constants.js
Normal file
@ -0,0 +1 @@
|
||||
export const SYSTEM_RDD = "foundryvtt-reve-de-dragon";
|
@ -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)
|
||||
}
|
||||
}
|
@ -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}`);
|
||||
|
@ -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 = `<img src="${signeDragon}" />`;
|
||||
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) {
|
||||
|
@ -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] == '/') {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user