diff --git a/module/rdd-main.js b/module/rdd-main.js index e64cff74..86acbc79 100644 --- a/module/rdd-main.js +++ b/module/rdd-main.js @@ -138,26 +138,10 @@ Hooks.once("ready", function() { /* -------------------------------------------- */ /* Foundry VTT Initialization */ /* -------------------------------------------- */ -const table2func = { "queues": TMRUtility.getQueue, "ombre": TMRUtility.getOmbre, "tetehr": TMRUtility.getTeteHR, "tete": TMRUtility.getTete, "souffle": TMRUtility.getSouffle }; Hooks.on("chatMessage", (html, content, msg) => { + let regExp; + regExp = /(\S+)/g; + let commands = content.match(regExp); - // Setup new message's visibility - let rollMode = game.settings.get("core", "rollMode"); - if (["gmroll", "blindroll"].includes(rollMode)) msg["whisper"] = ChatMessage.getWhisperIDs("GM"); - if (rollMode === "blindroll") msg["blind"] = true; - msg["type"] = 0; - - let regExp; - regExp = /(\S+)/g; - let commands = content.match(regExp); - let command = commands[0]; - - // Roll on a table - if (command === "/table") { - let tableName = commands[1].toLowerCase(); - table2func[tableName](); - return false - } - - return true; + return RdDUtility.processChatCommand( commands, content, msg ); } ); diff --git a/module/rdd-tmr-dialog.js b/module/rdd-tmr-dialog.js index ed9abf7d..a417457b 100644 --- a/module/rdd-tmr-dialog.js +++ b/module/rdd-tmr-dialog.js @@ -5,6 +5,7 @@ import { RdDUtility } from "./rdd-utility.js"; import { TMRUtility } from "./tmr-utility.js"; +/** Helper functions */ export class RdDTMRDialog extends Dialog { /* -------------------------------------------- */ diff --git a/module/rdd-utility.js b/module/rdd-utility.js index c2f76848..cf8798a4 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -1,6 +1,7 @@ /* Common useful functions shared between objects */ import { RdDActor } from "./actor.js"; +import { TMRUtility } from "./tmr-utility.js"; const level_category = { "generale": "-4", @@ -76,6 +77,12 @@ const fatigueMarche = { "aise": { "4":1, "6":2, "8":3, "10":4, "12":6 }, "malaise": { "4":2, "6":3, "8":4, "10":6 }, "difficile": { "4":3, "6":4, "8":6 }, "tresdifficile": { "4":4, "6":6 } } +/* Static tables for commands /table */ +const table2func = { "queues": {descr: "queues : Tire une queue de Dragon", func: TMRUtility.getQueue}, + "ombre": { descr: "ombre: Tire une Ombre de Dragon", func: TMRUtility.getOmbre }, + "tetehr": {descr: "tetehr: Tire une Tête de Dragon pour Hauts Revants", fund: TMRUtility.getTeteHR}, + "tete" : { descr: "tete: Tire une Tête de Dragon", func: TMRUtility.getTete}, + "souffle": { descr: "souffle: Tire un Souffle de Dragon", func: TMRUtility.getSouffle} }; /* -------------------------------------------- */ export class RdDUtility { @@ -587,4 +594,43 @@ export class RdDUtility { } + /* -------------------------------------------- */ + /* Display help for /table */ + static displayHelpTable( msg ) + { + msg.content = ""; + for (let [name, tableData] of Object.entries(table2func)) { + msg.content += "
" + tableData.descr; + } + ChatMessage.create( msg ); + } + + /* -------------------------------------------- */ + /* Manage chat commands */ + static processChatCommand( commands, content, msg ) { + // Setup new message's visibility + let rollMode = game.settings.get("core", "rollMode"); + if (["gmroll", "blindroll"].includes(rollMode)) msg["whisper"] = ChatMessage.getWhisperIDs("GM"); + if (rollMode === "blindroll") msg["blind"] = true; + msg["type"] = 0; + + let command = commands[0]; + + // Roll on a table + if (command === "/table") { + if ( commands[1] ) { + let tableName = commands[1].toLowerCase(); + table2func[tableName](); + } else { + this.displayHelpTable( msg ); + } + return false + } else if (command === "/tmrr") { + TMRUtility.getRencontre(commands[1], commands[2] ) + return false + } + + return true; + } + } diff --git a/module/tmr-utility.js b/module/tmr-utility.js index 43e66b22..f0157270 100644 --- a/module/tmr-utility.js +++ b/module/tmr-utility.js @@ -399,5 +399,35 @@ export class TMRUtility { return TMRUtility.genericGetTableResult( "Ombre de Thanatos", toChat); } + /* -------------------------------------------- */ + /** + * Retourne une recontre en fonction de la case ou du tirage + * @param {*} caseName + * @param {*} roll + */ + static getRencontre( caseName, roll ) { + if (!roll) { + roll = new Roll("1d100").roll().total; + } + if ( !caseName) { + ChatMessage.create({ content: "Un nom de case doit être indiqué (ie /tmrr desert ou /tmrr cite)" }); + return false; + } + caseName = caseName.toLowerCase(); + caseName = caseName.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); + //console.log("Case : ", caseName); + for( let renc of rencontresTable) { + let scoreDef = renc.data[caseName]; + let min = scoreDef.substr(0,2); + let max = scoreDef.substr(3,2); + if ( roll >= min && roll <= max) { + let force = new Roll(renc.data.force).roll().total; + ChatMessage.create({ content: "Vous rencontrez un " + renc.name + " d'une force de " + force + " Points de Rêve" }); + return false; + } + } + + } + } diff --git a/packs/equipement.db b/packs/equipement.db index 19eb1c20..39fa81e6 100644 --- a/packs/equipement.db +++ b/packs/equipement.db @@ -5,7 +5,9 @@ {"name":"Gourde, outre (10 litres)","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"conteneur","data":{"description":"","capacite":5,"encombrement":0.1,"equipe":false,"qualite":0,"cout":0.2},"flags":{},"img":"icons/svg/mystery-man.svg","_id":"6EmXVWHXtu3GaTsJ"} {"name":"Premier Chant Dérisoire","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"livre","data":{"description":"

Les Chants Dérisoires de Yester l’Ancien ont été peu retranscrits, probablement à cause de leur ineptie fondamentale. En dénicher un exemplaire n’est donc déjà pas chose aisée. Le premier chant, cependant, peut être source de révélation pour les haut-rêvants. La découverte de ce sens caché demande un minimum de +4 en voie d’Hypnos et permet la synthèse du sort de Dérision. Sans son assimilation préalable, la synthèse de ce sort est totalement inenvisageable. Sa difficulté de lecture est de -5, son assimilation requiert 16 points de tâche, périodicité 1 heure.

","auteur":"Yester l’Ancien","quantite":1,"difficulte":-5,"points_de_tache":16,"encombrement":0,"xp":"","cout":0},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_hypnos.png","_id":"6fW8gPkxgeBCKA59"} {"name":"Chemise de lin","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"objet","data":{"description":"","quantite":1,"encombrement":0,"equipe":false,"resistance":0,"qualite":0,"cout":0.3},"flags":{},"img":"icons/svg/mystery-man.svg","_id":"6ijvX546B9rXtvbR"} +{"name":"Drap Matelassé","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"armure","data":{"description":"

Deux épaisseurs de drap surpiquées, avec rembourrage de laine.

\n

Pourpoint ou cotte de drap matelassé + culottes de drap matelassé + bottes de cuir souple. Le pourpoint est une sorte de veste ; la cotte est une sorte de tunique, lacée sur la poitrine, et descendant jusqu’aux genoux, façon Robin des Bois.

\n

 

","quantite":1,"encombrement":0,"equipe":false,"protection":1,"deterioration":0,"malus":0,"cout":4},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/armures/icon_drap_matelasse.png","_id":"71JQGw2sbcl3wynB"} {"name":"Fiole de verre (20 cl)","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"conteneur","data":{"description":"","capacite":0.1,"encombrement":0,"equipe":false,"qualite":0,"cout":0.2},"flags":{},"img":"icons/svg/mystery-man.svg","_id":"7JZ01gxQPv7bcGZB"} +{"name":"Cuir Souple","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"armure","data":{"description":"

Même épaisseur que nos modernes blousons de cuir. Pourpoint ou cotte de cuir souple + culottes de cuir souple + bottes de cuir souple.

\n

 

","quantite":1,"encombrement":0,"equipe":false,"protection":2,"deterioration":0,"malus":0,"cout":6},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/armures/icon_cuir_souple.png","_id":"A2nen5AsgUsOL19L"} {"name":"Masse lourde 1M","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"arme","data":{"description":"","quantite":1,"encombrement":3,"equipe":false,"dommages":3,"force":12,"resistance":10,"competence":"Masse à 1 main","cout":4,"portee_courte":0,"portee_moyenne":0,"portee_extreme":0,"rapide":false},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/armes/icon_masse.png","_id":"Amvsjgxid6pRtx3y"} {"name":"Épée dragonne","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"arme","data":{"description":"

C’est une épée longue, plus robuste que l’esparlongue, pouvant également frapper de taille.

","quantite":1,"encombrement":2,"equipe":false,"dommages":3,"force":11,"resistance":12,"competence":"Epée à 1 main","cout":20,"portee_courte":0,"portee_moyenne":0,"portee_extreme":0,"rapide":false},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/armes/icon_epee_dragonne.png","_id":"AnZypTTGY9dRZbQM"} {"name":"Sacoche de selle (12.5 kg)","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"conteneur","data":{"description":"","capacite":6.3,"encombrement":0.2,"equipe":false,"qualite":0,"cout":0.9},"flags":{},"img":"icons/svg/mystery-man.svg","_id":"B3kEKlDX8ncLSMqk"} @@ -33,6 +35,7 @@ {"name":"Bas de lin","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"objet","data":{"description":"","quantite":1,"encombrement":0,"equipe":false,"resistance":0,"qualite":0,"cout":0.3},"flags":{},"img":"icons/svg/mystery-man.svg","_id":"Sm28dG9isppoQzPQ"} {"name":"Épée sorde 1M","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"arme","data":{"description":"

C’est une épée plus courte que la dragonne, mais plus large. Elle peut s’utiliser à une ou deux mains. Sa grande solidité en fait l’épée de prédilection des gardes et des soldats.

\n

C’est probablement à elle que le Guerrier Sorde doit son nom (à moins que ce ne soit l’inverse).

","quantite":1,"encombrement":2,"equipe":false,"dommages":3,"force":12,"resistance":15,"competence":"Epée à 1 main","cout":20,"portee_courte":0,"portee_moyenne":0,"portee_extreme":0,"rapide":false},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/armes/icon_epee_batarde.png","_id":"VP35SHsapv0NFkgE"} {"name":"Sac à dos, grand (50 litres)","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"conteneur","data":{"description":"","capacite":25,"encombrement":1.7,"equipe":false,"qualite":0,"cout":2},"flags":{},"img":"icons/svg/mystery-man.svg","_id":"VP9TpckvYBh1GKwb"} +{"name":"Mailles de Fer","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"armure","data":{"description":"

Grand haubert de mailles avec capuche À enfiler sur une cotte de cuir souple ou de drap matelassé) + bottes de cuir / métal.

\n

 

","quantite":1,"encombrement":6,"equipe":false,"protection":5,"deterioration":-4,"malus":0,"cout":50},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/armures/icon_mailles_fer.png","_id":"Vpl1DjSzkQNOpgDE"} {"name":"Burette de fer blanc (40 cl)","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"conteneur","data":{"description":"","capacite":0.2,"encombrement":0.2,"equipe":false,"qualite":0,"cout":0.5},"flags":{},"img":"icons/svg/mystery-man.svg","_id":"VxP2WXWabwV9eBZ1"} {"name":"Le Principe Drachromatique","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"livre","data":{"description":"

Cet ouvrage de profonde érudition sur l’origine des couleurs et leur signification onirique est foncièrement incompréhensible, à moins de posséder un minimum de +4 en voie d’Oniros. Il permet d’envisager la synthèse des sorts d’Invulnérabilité Chromatique et de Transmutation Chromatique. Sans son assimilation préalable, la synthèse de ces sorts est totalement inenvisageable. Sa difficulté de lecture est de -4, son assimilation requiert 26 points de tâche, périodicité 1 heure.

","auteur":"Anonyme","quantite":1,"difficulte":-4,"points_de_tache":26,"encombrement":0,"xp":"","cout":0},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_oniros.png","_id":"YNHDt4EerstJvx5l"} {"name":"Gourdin","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"arme","data":{"description":"","quantite":1,"encombrement":1,"equipe":false,"dommages":1,"force":7,"resistance":8,"competence":"Masse à 1 main","cout":0,"portee_courte":0,"portee_moyenne":0,"portee_extreme":0,"rapide":false},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/armes/icon_gourdin.png","_id":"YOFn2Aom2J2vomXD"} @@ -66,12 +69,15 @@ {"name":"Couverture de laine","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"objet","data":{"description":"","quantite":1,"encombrement":0.6,"equipe":false,"resistance":0,"qualite":0,"cout":0.3},"flags":{},"img":"icons/svg/mystery-man.svg","_id":"qkhI95Ta6g6KcXSp"} {"name":"Seau en cuir (15 litres)","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"conteneur","data":{"description":"","capacite":7.5,"encombrement":0.2,"equipe":false,"qualite":0,"cout":0.36},"flags":{},"img":"icons/svg/mystery-man.svg","_id":"qmOYYmzAlmTrQJMi"} {"name":"Bourse, sachet de tissu","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"conteneur","data":{"description":"","capacite":0.25,"encombrement":0,"equipe":false,"qualite":0,"cout":0.05},"flags":{},"img":"icons/svg/mystery-man.svg","_id":"rZXSXbKkF8B1JJru"} +{"name":"Cuir / Metal","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"armure","data":{"description":"

Cuir épais clouté, ou petites plaquettes, écailles ou anneaux de fer cousus sur le cuir. Pectoral ou cotte de cuir/métal + jupon ou cuissards de cuir / métal sur culottes de cuir souple + bottes de cuir / métal + casque de métal.

\n

 

","quantite":1,"encombrement":4,"equipe":false,"protection":4,"deterioration":-2,"malus":0,"cout":20},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/armures/icon_cuir_metal.png","_id":"rtwe796Mo0VfTKvO"} {"name":"Fouet","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"arme","data":{"description":"

Bien qu’étant toujours tenu en main, le fouet est considéré comme une arme de lancer. Sa portée est limitée par sa longueur, maximum 3 m. Ses dommages sont déterminés sur la table des Coups non mortels, c’est-à-dire qu’ils ne font essentiellement perdre que des points d’endurance. Face aux fouets, les armures sont majorées de 2 points. Le drap matelassé vaut ainsi 3 et le cuir souple 4. Qui plus est, le cuir épais, le cuir / métal, les mailles et les plaques, et toute  protection naturelle d’une créature de 5 points ou plus, protègent totalement des dégâts du fouet. Il est inutile de vouloir fouetter un rhinocéros. Inversement, vêtements ordinaires ou pas de vêtements du tout valent toujours zéro de protection.

","quantite":1,"encombrement":0.5,"equipe":false,"dommages":2,"force":0,"resistance":0,"competence":"Fouet","cout":1,"portee_courte":2,"portee_moyenne":0,"portee_extreme":0,"rapide":false},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/armes/icon_fouet.png","_id":"sTQJcMedtrCuWvXQ"} {"name":"Javeline","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"arme","data":{"description":"","quantite":1,"encombrement":1,"equipe":false,"dommages":1,"force":7,"resistance":5,"competence":"Lance","cout":1,"portee_courte":0,"portee_moyenne":0,"portee_extreme":0,"rapide":false},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/armes/icon_lance.png","_id":"sliT9TkC6tRB8Ihe"} {"name":"Bouclier léger","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"arme","data":{"description":"","quantite":1,"encombrement":1,"equipe":false,"dommages":0,"force":8,"resistance":13,"competence":"Bouclier","cout":4,"portee_courte":0,"portee_moyenne":0,"portee_extreme":0,"rapide":false},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/armes/icon_bouclier_leger.png","_id":"tHTkb55OO8Co4SA7"} {"name":"Bouclier moyen","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"arme","data":{"description":"","quantite":1,"encombrement":2,"equipe":false,"dommages":0,"force":11,"resistance":15,"competence":"Bouclier","cout":6,"portee_courte":0,"portee_moyenne":0,"portee_extreme":0,"rapide":false},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/armes/icon_bouclier_moyen.png","_id":"tssXjPlcXfdXjWbR"} +{"name":"Plaques de Fer","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"armure","data":{"description":"

L'armure classique du chevalier. Armure complète de plaques (heaume, cuirasse, épaulières, cubitières, ventrière, cuissards, jambières).

\n

 

","quantite":1,"encombrement":8,"equipe":false,"protection":6,"deterioration":-6,"malus":0,"cout":100},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/armures/icon_plaques_fer.png","_id":"v5ZX7m8NPKssDHRM"} {"name":"Sacoche de selle (5 kg)","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"conteneur","data":{"description":"","capacite":2.5,"encombrement":0.2,"equipe":false,"qualite":0,"cout":0.6},"flags":{},"img":"icons/svg/mystery-man.svg","_id":"vUpuEXY9fGHYSuom"} {"name":"1 m2 de laine","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"objet","data":{"description":"","quantite":1,"encombrement":0.2,"equipe":false,"resistance":0,"qualite":0,"cout":0.1},"flags":{},"img":"icons/svg/mystery-man.svg","_id":"vcn8b32Gg9WOLgQX"} +{"name":"Cuir Epais","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"armure","data":{"description":"

Cuir très épais comme le cuir de botte. Pectoral de cuir épais + jupon de bandes ou de tresses de cuir ou cuissards de cuir épais sur culottes de cuir souple + bottes dures + casque de cuir.

\n

 

","quantite":1,"encombrement":2,"equipe":false,"protection":3,"deterioration":-1,"malus":0,"cout":10},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/armures/icon_cuir_epais.png","_id":"wePwDpfZKDkhEJla"} {"name":"Robe de laine","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"objet","data":{"description":"","quantite":1,"encombrement":0.2,"equipe":false,"resistance":0,"qualite":0,"cout":0.4},"flags":{},"img":"icons/svg/mystery-man.svg","_id":"wpWaqe96x3cvqTXy"} {"name":"Le Paradoxe de l’Immobilité Rapide","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"livre","data":{"description":"

Ce texte de pure logique ne peut être assimilé que si l’on possède un minimum de +4 en voie d’Hypnos. Il permet d’envisager la synthèse du sort de Concentration. (Sans son assimilation préalable, la synthèse de ce sort est totalement inenvisageable.) Sa difficulté de lecture est de -5, son assimilation requiert 12 points de tâche, périodicité 1 heure.

","auteur":"Wanister de Bravo","quantite":1,"difficulte":-5,"points_de_tache":12,"encombrement":0,"xp":"","cout":0},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_hypnos.png","_id":"wwWRn95ByBD08eGQ"} {"name":"Chemise de laine","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"objet","data":{"description":"","quantite":1,"encombrement":0.1,"equipe":false,"resistance":0,"qualite":0,"cout":0.2},"flags":{},"img":"icons/svg/mystery-man.svg","_id":"xuk60njqtrSZusSX"} diff --git a/system.json b/system.json index 9d3460c5..a24f3aaa 100644 --- a/system.json +++ b/system.json @@ -2,9 +2,9 @@ "name": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", "description": "Rêve de Dragon RPG for FoundryVTT", - "version": "0.9.3", + "version": "0.9.4", "minimumCoreVersion": "0.6.0", - "compatibleCoreVersion": "0.6.2", + "compatibleCoreVersion": "0.6.6", "templateVersion": 28, "author": "LeRatierBretonnien", "esmodules": [ "module/rdd-main.js", "module/hook-renderChatLog.js" ],