Amelioration des commandes de tchat et aide

This commit is contained in:
sladecraven 2020-09-13 22:46:42 +02:00
parent 18be421ce5
commit cec65edb83
6 changed files with 89 additions and 22 deletions

View File

@ -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 );
} );

View File

@ -5,6 +5,7 @@
import { RdDUtility } from "./rdd-utility.js";
import { TMRUtility } from "./tmr-utility.js";
/** Helper functions */
export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */

View File

@ -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 += "<br>" + 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;
}
}

View File

@ -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;
}
}
}
}

View File

@ -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":"<p>Les <em>Chants D&eacute;risoires</em> de Yester l&rsquo;Ancien ont &eacute;t&eacute; peu retranscrits, probablement &agrave; cause de leur ineptie fondamentale. En d&eacute;nicher un exemplaire n&rsquo;est donc d&eacute;j&agrave; pas chose ais&eacute;e. Le premier chant, cependant, peut &ecirc;tre source de r&eacute;v&eacute;lation pour les haut-r&ecirc;vants. La d&eacute;couverte de ce sens cach&eacute; demande un minimum de +4 en voie d&rsquo;Hypnos et permet la synth&egrave;se du sort de <em>D&eacute;rision</em>. Sans son assimilation pr&eacute;alable, la synth&egrave;se de ce sort est totalement inenvisageable. Sa difficult&eacute; de lecture est de -5, son assimilation requiert 16 points de t&acirc;che, p&eacute;riodicit&eacute; 1 heure.</p>","auteur":"Yester lAncien","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":"<p>Deux épaisseurs de drap surpiquées, avec rembourrage de laine.</p>\n<p>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 jusquaux genoux, façon Robin des Bois.</p>\n<p>&nbsp;</p>","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":"<p>Même épaisseur que nos modernes blousons de cuir. Pourpoint ou cotte de cuir souple + culottes de cuir souple + bottes de cuir souple.</p>\n<p>&nbsp;</p>","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":"<p>C&rsquo;est une &eacute;p&eacute;e <em>longue</em>, plus robuste que l&rsquo;esparlongue, pouvant &eacute;galement frapper de taille.</p>","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":"<p>C&rsquo;est une &eacute;p&eacute;e plus courte que la dragonne, mais plus <em>large</em>. Elle peut s&rsquo;utiliser &agrave; une ou deux mains. Sa grande solidit&eacute; en fait l&rsquo;&eacute;p&eacute;e de pr&eacute;dilection des gardes et des soldats.</p>\n<p>C&rsquo;est probablement &agrave; elle que le <em>Guerrier Sorde</em> doit son nom (&agrave; moins que ce ne soit l&rsquo;inverse).</p>","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":"<p>Grand haubert de mailles avec capuche À enfiler sur une cotte de cuir souple ou de drap matelassé) + bottes de cuir / métal.</p>\n<p>&nbsp;</p>","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":"<p>Cet ouvrage de profonde &eacute;rudition sur l&rsquo;origine des couleurs et leur signification onirique est fonci&egrave;rement incompr&eacute;hensible, &agrave; moins de poss&eacute;der un minimum de +4 en voie d&rsquo;Oniros. Il permet d&rsquo;envisager la synth&egrave;se des sorts d&rsquo;<em>Invuln&eacute;rabilit&eacute; Chromatique</em> et de <em>Transmutation Chromatique</em>. Sans son assimilation pr&eacute;alable, la synth&egrave;se de ces sorts est totalement inenvisageable. Sa difficult&eacute; de lecture est de -4, son assimilation requiert 26 points de t&acirc;che, p&eacute;riodicit&eacute; 1 heure.</p>","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":"<p>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.</p>\n<p>&nbsp;</p>","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":"<p>Bien qu&rsquo;&eacute;tant toujours tenu en main, le fouet est consid&eacute;r&eacute; comme une arme de lancer. Sa port&eacute;e est limit&eacute;e par sa longueur, maximum 3 m. Ses dommages sont d&eacute;termin&eacute;s sur la table des Coups non mortels, c&rsquo;est-&agrave;-dire qu&rsquo;ils ne font essentiellement perdre que des points d&rsquo;endurance. Face aux fouets, les armures sont major&eacute;es de 2 points. Le drap matelass&eacute; vaut ainsi 3 et le cuir souple 4. Qui plus est, le cuir &eacute;pais, le cuir / m&eacute;tal, les mailles et les plaques, et toute&nbsp; protection naturelle d&rsquo;une cr&eacute;ature de 5 points ou plus, prot&egrave;gent totalement des d&eacute;g&acirc;ts du fouet. Il est inutile de vouloir fouetter un rhinoc&eacute;ros. Inversement, v&ecirc;tements ordinaires ou pas de v&ecirc;tements du tout valent toujours z&eacute;ro de protection.</p>","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":"<p>L'armure classique du chevalier. Armure complète de plaques (heaume, cuirasse, épaulières, cubitières, ventrière, cuissards, jambières).</p>\n<p>&nbsp;</p>","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":"<p>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.</p>\n<p>&nbsp;</p>","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 lImmobilité Rapide","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"livre","data":{"description":"<p>Ce texte de pure logique ne peut &ecirc;tre assimil&eacute; que si l&rsquo;on poss&egrave;de un minimum de +4 en voie d&rsquo;Hypnos. Il permet d&rsquo;envisager la synth&egrave;se du sort de <em>Concentration</em>. (Sans son assimilation pr&eacute;alable, la synth&egrave;se de ce sort est totalement inenvisageable.) Sa difficult&eacute; de lecture est de -5, son assimilation requiert 12 points de t&acirc;che, p&eacute;riodicit&eacute; 1 heure.</p>","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"}

View File

@ -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" ],