From 6873cf0d41a2c25862d21f22c1cd8b59b8f7c13d Mon Sep 17 00:00:00 2001 From: sladecraven Date: Mon, 6 Jun 2022 23:18:33 +0200 Subject: [PATCH 1/6] Increase release --- system.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system.json b/system.json index ece7cfbb..b38906ac 100644 --- a/system.json +++ b/system.json @@ -29,7 +29,7 @@ "url": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/", "license": "LICENSE.txt", "flags": {}, - "version": "1.5.77", + "version": "1.5.78", "minimumCoreVersion": "0.8.0", "compatibleCoreVersion": "9", "scripts": [], @@ -500,7 +500,7 @@ "dependencies": [], "socket": true, "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v1.5/system.json", - "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-1.5.77.zip", + "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-1.5.78.zip", "protected": false, "gridDistance": 1, "gridUnits": "m", From 5868bf16e082c6edb49111327c8cac63e420de5b Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sat, 25 Jun 2022 22:18:46 +0200 Subject: [PATCH 2/6] =?UTF-8?q?Commande=20m=C3=A9t=C3=A9o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/rdd-commands.js | 5 ++ module/rdd-meteo.js | 134 +++++++++++++++++++++++++++++ module/rdd-utility.js | 2 + templates/chat-resultat-meteo.html | 9 ++ 4 files changed, 150 insertions(+) create mode 100644 module/rdd-meteo.js create mode 100644 templates/chat-resultat-meteo.html diff --git a/module/rdd-commands.js b/module/rdd-commands.js index 8793f306..fdddcb05 100644 --- a/module/rdd-commands.js +++ b/module/rdd-commands.js @@ -7,6 +7,7 @@ import { RdDItemCompetence } from "./item-competence.js"; import { Misc } from "./misc.js"; import { RdDCarac } from "./rdd-carac.js"; import { RdDDice } from "./rdd-dice.js"; +import { RdDMeteo } from "./rdd-meteo.js"; import { RdDNameGen } from "./rdd-namegen.js"; import { RdDResolutionTable } from "./rdd-resolution-table.js"; import { RdDRollResolutionTable } from "./rdd-roll-resolution-table.js"; @@ -34,6 +35,7 @@ export class RdDCommands { rddCommands.registerCommand({ path: ["/table", "souffle"], func: (content, msg, params) => RdDRollTables.getSouffle(true), descr: " Tire un Souffle de Dragon" }); rddCommands.registerCommand({ path: ["/table", "comp"], func: (content, msg, params) => RdDRollTables.getCompetence(true), descr: "Tire une compétence au hasard" }); rddCommands.registerCommand({ path: ["/table", "tarot"], func: (content, msg, params) => RdDRollTables.getTarot(true), descr: "Tire une carte du Tarot Draconique" }); + rddCommands.registerCommand({ path: ["/meteo"], func: (content, msg, params) => rddCommands.getMeteo(msg, params), descr: "Propose une météo marine" }); rddCommands.registerCommand({ path: ["/nom"], func: (content, msg, params) => RdDNameGen.getName(msg, params), descr: "Génère un nom aléatoire" }); rddCommands.registerCommand({ @@ -398,5 +400,8 @@ export class RdDCommands { } return true; } + async getMeteo(msg, params) { + return await RdDMeteo.getMeteo(); + } } diff --git a/module/rdd-meteo.js b/module/rdd-meteo.js new file mode 100644 index 00000000..8dbff49c --- /dev/null +++ b/module/rdd-meteo.js @@ -0,0 +1,134 @@ + +const vents = [ + { min: 0, max: 0, valeur: 'Calme' }, + { min: 1, max: 1, valeur: 'Légère brise' }, + { min: 2, max: 2, valeur: 'Jolie brise' }, + { min: 3, max: 3, valeur: 'Bonne brise' }, + { min: 4, max: 4, valeur: 'Vent frais' }, + { min: 5, max: 5, valeur: 'Coup de vent' }, + { min: 6, max: 6, valeur: 'Fort coup de vent' }, + { min: 7, max: 9, valeur: 'Tempête' }, + { min: 10, max: 13, valeur: 'Violente tempête' }, + { min: 14, valeur: 'Ouragan' }, +] +const mers = [ + { min: 0, max: 0, valeur: 'Calme' }, + { min: 1, max: 1, valeur: 'Belle' }, + { min: 2, max: 2, valeur: 'Peu agitée' }, + { min: 3, max: 3, valeur: 'Agitée' }, + { min: 4, max: 4, valeur: 'Forte' }, + { min: 5, max: 6, valeur: 'Très forte' }, + { min: 7, max: 9, valeur: 'Grosse' }, + { min: 10, max: 13, valeur: 'Très grosse' }, + { min: 14, valeur: 'Énorme' }, +] + +const nuages = [ + { min: 0, max: 3, valeur: 'dégagé' }, + { min: 4, max: 6, valeur: 'passages nuageux' }, + { min: 7, max: 9, valeur: 'nuageux', }, + { min: 10, max: 10, valeur: 'brouillard' }, + { min: 11, max: 12, valeur: 'bruine' }, + { min: 13, valeur: 'très nuageux' }, +] + +const pluies = [ + { min: 0, max: 4, valeur: 'aucune' }, + { min: 5, max: 5, valeur: 'bruine, crachin, éparse' }, + { min: 6, max: 7, valeur: 'averses' }, + { min: 8, max: 10, valeur: 'pluvieux', }, + { min: 11, max: 13, valeur: 'forte pluie' }, + { min: 14, valeur: 'déluge' }, +] + +const temperatures = [ + { max: -14, valeur: 'glaciale' }, + { min: -13, max: -10, valeur: 'Très froide' }, + { min: -9, max: -7, valeur: 'froide' }, + { min: -6, max: -4, valeur: 'fraîche' }, + { min: -3, max: 3, valeur: 'de saison' }, + { min: 4, max: 6, valeur: 'élevée' }, + { min: 7, max: 9, valeur: 'chaude' }, + { min: 10, max: 13, valeur: 'torride' }, + { min: 14, valeur: 'caniculaire' }, +] + +export class RdDMeteo { + static async getForce() { + const roll = new Roll(`1dr`); + await roll.evaluate({ async: true }); + return roll.total; + } + + static async getPluie(nuage) { + return nuage <= 3 ? 0 : await RdDMeteo.getForce(); + } + + static async getTemperature() { + const degre = await RdDMeteo.getForce(); + const rollChaudFroid = new Roll('1d2'); + await rollChaudFroid.evaluate({ async: true }); + const chaudFroid = rollChaudFroid.total == 1; + return chaudFroid.total ? degre : -degre; + } + + static async getDirection(direction) { + const roll = new Roll(`1d16`); + await roll.evaluate({ async: true }); + switch (roll.total % 16) { + case 0: return 'Nord'; + case 1: return 'Nord Nord Est'; + case 2: return 'Nord Est'; + case 3: return 'Est Nord Est'; + case 4: return 'Est'; + case 5: return 'Est Sud Est'; + case 6: return 'Sud Est'; + case 7: return 'Sud Sud Est'; + case 8: return 'Sud'; + case 9: return 'Sud Sud Ouest'; + case 10: return 'Sud Ouest'; + case 11: return 'Ouest Sud Ouest'; + case 12: return 'Ouest'; + case 13: return 'Ouest Nord Ouest'; + case 14: return 'Nord Ouest'; + case 15: return 'Nord Nord Ouest'; + } + return undefined; + } + + static async getMeteo() { + const vent = await RdDMeteo.getForce(); + const mer = await RdDMeteo.getForce(); + const nuage = await RdDMeteo.getForce(); + const pluie = await RdDMeteo.getPluie(nuage); + const temperature = await RdDMeteo.getTemperature(); + const meteo = { + vent: { force: vent, direction: await RdDMeteo.getDirection(), }, + mer: { force: mer, direction: await RdDMeteo.getDirection(), }, + temperature: { force: temperature }, + nuage: { force: nuage, }, + pluie: { force: pluie }, + } + meteo.vent.description = RdDMeteo.vent(meteo.vent.force); + meteo.mer.description = RdDMeteo.mer(meteo.mer.force), + meteo.temperature.description = RdDMeteo.temperature(meteo.temperature.force); + meteo.nuage.description = RdDMeteo.nuage(meteo.nuage.force); + meteo.pluie.description = RdDMeteo.pluie(meteo.pluie.force); + + ChatMessage.create({ + content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-resultat-meteo.html', meteo), + whisper: ChatMessage.getWhisperRecipients('GM') + }); + } + + static description(liste, force, valeur = it => it.valeur) { + let select = liste.find(it => (it.min == undefined || it.min <= force) && (it.max == undefined || force <= it.max)); + return valeur(select ?? liste[0]); + } + + static vent(force) { return this.description(vents, force); } + static mer(force) { return this.description(mers, force); } + static nuage(force) { return this.description(nuages, force); } + static pluie(force) { return this.description(pluies, force); } + static temperature(force) { return this.description(temperatures, force); } +} \ No newline at end of file diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 786ad9b1..50865039 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -221,8 +221,10 @@ export class RdDUtility { ]; Handlebars.registerHelper('upperFirst', str => Misc.upperFirst(str ?? 'Null')); + Handlebars.registerHelper('lowerFirst', str => Misc.lowerFirst(str ?? 'Null')); Handlebars.registerHelper('upper', str => str?.toUpperCase() ?? 'NULL'); Handlebars.registerHelper('le', str => Grammar.articleDetermine(str)); + Handlebars.registerHelper('apostrophe', (article, str) => Grammar.apostrophe(article, str)); Handlebars.registerHelper('un', str => Grammar.articleIndetermine(str)); Handlebars.registerHelper('accord', (genre, ...args) => Grammar.accord(genre, args)); Handlebars.registerHelper('buildConteneur', (objet) => { return new Handlebars.SafeString(RdDUtility.buildConteneur(objet)); }); diff --git a/templates/chat-resultat-meteo.html b/templates/chat-resultat-meteo.html new file mode 100644 index 00000000..96d7e4b8 --- /dev/null +++ b/templates/chat-resultat-meteo.html @@ -0,0 +1,9 @@ +Météo +

Météo aléatoire

+