Merge pull request 'Fix de régressions, stabilisation' (#575) from VincentVk/foundryvtt-reve-de-dragon:v10 into v10
Reviewed-on: public/foundryvtt-reve-de-dragon#575
This commit is contained in:
commit
dd2109735d
@ -16,7 +16,6 @@
|
||||
"TypeTarot": "Carte de tarot",
|
||||
"TypeCasetmr": "TMR spéciale",
|
||||
"TypeRencontre": "Rencontre TMR",
|
||||
"TypeRencontrestmr": "Rencontre TMR (ancien)",
|
||||
"TypeMunition": "Munition",
|
||||
"TypeMonnaie": "Monnaie",
|
||||
"TypeHerbe": "Herbe ou plante",
|
||||
|
@ -29,7 +29,6 @@ import { Monnaie } from "./item-monnaie.js";
|
||||
import { DialogConsommer } from "./dialog-item-consommer.js";
|
||||
import { DialogFabriquerPotion } from "./dialog-fabriquer-potion.js";
|
||||
import { RollDataAjustements } from "./rolldata-ajustements.js";
|
||||
import { DialogItemAchat } from "./dialog-item-achat.js";
|
||||
import { RdDItem } from "./item.js";
|
||||
import { RdDPossession } from "./rdd-possession.js";
|
||||
import { ENTITE_BLURETTE, ENTITE_INCARNE, ENTITE_NONINCARNE, HIDE_DICE, SHOW_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js";
|
||||
@ -3658,7 +3657,6 @@ export class RdDActor extends Actor {
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const acheteur = achat.acheteurId ? game.actors.get(achat.acheteurId) : undefined;
|
||||
const vendeur = achat.vendeurId ? game.actors.get(achat.vendeurId) : undefined;
|
||||
const vente = achat.vente;
|
||||
@ -3724,6 +3722,7 @@ export class RdDActor extends Actor {
|
||||
vente["properties"] = new RdDItem(vente.item).getProprietes();
|
||||
vente.quantiteNbLots -= achat.choix.nombreLots;
|
||||
vente.jsondata = JSON.stringify(vente.item);
|
||||
const messageVente = game.messages.get(achat.chatMessageIdVente);
|
||||
messageVente.update({ content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-vente-item.html', vente) });
|
||||
messageVente.render(true);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ export class DialogChronologie extends Dialog {
|
||||
const options = {
|
||||
classes: ["DialogChronologie"],
|
||||
width: 500,
|
||||
height: 350,
|
||||
height: 'fit-content',
|
||||
'z-index': 99999
|
||||
};
|
||||
const conf = {
|
||||
@ -43,8 +43,7 @@ export class DialogChronologie extends Dialog {
|
||||
content: html,
|
||||
buttons: {
|
||||
ajout: { label: "Ajouter", callback: it => this.ajouter() },
|
||||
},
|
||||
default: "ajout"
|
||||
}
|
||||
};
|
||||
super(conf, options);
|
||||
}
|
||||
|
@ -31,8 +31,7 @@ export class DialogStress extends Dialog {
|
||||
content: html,
|
||||
buttons: {
|
||||
stress: { label: "Stress !", callback: it => { this.onStress(); } }
|
||||
},
|
||||
default: "stress"
|
||||
}
|
||||
};
|
||||
super(conf, options);
|
||||
this.dialogData = dialogData;
|
||||
|
@ -102,7 +102,7 @@ export class Misc {
|
||||
}
|
||||
|
||||
static join(params, separator = '') {
|
||||
return params.reduce((a, b) => a + separator + b);
|
||||
return params?.reduce((a, b) => a + separator + b) ?? '';
|
||||
}
|
||||
|
||||
static connectedGMOrUser(ownerId = undefined) {
|
||||
@ -195,4 +195,4 @@ export class Misc {
|
||||
}
|
||||
return subset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,18 +8,19 @@ export class RdDCalendrierEditeur extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
constructor(html, calendrier, calendrierData) {
|
||||
|
||||
let myButtons = {
|
||||
saveButton: { label: "Enregistrer", callback: html => this.fillData() }
|
||||
};
|
||||
|
||||
// Common conf
|
||||
let dialogConf = { content: html, title: "Editeur de date/heure", buttons: myButtons, default: "saveButton" };
|
||||
let dialogOptions = { classes: ["rdddialog"], width: 400, height: 300, 'z-index': 99999 }
|
||||
let dialogConf = {
|
||||
content: html,
|
||||
title: "Editeur de date/heure",
|
||||
buttons: {
|
||||
save: { label: "Enregistrer", callback: html => this.fillData() }
|
||||
},
|
||||
default: "save"
|
||||
};
|
||||
let dialogOptions = { classes: ["rdddialog"], width: 400, height: 'fit-content', 'z-index': 99999 }
|
||||
super(dialogConf, dialogOptions)
|
||||
|
||||
this.calendrier = calendrier;
|
||||
this.calendrierData = calendrierData; //duplicate(calendrierData);
|
||||
this.calendrierData = calendrierData;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -14,7 +14,7 @@ import { DialogChronologie } from "./dialog-chronologie.js";
|
||||
const dossierIconesHeures = 'systems/foundryvtt-reve-de-dragon/icons/heures/'
|
||||
const heuresList = ["vaisseau", "sirene", "faucon", "couronne", "dragon", "epees", "lyre", "serpent", "poissonacrobate", "araignee", "roseau", "chateaudormant"];
|
||||
const heuresDef = {
|
||||
"vaisseau": {key:"vaisseau", label: "Vaisseau", lettreFont: 'v', saison: "printemps", heure: 0, icon: 'hd01.svg' },
|
||||
"vaisseau": {key: "vaisseau", label: "Vaisseau", lettreFont: 'v', saison: "printemps", heure: 0, icon: 'hd01.svg' },
|
||||
"sirene": { key: "sirene", label: "Sirène", lettreFont: 'i', saison: "printemps", heure: 1, icon: 'hd02.svg' },
|
||||
"faucon": { key: "faucon", label: "Faucon", lettreFont: 'f', saison: "printemps", heure: 2, icon: 'hd03.svg' },
|
||||
"couronne": { key: "couronne", label: "Couronne", lettreFont: '', saison: "ete", heure: 3, icon: 'hd04.svg' },
|
||||
@ -92,7 +92,7 @@ export class RdDCalendrier extends Application {
|
||||
minutesRelative: 0,
|
||||
indexJour: index,
|
||||
annee: Math.floor(index / (RDD_JOUR_PAR_MOIS * RDD_MOIS_PAR_AN)),
|
||||
moisRdD: RdDCalendrier.getDefSigne(mois),
|
||||
moisRdD: RdDCalendrier.getDefSigne(mois).heure,
|
||||
moisLabel: RdDCalendrier.getDefSigne(mois).label,
|
||||
jour: (index % RDD_JOUR_PAR_MOIS) // Le calendrier stocke le jour en 0-27, mais en 1-28 à l'affichage
|
||||
}
|
||||
@ -316,16 +316,12 @@ export class RdDCalendrier extends Application {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
fillCalendrierData(formData = {}) {
|
||||
console.log(this.calendrier);
|
||||
let moisKey = heuresList[this.calendrier.moisRdD];
|
||||
let heureKey = heuresList[this.calendrier.heureRdD];
|
||||
console.log(moisKey, heureKey);
|
||||
const mois = RdDCalendrier.getDefSigne(this.calendrier.moisRdD);
|
||||
const heure = RdDCalendrier.getDefSigne(this.calendrier.heureRdD);
|
||||
console.log('fillCalendrierData', this.calendrier, mois, heure);
|
||||
|
||||
const mois = heuresDef[moisKey];
|
||||
const heure = heuresDef[heureKey];
|
||||
|
||||
formData.heureKey = heureKey;
|
||||
formData.moisKey = moisKey;
|
||||
formData.heureKey = heure.key;
|
||||
formData.moisKey = mois.key;
|
||||
formData.jourMois = this.calendrier.jour + 1;
|
||||
formData.nomMois = mois.label; // heures et mois nommés identiques
|
||||
formData.iconMois = dossierIconesHeures + mois.icon;
|
||||
|
@ -39,21 +39,22 @@ export class RdDCommands {
|
||||
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({
|
||||
path: ["/tmr"], func: (content, msg, params) => rddCommands.findTMR(msg, params),
|
||||
descr: `Cherche où se trouve une case des Terres médianes
|
||||
<br><strong>/tmr sord</strong> indique que la cité Sordide est en D13
|
||||
<br><strong>/tmr foret</strong> donne la liste des TMR dont le nom contient "foret" (donc, toutes les forêts)` });
|
||||
rddCommands.registerCommand({
|
||||
path: ["/tmra"], func: (content, msg, params) => rddCommands.getTMRAleatoire(msg, params),
|
||||
descr: `Tire une case aléatoire des Terres médianes
|
||||
<br><strong>/tmra forêt</strong> détermine une 'forêt' aléatoire
|
||||
<br><strong>/tmra</strong> détermine une case aléatoire dans toutes les TMR` });
|
||||
rddCommands.registerCommand({
|
||||
path: ["/tmr"], func: (content, msg, params) => rddCommands.findTMR(msg, params),
|
||||
descr: `Cherche où se trouve une case des Terres médianes
|
||||
<br><strong>/tmr? sordide</strong> indique que la cité Sordide est en D13
|
||||
<br><strong>/tmr? foret</strong> donne la liste des TMR dont le nom contient "foret" (donc, toutes les forêts)` });
|
||||
rddCommands.registerCommand({
|
||||
path: ["/tmrr"], func: (content, msg, params) => rddCommands.getRencontreTMR(params),
|
||||
descr: `Détermine une rencontre dans un type de case
|
||||
<br><strong>/tmrr foret</strong> lance un d100 et détermine la rencontre correspondante en 'forêt'
|
||||
<br><strong>/tmrr forêt 47</strong> détermine la rencontre en 'forêt' pour un jet de dé de 47`
|
||||
<br><strong>/tmrr forêt</strong> détermine une rencontre aléatoire en 'forêt'
|
||||
<br><strong>/tmrr mauvaise</strong> détermine une mauvaise rencontre aléatoire
|
||||
<br><strong>/tmrr for 47</strong> détermine la rencontre en 'forêt' pour un jet de dé de 47`
|
||||
});
|
||||
|
||||
rddCommands.registerCommand({
|
||||
@ -84,7 +85,7 @@ export class RdDCommands {
|
||||
|
||||
rddCommands.registerCommand({
|
||||
path: ["/payer"], func: (content, msg, params) => RdDUtility.afficherDemandePayer(params[0], params[1]),
|
||||
descr: `Permet de payer un montant. Exemples:
|
||||
descr: `Demande aux joueurs de payer un montant. Exemples:
|
||||
<br><strong>/payer 5s 10d</strong> permet d'envoyer un message pour payer 5 sols et 10 deniers
|
||||
<br><strong>/payer 10d</strong> permet d'envoyer un message pour payer 10 deniers`
|
||||
});
|
||||
@ -180,7 +181,7 @@ export class RdDCommands {
|
||||
return this._processCommand(this.commandsTable, command, params, content, msg);
|
||||
}
|
||||
|
||||
_processCommand(commandsTable, name, params, content = '', msg = {}, path = "") {
|
||||
async _processCommand(commandsTable, name, params, content = '', msg = {}, path = "") {
|
||||
let command = commandsTable[name];
|
||||
path = path + name + " ";
|
||||
if (command && command.subTable) {
|
||||
@ -193,7 +194,7 @@ export class RdDCommands {
|
||||
}
|
||||
}
|
||||
if (command && command.func) {
|
||||
const result = command.func(content, msg, params);
|
||||
const result = await command.func(content, msg, params);
|
||||
if (result == false) {
|
||||
RdDCommands._chatAnswer(msg, command.descr);
|
||||
}
|
||||
@ -250,9 +251,7 @@ export class RdDCommands {
|
||||
if (params.length == 1 || params.length == 2) {
|
||||
return TMRRencontres.rollRencontre(params[0], params[1])
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -305,20 +304,20 @@ export class RdDCommands {
|
||||
show: { title: "Table de résolution" }
|
||||
};
|
||||
await RdDResolutionTable.rollData(rollData);
|
||||
RdDCommands._chatAnswer(msg, await RdDResolutionTable.buildRollDataHtml(rollData));
|
||||
return RdDCommands._chatAnswer(msg, await RdDResolutionTable.buildRollDataHtml(rollData));
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollDeDraconique(msg) {
|
||||
let ddr = await RdDDice.rollTotal("1dr + 7");
|
||||
RdDCommands._chatAnswer(msg, `Lancer d'un Dé draconique: ${ddr}`);
|
||||
return RdDCommands._chatAnswer(msg, `Lancer d'un Dé draconique: ${ddr}`);
|
||||
}
|
||||
|
||||
async getTMRAleatoire(msg, params) {
|
||||
if (params.length < 2) {
|
||||
let type = params[0];
|
||||
const tmr = await TMRUtility.getTMRAleatoire(type ? (it => it.type == type) : (it => true));
|
||||
RdDCommands._chatAnswer(msg, `Case aléatoire: ${tmr.coord} - ${tmr.label}`);
|
||||
return RdDCommands._chatAnswer(msg, `Case aléatoire: ${tmr.coord} - ${tmr.label}`);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
@ -326,12 +325,15 @@ export class RdDCommands {
|
||||
}
|
||||
|
||||
async findTMR(msg, params) {
|
||||
const search = Misc.join(params, ' ');
|
||||
const found = TMRUtility.findTMR(search);
|
||||
if (found?.length > 0) {
|
||||
return RdDCommands._chatAnswer(msg, `Les TMRs correspondant à '${search}' sont:` + Misc.join(found.map(it => `<br>${it.coord}: ${it.label}`)));
|
||||
if (params && params.length > 0) {
|
||||
const search = Misc.join(params, ' ');
|
||||
const found = TMRUtility.findTMR(search);
|
||||
if (found?.length > 0) {
|
||||
return RdDCommands._chatAnswer(msg, `Les TMRs correspondant à '${search}' sont:` + Misc.join(found.map(it => `<br>${it.coord}: ${it.label}`)));
|
||||
}
|
||||
return RdDCommands._chatAnswer(msg, 'Aucune TMR correspondant à ' + search);
|
||||
}
|
||||
return RdDCommands._chatAnswer(msg, 'Aucune TMR correspondant à ' + search);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -339,7 +341,7 @@ export class RdDCommands {
|
||||
if (params && (params.length == 1 || params.length == 2)) {
|
||||
let to = params.length == 1 ? Number(params[0]) : Number(params[1]);
|
||||
let from = params.length == 1 ? to - 1 : Number(params[0]);
|
||||
RdDCommands._chatAnswer(msg, `Coût pour passer une compétence de ${from} à ${to}: ${RdDItemCompetence.getDeltaXp(from, to)}`);
|
||||
return RdDCommands._chatAnswer(msg, `Coût pour passer une compétence de ${from} à ${to}: ${RdDItemCompetence.getDeltaXp(from, to)}`);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
@ -350,7 +352,7 @@ export class RdDCommands {
|
||||
getCoutXpCarac(msg, params) {
|
||||
if (params && params.length == 1) {
|
||||
let to = Number(params[0]);
|
||||
RdDCommands._chatAnswer(msg, `Coût pour passer une caractéristique de ${to - 1} à ${to}: ${RdDCarac.getCaracXp(to)}`);
|
||||
return RdDCommands._chatAnswer(msg, `Coût pour passer une caractéristique de ${to - 1} à ${to}: ${RdDCarac.getCaracXp(to)}`);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
@ -200,7 +200,7 @@ Hooks.once("init", async function () {
|
||||
"recettealchimique", "musique", "chant", "danse", "jeu", "recettecuisine", "oeuvre",
|
||||
"objet", "arme", "armure", "conteneur", "herbe", "ingredient", "livre", "potion", "munition",
|
||||
"monnaie", "nourritureboisson", "gemme",
|
||||
"meditation", "rencontresTMR", "queue", "ombre", "souffle", "tete", "casetmr", "sort", "sortreserve",
|
||||
"meditation", "queue", "ombre", "souffle", "tete", "casetmr", "sort", "sortreserve",
|
||||
"nombreastral", "tache", "maladie", "poison", "possession",
|
||||
"tarot", "extraitpoetique"
|
||||
], makeDefault: true
|
||||
|
@ -182,7 +182,6 @@ export class RdDUtility {
|
||||
'systems/foundryvtt-reve-de-dragon/templates/item-tache-sheet.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/item-potion-sheet.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/item-rencontre-sheet.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/item-rencontresTMR-sheet.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/item-queue-sheet.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/item-souffle-sheet.html',
|
||||
'systems/foundryvtt-reve-de-dragon/templates/item-tarot-sheet.html',
|
||||
|
@ -15,21 +15,15 @@ export class TMRRencontres {
|
||||
* @param {*} forcedRoll
|
||||
*/
|
||||
static async rollRencontre(terrain, forcedRoll) {
|
||||
// TODO: recherche parmi les types de terrains + mauvaise, rejet si plusieurs choix
|
||||
const codeTerrain = Grammar.toLowerCaseNoAccent(terrain);
|
||||
if (!terrain) {
|
||||
ChatMessage.create({
|
||||
user: game.user.id,
|
||||
whisper: [game.user.id],
|
||||
content: "Un type de case doit être indiqué (par exemple sanctuaire, desert ou cité)"
|
||||
});
|
||||
return false;
|
||||
terrain = TMRUtility.findTMRLike(terrain);
|
||||
if (terrain == undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (forcedRoll && (forcedRoll <= 0 || forcedRoll > 100)) {
|
||||
forcedRoll = undefined;
|
||||
}
|
||||
|
||||
const codeTerrain = Grammar.toLowerCaseNoAccent(terrain)
|
||||
const table = await TMRRencontres.$buildTableRencontre(codeTerrain);
|
||||
const [selected, roll] = await TMRRencontres.$selectRencontre(codeTerrain, table, forcedRoll);
|
||||
const rencontre = await TMRRencontres.createRencontre(selected.rencontre);
|
||||
@ -40,7 +34,7 @@ export class TMRRencontres {
|
||||
/* -------------------------------------------- */
|
||||
static async $buildTableRencontre(codeTerrain) {
|
||||
let max = 0;
|
||||
const items = await SystemCompendiums.getItems('rencontres');
|
||||
const items = await SystemCompendiums.getItems('rencontres', 'rencontre');
|
||||
const filtreMauvaise = codeTerrain == 'mauvaise' ? it => it.system.mauvaiseRencontre : it => !it.system.mauvaiseRencontre;
|
||||
const rencontres = items.filter(it => it.type == 'rencontre')
|
||||
.filter(filtreMauvaise)
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { TMRRencontres } from "./tmr-rencontres.js";
|
||||
import { Misc } from "./misc.js";
|
||||
import { Grammar } from "./grammar.js";
|
||||
import { RdDDice } from "./rdd-dice.js";
|
||||
@ -287,13 +286,30 @@ export class TMRUtility {
|
||||
const tmr = TMRMapping[coord];
|
||||
return Grammar.articleDetermine(tmr.type) + ' ' + tmr.label;
|
||||
}
|
||||
|
||||
static findTMRLike(type, options = {inclusMauvaise:true}) {
|
||||
const choix = [...Object.values(TMRType)]
|
||||
if (options.inclusMauvaise){
|
||||
choix.push({name: 'Mauvaise'});
|
||||
}
|
||||
const selection = Misc.findAllLike(type, choix).map(it => it.name);
|
||||
if (selection.length == 0) {
|
||||
ui.notifications.warn(`Un type de TMR doit être indiqué, '${type}' n'est pas trouvé dans ${choix}`);
|
||||
return undefined;
|
||||
}
|
||||
if (selection.length > 1) {
|
||||
ui.notifications.warn(`Plusieurs types de TMR pourraient correspondre à '${type}': ${selection}`);
|
||||
return undefined;
|
||||
}
|
||||
return selection[0];
|
||||
}
|
||||
|
||||
static typeTmrName(type) {
|
||||
return Misc.upperFirst(TMRType[Grammar.toLowerCaseNoAccent(type)].name);
|
||||
}
|
||||
|
||||
|
||||
static buildSelectionTypesTMR(typesTMR) {
|
||||
typesTMR= typesTMR?? [];
|
||||
typesTMR = typesTMR?? [];
|
||||
return Object.values(TMRType).map(value => Misc.upperFirst(value.name))
|
||||
.sort()
|
||||
.map(name => { return { name: name, selected: typesTMR.includes(name) } });
|
||||
@ -339,8 +355,7 @@ export class TMRUtility {
|
||||
}
|
||||
|
||||
static findTMR(search) {
|
||||
const labelSearch = Grammar.toLowerCaseNoAccent(search)
|
||||
return TMRUtility.filterTMR(it => Grammar.toLowerCaseNoAccent(it.label).match(labelSearch) || it.coord == search);
|
||||
return TMRUtility.filterTMR(it => Grammar.includesLowerCaseNoAccent(it.label, search) || it.coord == search);
|
||||
}
|
||||
|
||||
static filterTMRCoord(filter) {
|
||||
|
@ -586,7 +586,7 @@
|
||||
"recettealchimique", "musique", "chant", "danse", "jeu", "recettecuisine", "oeuvre",
|
||||
"objet", "arme", "armure", "conteneur", "herbe", "ingredient", "livre", "potion", "munition",
|
||||
"monnaie", "nourritureboisson", "gemme",
|
||||
"meditation", "rencontre", "rencontresTMR", "queue", "ombre", "souffle", "tete", "casetmr", "signedraconique", "sort", "sortreserve",
|
||||
"meditation", "rencontre", "queue", "ombre", "souffle", "tete", "casetmr", "signedraconique", "sort", "sortreserve",
|
||||
"nombreastral", "tache", "maladie", "poison", "possession",
|
||||
"tarot", "extraitpoetique"
|
||||
],
|
||||
@ -827,10 +827,6 @@
|
||||
},
|
||||
"description": ""
|
||||
},
|
||||
"rencontresTMR": {
|
||||
"description": "",
|
||||
"descriptionmj": ""
|
||||
},
|
||||
"queue": {
|
||||
"description": "",
|
||||
"descriptionmj": "",
|
||||
|
Loading…
Reference in New Issue
Block a user