Jolis dés draconiques
This commit is contained in:
		
							
								
								
									
										
											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 { Grammar } from "./grammar.js"; | ||||||
| import { RdDEncaisser } from "./rdd-roll-encaisser.js"; | import { RdDEncaisser } from "./rdd-roll-encaisser.js"; | ||||||
| import { RdDCombat } from "./rdd-combat.js"; | import { RdDCombat } from "./rdd-combat.js"; | ||||||
| import { DeDraconique } from "./de-draconique.js"; |  | ||||||
| import { RdDAudio } from "./rdd-audio.js"; | import { RdDAudio } from "./rdd-audio.js"; | ||||||
| import { RdDItemCompetence } from "./item-competence.js"; | import { RdDItemCompetence } from "./item-competence.js"; | ||||||
| import { RdDItemArme } from "./item-arme.js"; | import { RdDItemArme } from "./item-arme.js"; | ||||||
| @@ -543,7 +542,7 @@ export class RdDActor extends Actor { | |||||||
|       message.content += `Vous avez suffisament rêvé, au delà de votre seuil. `; |       message.content += `Vous avez suffisament rêvé, au delà de votre seuil. `; | ||||||
|     } |     } | ||||||
|     else { |     else { | ||||||
|       let deRecuperation = (await DeDraconique.ddr("selfroll")).total; |       let deRecuperation = new Roll("1dr + 7").evaluate().total; | ||||||
|       console.log("recuperationReve", deRecuperation); |       console.log("recuperationReve", deRecuperation); | ||||||
|       if (deRecuperation >= 7) { |       if (deRecuperation >= 7) { | ||||||
|         // Rêve de Dragon ! |         // 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,27 +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] = rerolls; |  | ||||||
|     this.results[this.results.length - 1] = 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 { RdDItemCompetence } from "./item-competence.js"; | ||||||
| import { Misc } from "./misc.js"; | import { Misc } from "./misc.js"; | ||||||
| import { RdDCarac } from "./rdd-carac.js"; | import { RdDCarac } from "./rdd-carac.js"; | ||||||
| @@ -258,7 +257,7 @@ export class RdDCommands { | |||||||
|  |  | ||||||
|   /* -------------------------------------------- */ |   /* -------------------------------------------- */ | ||||||
|   async rollDeDraconique(msg) { |   async rollDeDraconique(msg) { | ||||||
|     let ddr = new DeDraconique().evaluate(); |     let ddr = new Roll("1dr + 7").evaluate(); | ||||||
|     ddr.showDice = true; |     ddr.showDice = true; | ||||||
|     await RdDDice.showDiceSoNice(ddr); |     await RdDDice.showDiceSoNice(ddr); | ||||||
|     RdDCommands._chatAnswer(msg, `Lancer d'un Dé draconique: ${ddr.total}`); |     RdDCommands._chatAnswer(msg, `Lancer d'un Dé draconique: ${ddr.total}`); | ||||||
|   | |||||||
| @@ -1,10 +1,90 @@ | |||||||
| import { ChatUtility } from "./chat-utility.js"; | 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 { | 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) { |   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); |       await this.showDiceSoNice(roll, rollMode); | ||||||
|     } |     } | ||||||
|     return roll; |     return roll; | ||||||
|   | |||||||
| @@ -22,13 +22,13 @@ import { RdDTokenHud } from "./rdd-token-hud.js"; | |||||||
| import { RdDCommands } from "./rdd-commands.js"; | import { RdDCommands } from "./rdd-commands.js"; | ||||||
| import { RdDCombatManager, RdDCombat } from "./rdd-combat.js"; | import { RdDCombatManager, RdDCombat } from "./rdd-combat.js"; | ||||||
| import { ChatUtility } from "./chat-utility.js"; | import { ChatUtility } from "./chat-utility.js"; | ||||||
| import { RdDItemCompetence } from "./item-competence.js"; |  | ||||||
| import { StatusEffects } from "./status-effects.js"; | import { StatusEffects } from "./status-effects.js"; | ||||||
| import { RddCompendiumOrganiser } from "./rdd-compendium-organiser.js"; | import { RddCompendiumOrganiser } from "./rdd-compendium-organiser.js"; | ||||||
| import { ReglesOptionelles } from "./regles-optionelles.js"; | import { ReglesOptionelles } from "./regles-optionelles.js"; | ||||||
| import { TMRRencontres } from "./tmr-rencontres.js"; | import { TMRRencontres } from "./tmr-rencontres.js"; | ||||||
| import { RdDHotbar } from "./rdd-hotbar-drop.js" | import { RdDHotbar } from "./rdd-hotbar-drop.js" | ||||||
| import { EffetsDraconiques } from "./tmr/effets-draconiques.js"; | import { EffetsDraconiques } from "./tmr/effets-draconiques.js"; | ||||||
|  | import { RdDDice } from "./rdd-dice.js"; | ||||||
|  |  | ||||||
| /* -------------------------------------------- */ | /* -------------------------------------------- */ | ||||||
| /*  Foundry VTT Initialization                  */ | /*  Foundry VTT Initialization                  */ | ||||||
| @@ -154,6 +154,7 @@ Hooks.once("init", async function () { | |||||||
|   CONFIG.Combat.entityClass = RdDCombatManager; |   CONFIG.Combat.entityClass = RdDCombatManager; | ||||||
|  |  | ||||||
|   // préparation des différents modules |   // préparation des différents modules | ||||||
|  |   RdDDice.init(); | ||||||
|   RdDCommands.init(); |   RdDCommands.init(); | ||||||
|   RdDCombat.init(); |   RdDCombat.init(); | ||||||
|   RdDCombatManager.init(), |   RdDCombatManager.init(), | ||||||
| @@ -212,7 +213,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) => { | Hooks.on("chatMessage", (html, content, msg) => { | ||||||
|   if (content[0] == '/') { |   if (content[0] == '/') { | ||||||
|   | |||||||
| @@ -1,4 +1,3 @@ | |||||||
| import { DeDraconique } from "./de-draconique.js"; |  | ||||||
| import { Grammar } from "./grammar.js"; | import { Grammar } from "./grammar.js"; | ||||||
| import { Misc } from "./misc.js"; | import { Misc } from "./misc.js"; | ||||||
| import { TMRUtility } from "./tmr-utility.js"; | import { TMRUtility } from "./tmr-utility.js"; | ||||||
| @@ -382,7 +381,7 @@ export class TMRRencontres { | |||||||
|   /* -------------------------------------------- */ |   /* -------------------------------------------- */ | ||||||
|   static async evaluerForceRencontre(rencontre) { |   static async evaluerForceRencontre(rencontre) { | ||||||
|     if (TMRRencontres.isReveDeDragon(rencontre)) { |     if (TMRRencontres.isReveDeDragon(rencontre)) { | ||||||
|       const ddr = await DeDraconique.ddr("selfroll") |       const ddr =  new Roll("1dr + 7").evaluate(); | ||||||
|       rencontre.force = 7 + ddr.total; |       rencontre.force = 7 + ddr.total; | ||||||
|     } |     } | ||||||
|     else { |     else { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user