Fix de régressions, stabilisation #575
| @@ -16,7 +16,6 @@ | |||||||
|     "TypeTarot": "Carte de tarot", |     "TypeTarot": "Carte de tarot", | ||||||
|     "TypeCasetmr": "TMR spéciale", |     "TypeCasetmr": "TMR spéciale", | ||||||
|     "TypeRencontre": "Rencontre TMR", |     "TypeRencontre": "Rencontre TMR", | ||||||
|     "TypeRencontrestmr": "Rencontre TMR (ancien)", |  | ||||||
|     "TypeMunition": "Munition", |     "TypeMunition": "Munition", | ||||||
|     "TypeMonnaie": "Monnaie", |     "TypeMonnaie": "Monnaie", | ||||||
|     "TypeHerbe": "Herbe ou plante", |     "TypeHerbe": "Herbe ou plante", | ||||||
|   | |||||||
| @@ -29,7 +29,6 @@ import { Monnaie } from "./item-monnaie.js"; | |||||||
| import { DialogConsommer } from "./dialog-item-consommer.js"; | import { DialogConsommer } from "./dialog-item-consommer.js"; | ||||||
| import { DialogFabriquerPotion } from "./dialog-fabriquer-potion.js"; | import { DialogFabriquerPotion } from "./dialog-fabriquer-potion.js"; | ||||||
| import { RollDataAjustements } from "./rolldata-ajustements.js"; | import { RollDataAjustements } from "./rolldata-ajustements.js"; | ||||||
| import { DialogItemAchat } from "./dialog-item-achat.js"; |  | ||||||
| import { RdDItem } from "./item.js"; | import { RdDItem } from "./item.js"; | ||||||
| import { RdDPossession } from "./rdd-possession.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"; | 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; |       return; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     const acheteur = achat.acheteurId ? game.actors.get(achat.acheteurId) : undefined; |     const acheteur = achat.acheteurId ? game.actors.get(achat.acheteurId) : undefined; | ||||||
|     const vendeur = achat.vendeurId ? game.actors.get(achat.vendeurId) : undefined; |     const vendeur = achat.vendeurId ? game.actors.get(achat.vendeurId) : undefined; | ||||||
|     const vente = achat.vente; |     const vente = achat.vente; | ||||||
| @@ -3724,6 +3722,7 @@ export class RdDActor extends Actor { | |||||||
|         vente["properties"] = new RdDItem(vente.item).getProprietes(); |         vente["properties"] = new RdDItem(vente.item).getProprietes(); | ||||||
|         vente.quantiteNbLots -= achat.choix.nombreLots; |         vente.quantiteNbLots -= achat.choix.nombreLots; | ||||||
|         vente.jsondata = JSON.stringify(vente.item); |         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.update({ content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-vente-item.html', vente) }); | ||||||
|         messageVente.render(true); |         messageVente.render(true); | ||||||
|       } |       } | ||||||
|   | |||||||
| @@ -35,7 +35,7 @@ export class DialogChronologie extends Dialog { | |||||||
|     const options = { |     const options = { | ||||||
|       classes: ["DialogChronologie"], |       classes: ["DialogChronologie"], | ||||||
|       width: 500, |       width: 500, | ||||||
|       height: 350, |       height: 'fit-content', | ||||||
|       'z-index': 99999 |       'z-index': 99999 | ||||||
|     }; |     }; | ||||||
|     const conf = { |     const conf = { | ||||||
| @@ -43,8 +43,7 @@ export class DialogChronologie extends Dialog { | |||||||
|       content: html, |       content: html, | ||||||
|       buttons: { |       buttons: { | ||||||
|         ajout: { label: "Ajouter", callback: it => this.ajouter() }, |         ajout: { label: "Ajouter", callback: it => this.ajouter() }, | ||||||
|       }, |       } | ||||||
|       default: "ajout" |  | ||||||
|     }; |     }; | ||||||
|     super(conf, options); |     super(conf, options); | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -31,8 +31,7 @@ export class DialogStress extends Dialog { | |||||||
|       content: html, |       content: html, | ||||||
|       buttons: { |       buttons: { | ||||||
|         stress: { label: "Stress !", callback: it => { this.onStress(); } } |         stress: { label: "Stress !", callback: it => { this.onStress(); } } | ||||||
|       }, |       } | ||||||
|       default: "stress" |  | ||||||
|     }; |     }; | ||||||
|     super(conf, options); |     super(conf, options); | ||||||
|     this.dialogData = dialogData; |     this.dialogData = dialogData; | ||||||
|   | |||||||
| @@ -102,7 +102,7 @@ export class Misc { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   static join(params, separator = '') { |   static join(params, separator = '') { | ||||||
|     return params.reduce((a, b) => a + separator + b); |     return params?.reduce((a, b) => a + separator + b) ?? ''; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   static connectedGMOrUser(ownerId = undefined) { |   static connectedGMOrUser(ownerId = undefined) { | ||||||
|   | |||||||
| @@ -8,18 +8,19 @@ export class RdDCalendrierEditeur extends Dialog { | |||||||
|  |  | ||||||
|   /* -------------------------------------------- */ |   /* -------------------------------------------- */ | ||||||
|   constructor(html, calendrier, calendrierData) { |   constructor(html, calendrier, calendrierData) { | ||||||
|  |     let dialogConf = { | ||||||
|     let myButtons = { |       content: html, | ||||||
|         saveButton: { label: "Enregistrer", callback: html => this.fillData() } |       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 }   | ||||||
|     // 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 }   |  | ||||||
|     super(dialogConf, dialogOptions) |     super(dialogConf, dialogOptions) | ||||||
|      |      | ||||||
|     this.calendrier = calendrier; |     this.calendrier = calendrier; | ||||||
|     this.calendrierData = calendrierData; //duplicate(calendrierData); |     this.calendrierData = calendrierData; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /* -------------------------------------------- */ |   /* -------------------------------------------- */ | ||||||
|   | |||||||
| @@ -92,7 +92,7 @@ export class RdDCalendrier extends Application { | |||||||
|       minutesRelative: 0, |       minutesRelative: 0, | ||||||
|       indexJour: index, |       indexJour: index, | ||||||
|       annee: Math.floor(index / (RDD_JOUR_PAR_MOIS * RDD_MOIS_PAR_AN)), |       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, |       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 |       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 = {}) { |   fillCalendrierData(formData = {}) { | ||||||
|     console.log(this.calendrier); |     const mois = RdDCalendrier.getDefSigne(this.calendrier.moisRdD); | ||||||
|     let moisKey = heuresList[this.calendrier.moisRdD]; |     const heure = RdDCalendrier.getDefSigne(this.calendrier.heureRdD); | ||||||
|     let heureKey = heuresList[this.calendrier.heureRdD]; |     console.log('fillCalendrierData', this.calendrier, mois, heure); | ||||||
|     console.log(moisKey, heureKey); |  | ||||||
|  |  | ||||||
|     const mois = heuresDef[moisKey]; |     formData.heureKey = heure.key; | ||||||
|     const heure = heuresDef[heureKey]; |     formData.moisKey = mois.key; | ||||||
|  |  | ||||||
|     formData.heureKey = heureKey; |  | ||||||
|     formData.moisKey = moisKey; |  | ||||||
|     formData.jourMois = this.calendrier.jour + 1; |     formData.jourMois = this.calendrier.jour + 1; | ||||||
|     formData.nomMois = mois.label; // heures et mois nommés identiques |     formData.nomMois = mois.label; // heures et mois nommés identiques | ||||||
|     formData.iconMois = dossierIconesHeures + mois.icon; |     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: ["/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: ["/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({ |       rddCommands.registerCommand({ | ||||||
|         path: ["/tmra"], func: (content, msg, params) => rddCommands.getTMRAleatoire(msg, params), |         path: ["/tmra"], func: (content, msg, params) => rddCommands.getTMRAleatoire(msg, params), | ||||||
|         descr: `Tire une case aléatoire des Terres médianes |         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 forêt</strong> détermine une 'forêt' aléatoire | ||||||
|           <br><strong>/tmra</strong> détermine une case aléatoire dans toutes les TMR` }); |           <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({ |       rddCommands.registerCommand({ | ||||||
|         path: ["/tmrr"], func: (content, msg, params) => rddCommands.getRencontreTMR(params), |         path: ["/tmrr"], func: (content, msg, params) => rddCommands.getRencontreTMR(params), | ||||||
|         descr: `Détermine une rencontre dans un type de case |         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</strong> détermine une rencontre aléatoire 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 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({ |       rddCommands.registerCommand({ | ||||||
| @@ -84,7 +85,7 @@ export class RdDCommands { | |||||||
|  |  | ||||||
|       rddCommands.registerCommand({ |       rddCommands.registerCommand({ | ||||||
|         path: ["/payer"], func: (content, msg, params) => RdDUtility.afficherDemandePayer(params[0], params[1]), |         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 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` |           <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); |     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]; |     let command = commandsTable[name]; | ||||||
|     path = path + name + " "; |     path = path + name + " "; | ||||||
|     if (command && command.subTable) { |     if (command && command.subTable) { | ||||||
| @@ -193,7 +194,7 @@ export class RdDCommands { | |||||||
|       } |       } | ||||||
|     } |     } | ||||||
|     if (command && command.func) { |     if (command && command.func) { | ||||||
|       const result = command.func(content, msg, params); |       const result =  await command.func(content, msg, params); | ||||||
|       if (result == false) { |       if (result == false) { | ||||||
|         RdDCommands._chatAnswer(msg, command.descr); |         RdDCommands._chatAnswer(msg, command.descr); | ||||||
|       } |       } | ||||||
| @@ -250,10 +251,8 @@ export class RdDCommands { | |||||||
|     if (params.length == 1 || params.length == 2) { |     if (params.length == 1 || params.length == 2) { | ||||||
|       return TMRRencontres.rollRencontre(params[0], params[1]) |       return TMRRencontres.rollRencontre(params[0], params[1]) | ||||||
|     } |     } | ||||||
|     else { |  | ||||||
|     return false; |     return false; | ||||||
|   } |   } | ||||||
|   } |  | ||||||
|  |  | ||||||
|   /* -------------------------------------------- */ |   /* -------------------------------------------- */ | ||||||
|   async rollRdd(msg, params) { |   async rollRdd(msg, params) { | ||||||
| @@ -305,20 +304,20 @@ export class RdDCommands { | |||||||
|       show: { title: "Table de résolution" } |       show: { title: "Table de résolution" } | ||||||
|     }; |     }; | ||||||
|     await RdDResolutionTable.rollData(rollData); |     await RdDResolutionTable.rollData(rollData); | ||||||
|     RdDCommands._chatAnswer(msg, await RdDResolutionTable.buildRollDataHtml(rollData)); |     return RdDCommands._chatAnswer(msg, await RdDResolutionTable.buildRollDataHtml(rollData)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /* -------------------------------------------- */ |   /* -------------------------------------------- */ | ||||||
|   async rollDeDraconique(msg) { |   async rollDeDraconique(msg) { | ||||||
|     let ddr = await RdDDice.rollTotal("1dr + 7"); |     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) { |   async getTMRAleatoire(msg, params) { | ||||||
|     if (params.length < 2) { |     if (params.length < 2) { | ||||||
|       let type = params[0]; |       let type = params[0]; | ||||||
|       const tmr = await TMRUtility.getTMRAleatoire(type ? (it => it.type == type) : (it => true)); |       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 { |     else { | ||||||
|       return false; |       return false; | ||||||
| @@ -326,6 +325,7 @@ export class RdDCommands { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   async findTMR(msg, params) { |   async findTMR(msg, params) { | ||||||
|  |     if (params && params.length > 0) { | ||||||
|       const search = Misc.join(params, ' '); |       const search = Misc.join(params, ' '); | ||||||
|       const found = TMRUtility.findTMR(search); |       const found = TMRUtility.findTMR(search); | ||||||
|       if (found?.length > 0) { |       if (found?.length > 0) { | ||||||
| @@ -333,13 +333,15 @@ export class RdDCommands { | |||||||
|       } |       } | ||||||
|       return RdDCommands._chatAnswer(msg, 'Aucune TMR correspondant à ' + search); |       return RdDCommands._chatAnswer(msg, 'Aucune TMR correspondant à ' + search); | ||||||
|     } |     } | ||||||
|  |     return false; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   /* -------------------------------------------- */ |   /* -------------------------------------------- */ | ||||||
|   getCoutXpComp(msg, params) { |   getCoutXpComp(msg, params) { | ||||||
|     if (params && (params.length == 1 || params.length == 2)) { |     if (params && (params.length == 1 || params.length == 2)) { | ||||||
|       let to = params.length == 1 ? Number(params[0]) : Number(params[1]); |       let to = params.length == 1 ? Number(params[0]) : Number(params[1]); | ||||||
|       let from = params.length == 1 ? to - 1 : Number(params[0]); |       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 { |     else { | ||||||
|       return false; |       return false; | ||||||
| @@ -350,7 +352,7 @@ export class RdDCommands { | |||||||
|   getCoutXpCarac(msg, params) { |   getCoutXpCarac(msg, params) { | ||||||
|     if (params && params.length == 1) { |     if (params && params.length == 1) { | ||||||
|       let to = Number(params[0]); |       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 { |     else { | ||||||
|       return false; |       return false; | ||||||
|   | |||||||
| @@ -200,7 +200,7 @@ Hooks.once("init", async function () { | |||||||
|       "recettealchimique", "musique", "chant", "danse", "jeu", "recettecuisine", "oeuvre", |       "recettealchimique", "musique", "chant", "danse", "jeu", "recettecuisine", "oeuvre", | ||||||
|       "objet", "arme", "armure", "conteneur", "herbe", "ingredient", "livre", "potion", "munition", |       "objet", "arme", "armure", "conteneur", "herbe", "ingredient", "livre", "potion", "munition", | ||||||
|       "monnaie", "nourritureboisson", "gemme", |       "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", |       "nombreastral", "tache", "maladie", "poison", "possession", | ||||||
|       "tarot", "extraitpoetique" |       "tarot", "extraitpoetique" | ||||||
|   ], makeDefault: true |   ], 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-tache-sheet.html', | ||||||
|       'systems/foundryvtt-reve-de-dragon/templates/item-potion-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-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-queue-sheet.html', | ||||||
|       'systems/foundryvtt-reve-de-dragon/templates/item-souffle-sheet.html', |       'systems/foundryvtt-reve-de-dragon/templates/item-souffle-sheet.html', | ||||||
|       'systems/foundryvtt-reve-de-dragon/templates/item-tarot-sheet.html', |       'systems/foundryvtt-reve-de-dragon/templates/item-tarot-sheet.html', | ||||||
|   | |||||||
| @@ -15,21 +15,15 @@ export class TMRRencontres { | |||||||
|    * @param {*} forcedRoll  |    * @param {*} forcedRoll  | ||||||
|    */ |    */ | ||||||
|   static async rollRencontre(terrain, forcedRoll) { |   static async rollRencontre(terrain, forcedRoll) { | ||||||
|     // TODO: recherche parmi les types de terrains + mauvaise, rejet si plusieurs choix |     terrain = TMRUtility.findTMRLike(terrain); | ||||||
|     const codeTerrain = Grammar.toLowerCaseNoAccent(terrain); |     if (terrain == undefined) { | ||||||
|     if (!terrain) { |       return undefined; | ||||||
|       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; |  | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     if (forcedRoll && (forcedRoll <= 0 || forcedRoll > 100)) { |     if (forcedRoll && (forcedRoll <= 0 || forcedRoll > 100)) { | ||||||
|       forcedRoll = undefined; |       forcedRoll = undefined; | ||||||
|     } |     } | ||||||
|      |     const codeTerrain = Grammar.toLowerCaseNoAccent(terrain) | ||||||
|     const table = await TMRRencontres.$buildTableRencontre(codeTerrain); |     const table = await TMRRencontres.$buildTableRencontre(codeTerrain); | ||||||
|     const [selected, roll] = await TMRRencontres.$selectRencontre(codeTerrain, table, forcedRoll); |     const [selected, roll] = await TMRRencontres.$selectRencontre(codeTerrain, table, forcedRoll); | ||||||
|     const rencontre = await TMRRencontres.createRencontre(selected.rencontre); |     const rencontre = await TMRRencontres.createRencontre(selected.rencontre); | ||||||
| @@ -40,7 +34,7 @@ export class TMRRencontres { | |||||||
|   /* -------------------------------------------- */ |   /* -------------------------------------------- */ | ||||||
|   static async $buildTableRencontre(codeTerrain) { |   static async $buildTableRencontre(codeTerrain) { | ||||||
|     let max = 0; |     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 filtreMauvaise = codeTerrain == 'mauvaise' ? it => it.system.mauvaiseRencontre : it => !it.system.mauvaiseRencontre; | ||||||
|     const rencontres = items.filter(it => it.type == 'rencontre') |     const rencontres = items.filter(it => it.type == 'rencontre') | ||||||
|       .filter(filtreMauvaise) |       .filter(filtreMauvaise) | ||||||
|   | |||||||
| @@ -1,4 +1,3 @@ | |||||||
| import { TMRRencontres } from "./tmr-rencontres.js"; |  | ||||||
| import { Misc } from "./misc.js"; | import { Misc } from "./misc.js"; | ||||||
| import { Grammar } from "./grammar.js"; | import { Grammar } from "./grammar.js"; | ||||||
| import { RdDDice } from "./rdd-dice.js"; | import { RdDDice } from "./rdd-dice.js"; | ||||||
| @@ -288,6 +287,23 @@ export class TMRUtility { | |||||||
|     return Grammar.articleDetermine(tmr.type) + ' ' + tmr.label; |     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) { |   static typeTmrName(type) { | ||||||
|     return Misc.upperFirst(TMRType[Grammar.toLowerCaseNoAccent(type)].name); |     return Misc.upperFirst(TMRType[Grammar.toLowerCaseNoAccent(type)].name); | ||||||
|   } |   } | ||||||
| @@ -339,8 +355,7 @@ export class TMRUtility { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   static findTMR(search) { |   static findTMR(search) { | ||||||
|     const labelSearch = Grammar.toLowerCaseNoAccent(search) |     return TMRUtility.filterTMR(it => Grammar.includesLowerCaseNoAccent(it.label, search) || it.coord == search); | ||||||
|     return TMRUtility.filterTMR(it => Grammar.toLowerCaseNoAccent(it.label).match(labelSearch) || it.coord == search); |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   static filterTMRCoord(filter) { |   static filterTMRCoord(filter) { | ||||||
|   | |||||||
| @@ -586,7 +586,7 @@ | |||||||
|         "recettealchimique", "musique", "chant", "danse", "jeu", "recettecuisine", "oeuvre", |         "recettealchimique", "musique", "chant", "danse", "jeu", "recettecuisine", "oeuvre", | ||||||
|         "objet", "arme", "armure", "conteneur", "herbe", "ingredient", "livre", "potion", "munition", |         "objet", "arme", "armure", "conteneur", "herbe", "ingredient", "livre", "potion", "munition", | ||||||
|         "monnaie", "nourritureboisson", "gemme", |         "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", |         "nombreastral", "tache", "maladie", "poison", "possession", | ||||||
|         "tarot", "extraitpoetique" |         "tarot", "extraitpoetique" | ||||||
|     ], |     ], | ||||||
| @@ -827,10 +827,6 @@ | |||||||
|       }, |       }, | ||||||
|       "description": "" |       "description": "" | ||||||
|     }, |     }, | ||||||
|     "rencontresTMR": { |  | ||||||
|       "description": "", |  | ||||||
|       "descriptionmj": "" |  | ||||||
|     }, |  | ||||||
|     "queue": { |     "queue": { | ||||||
|       "description": "", |       "description": "", | ||||||
|       "descriptionmj": "", |       "descriptionmj": "", | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user