forked from public/foundryvtt-reve-de-dragon
		
	Minor fixes
This commit is contained in:
		| @@ -30,6 +30,7 @@ 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"; | ||||
|  | ||||
|  | ||||
| /* -------------------------------------------- */ | ||||
| @@ -1940,7 +1941,7 @@ export class RdDActor extends Actor { | ||||
|     const itemData = Misc.data(item); | ||||
|     const exotisme = Math.min(itemData.data.exotisme, itemData.data.qualite, 0); | ||||
|     if (exotisme < 0) { | ||||
|       const rolled = await this.rollCaracCompetence('volonte', 'cuisine', exotisme, { title: `surmonte l'exotisme de ${itemData.name}` }); | ||||
|       const rolled = await this.rollCaracCompetence('volonte', 'cuisine', exotisme, { title: `tente de surmonter l'exotisme de ${itemData.name}` }); | ||||
|       if (rolled.isEchec) { | ||||
|         if (!choix.seForcer) { | ||||
|           return false; | ||||
| @@ -3511,61 +3512,61 @@ export class RdDActor extends Actor { | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   async achatVente(vendeurId, acheteurId, venteData, chatMessageIdVente) { | ||||
|     if (vendeurId == acheteurId) { | ||||
|   async achatVente(achat) { | ||||
|     if (achat.vendeurId == achat.acheteurId) { | ||||
|       ui.notifications.info("Inutile de se vendre à soi-même"); | ||||
|       return; | ||||
|     } | ||||
|     if (!Misc.isElectedUser()) { | ||||
|       RdDActor.remoteActorCall({ | ||||
|         actorId: vendeurId ?? acheteurId, | ||||
|         method: 'achatVente', args: [vendeurId, acheteurId, venteData, chatMessageIdVente] | ||||
|         actorId: achat.vendeurId ?? achat.acheteurId, | ||||
|         method: 'achatVente', args: [achat] | ||||
|       }); | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|     const acheteur = acheteurId ? game.actors.get(acheteurId) : undefined; | ||||
|     const vendeur = vendeurId ? game.actors.get(vendeurId) : undefined; | ||||
|     const itemId = venteData.item._id; | ||||
|     const acheteur = achat.acheteurId ? game.actors.get(achat.acheteurId) : undefined; | ||||
|     const vendeur = achat.vendeurId ? game.actors.get(achat.vendeurId) : undefined; | ||||
|     const messageVente = game.messages.get(achat.chatMessageIdVente); | ||||
|     const html = await messageVente.getHTML(); | ||||
|     const buttonAcheter = html.find(".button-acheter")[0]; | ||||
|     const vente = DialogItemAchat.prepareVenteData(buttonAcheter, achat.vendeurId, vendeur, acheteur); | ||||
|     const itemId = vente.item._id; | ||||
|  | ||||
|     const coutDeniers = Math.floor((venteData.prixTotal ?? 0) * 100); | ||||
|     venteData.quantiteTotal = (venteData.nombreLots ?? 1) * (venteData.tailleLot); | ||||
|     const coutDeniers = Math.floor((achat.prixTotal ?? 0) * 100); | ||||
|     achat.quantiteTotal = (achat.nombreLots ?? 1) * (vente.tailleLot); | ||||
|     if (acheteur) { | ||||
|       let resteAcheteur = await acheteur.depenser(coutDeniers); | ||||
|       if (resteAcheteur < 0) { | ||||
|         ui.notifications.warn(`Vous n'avez pas assez d'argent pour payer ${venteData.prixTotal} sols !`); | ||||
|         ui.notifications.warn(`Vous n'avez pas assez d'argent pour payer ${vente.prixTotal} sols !`); | ||||
|         return; | ||||
|       } | ||||
|     } | ||||
|     if (vendeur) { | ||||
|       let itemData = Misc.data(vendeur.getObjet(itemId)); | ||||
|       // diminuer QuantiteVendeur | ||||
|       if ("quantite" in itemData.data ? | ||||
|         itemData.data.quantite < venteData.quantiteTotal : venteData.nombreLots != 1) { | ||||
|         // pas assez de quantite | ||||
|       let itemVenduData = Misc.data(vendeur.getObjet(itemId)); | ||||
|       if ("quantite" in itemVenduData.data ? itemVenduData.data.quantite < achat.quantiteTotal : achat.nombreLots != 1) { | ||||
|         await acheteur?.ajouterDeniers(coutDeniers); | ||||
|         ui.notifications.warn(`Le vendeur n'a plus assez de ${venteData.item.name} !`); | ||||
|         ui.notifications.warn(`Le vendeur n'a plus assez de ${vente.item.name} !`); | ||||
|         return; | ||||
|       } | ||||
|       vendeur.ajouterDeniers(coutDeniers); | ||||
|       let qtReste = (itemData.data.quantite ?? 1) - venteData.quantiteTotal; | ||||
|       if (qtReste == 0) { | ||||
|       let resteQuantite = (itemVenduData.data.quantite ?? 1) - achat.quantiteTotal; | ||||
|       if (resteQuantite == 0) { | ||||
|         vendeur.deleteEmbeddedDocuments("Item", itemId); | ||||
|       } | ||||
|       else { | ||||
|         vendeur.updateEmbeddedDocuments("Item", [{ _id: itemId, 'data.quantite': qtReste }]); | ||||
|         vendeur.updateEmbeddedDocuments("Item", [{ _id: itemId, 'data.quantite': resteQuantite }]); | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     if (acheteur) { | ||||
|       const achat = { | ||||
|         type: venteData.item.type, | ||||
|         img: venteData.item.img, | ||||
|         name: venteData.item.name, | ||||
|         data: venteData.item.data | ||||
|       const achatData = { | ||||
|         type: vente.item.type, | ||||
|         img: vente.item.img, | ||||
|         name: vente.item.name, | ||||
|         data: vente.item.data | ||||
|       } | ||||
|       achat.data.quantite = venteData.quantiteTotal; | ||||
|       await acheteur.createEmbeddedDocuments("Item", [achat]); | ||||
|       achatData.data.quantite = achat.quantiteTotal; | ||||
|       await acheteur.createEmbeddedDocuments("Item", [achatData]); | ||||
|     } | ||||
|     if (coutDeniers > 0) { | ||||
|       RdDAudio.PlayContextAudio("argent"); | ||||
| @@ -3573,19 +3574,16 @@ export class RdDActor extends Actor { | ||||
|  | ||||
|     ChatMessage.create({ | ||||
|       whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name), | ||||
|       content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-achat-item.html', venteData) | ||||
|       content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-achat-item.html', vente) | ||||
|     }); | ||||
|  | ||||
|     if (!venteData.quantiteIllimite) { | ||||
|       if (venteData.quantiteNbLots <= venteData.nombreLots) { | ||||
|     if (!vente.quantiteIllimite) { | ||||
|       if (vente.quantiteNbLots <= achat.nombreLots) { | ||||
|         ChatUtility.removeChatMessageId(chatMessageIdVente); | ||||
|       } | ||||
|       else { | ||||
|         venteData.quantiteNbLots -= venteData.nombreLots; | ||||
|         venteData.jsondata = JSON.stringify(venteData.item); | ||||
|         let newMessageVente = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-vente-item.html', venteData); | ||||
|         const messageVente = game.messages.get(chatMessageIdVente); | ||||
|         messageVente.update({ content: newMessageVente }); | ||||
|         vente.quantiteNbLots -= achat.nombreLots; | ||||
|         messageVente.update({ content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-vente-item.html', vente) }); | ||||
|         messageVente.render(true); | ||||
|       } | ||||
|     } | ||||
| @@ -4081,7 +4079,7 @@ export class RdDActor extends Actor { | ||||
|     if (Misc.isElectedUser()) { | ||||
|       let draconique = Draconique.all().find(it => it.isCase(item)); | ||||
|       if (draconique) { | ||||
|         draconique.onActorDeleteCaseTmr(this, item) | ||||
|         draconique.onActorDeleteCaseTmr(this, Misc.data(item)) | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   | ||||
| @@ -39,6 +39,8 @@ export class DialogCreateSigneDraconique extends Dialog { | ||||
|   } | ||||
|  | ||||
|   async _onCreerSigneActeurs() { | ||||
|     await $("[name='signe.data.ephemere']").change(); | ||||
|     await $(".signe-xp-sort").change(); | ||||
|     this.validerSigne(); | ||||
|     this.dialogData.actors.filter(it => it.selected).map(it => game.actors.get(it._id)) | ||||
|       .forEach(actor => this._createSigneForActor(actor, this.dialogData.signe)); | ||||
| @@ -75,6 +77,7 @@ export class DialogCreateSigneDraconique extends Dialog { | ||||
|     html.find(".select-actor").change((event) => this.onSelectActor(event)); | ||||
|     html.find(".signe-xp-sort").change((event) => this.onValeurXpSort(event)); | ||||
|   } | ||||
|  | ||||
|   async setSigneAleatoire() { | ||||
|     const newSigne = await RdDItemSigneDraconique.randomSigneDraconique({ephemere: true}); | ||||
|  | ||||
|   | ||||
| @@ -25,8 +25,8 @@ export class DialogFabriquerPotion extends Dialog { | ||||
|   /* -------------------------------------------- */ | ||||
|   static prepareData(actor, item) { | ||||
|     let potionData = duplicate(Misc.data(item)); | ||||
|     potionData.nbBrinsSelect = RdDUtility.buildListOptions( 1, potionData.data.quantite); | ||||
|     potionData.nbBrins =  potionData.data.quantite; | ||||
|     potionData.nbBrinsSelect = RdDUtility.buildListOptions(1, potionData.data.quantite); | ||||
|     potionData.nbBrins = Math.min(potionData.data.quantite, DialogFabriquerPotion.getNombreBrinOptimal(potionData)); | ||||
|     potionData.buttonName = "Fabriquer"; | ||||
|     return potionData; | ||||
|   } | ||||
| @@ -35,9 +35,7 @@ export class DialogFabriquerPotion extends Dialog { | ||||
|   constructor(actor, potionData, conf, options) { | ||||
|     conf.buttons = { | ||||
|       [potionData.buttonName]: { | ||||
|         label: potionData.buttonName, callback: it => { | ||||
|           this.fabriquer(); | ||||
|         } | ||||
|         label: potionData.buttonName, callback: it => this.onFabriquer(it) | ||||
|       } | ||||
|     }; | ||||
|  | ||||
| @@ -47,6 +45,14 @@ export class DialogFabriquerPotion extends Dialog { | ||||
|     this.potionData = potionData; | ||||
|   } | ||||
|  | ||||
|   static getNombreBrinOptimal(herbeData) { | ||||
|     switch (herbeData.data.categorie ?? '') { | ||||
|       case "Soin": return 12 - herbeData.data.niveau; | ||||
|       case "Repos": return 7 - herbeData.data.niveau; | ||||
|     } | ||||
|     return 1; | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   activateListeners(html) { | ||||
|     super.activateListeners(html); | ||||
| @@ -57,8 +63,9 @@ export class DialogFabriquerPotion extends Dialog { | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   async fabriquer() { | ||||
|     this.actor.fabriquerPotion( this.potionData ); | ||||
|   async onFabriquer(it) { | ||||
|     await $("#nbBrins").change(); | ||||
|     this.actor.fabriquerPotion(this.potionData); | ||||
|     this.close(); | ||||
|   } | ||||
| } | ||||
| @@ -1,17 +1,18 @@ | ||||
| import { RdDActor } from "./actor.js"; | ||||
| import { HtmlUtility } from "./html-utility.js"; | ||||
|  | ||||
| import { Misc } from "./misc.js"; | ||||
| import { RdDUtility } from "./rdd-utility.js"; | ||||
|  | ||||
| export class DialogItemAchat extends Dialog { | ||||
|  | ||||
|   static async onButtonAcheter(event) { | ||||
|     let jsondata = event.currentTarget.attributes['data-jsondata']?.value; | ||||
|     if (!jsondata) { | ||||
|     const buttonAcheter = event.currentTarget; | ||||
|     if (!buttonAcheter.attributes['data-jsondata']?.value) { | ||||
|       ui.notifications.warn("Impossible d'acheter: informations sur l'objet manquantes") | ||||
|       return; | ||||
|     } | ||||
|     const vendeurId = event.currentTarget.attributes['data-vendeurId']?.value; | ||||
|     const chatMessageIdVente = RdDUtility.findChatMessageId(buttonAcheter); | ||||
|  | ||||
|     const vendeurId = buttonAcheter.attributes['data-vendeurId']?.value; | ||||
|     const vendeur = vendeurId ? game.actors.get(vendeurId) : undefined; | ||||
|     const acheteur = RdDUtility.getSelectedActor(); | ||||
|  | ||||
| @@ -20,22 +21,7 @@ export class DialogItemAchat extends Dialog { | ||||
|       return; | ||||
|     } | ||||
|  | ||||
|     const chatMessageIdVente = RdDUtility.findChatMessageId(event.currentTarget); | ||||
|     const itemData = JSON.parse(jsondata); | ||||
|     const prixLot = event.currentTarget.attributes['data-prixLot']?.value ?? 0; | ||||
|     let venteData = { | ||||
|       item: itemData, | ||||
|       vendeurId: vendeurId, | ||||
|       vendeur: Misc.data(vendeur), | ||||
|       acheteur: Misc.data(acheteur), | ||||
|       tailleLot: event.currentTarget.attributes['data-tailleLot']?.value ?? 1, | ||||
|       quantiteIllimite : event.currentTarget.attributes['data-quantiteIllimite']?.value == 'true', | ||||
|       quantiteNbLots: event.currentTarget.attributes['data-quantiteNbLots']?.value, | ||||
|       nombreLots: 1, | ||||
|       prixLot: prixLot, | ||||
|       prixTotal: prixLot, | ||||
|       isVente: prixLot > 0 | ||||
|     }; | ||||
|     let venteData = DialogItemAchat.prepareVenteData(buttonAcheter, vendeurId, vendeur, acheteur); | ||||
|     const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/dialog-item-achat.html`, venteData); | ||||
|     const dialog = new DialogItemAchat(html, vendeur, acheteur, venteData, chatMessageIdVente); | ||||
|     dialog.render(true); | ||||
| @@ -63,13 +49,34 @@ export class DialogItemAchat extends Dialog { | ||||
|     this.venteData = venteData; | ||||
|   } | ||||
|  | ||||
|   static prepareVenteData(buttonAcheter, vendeurId, vendeur, acheteur) { | ||||
|     const jsondata = buttonAcheter.attributes['data-jsondata']?.value; | ||||
|     const prixLot = buttonAcheter.attributes['data-prixLot']?.value ?? 0; | ||||
|     let venteData = { | ||||
|       item: JSON.parse(jsondata), | ||||
|       vendeurId: vendeurId, | ||||
|       vendeur: Misc.data(vendeur), | ||||
|       acheteur: Misc.data(acheteur), | ||||
|       tailleLot: parseInt(buttonAcheter.attributes['data-tailleLot']?.value ?? 1), | ||||
|       quantiteIllimite: buttonAcheter.attributes['data-quantiteIllimite']?.value == 'true', | ||||
|       quantiteNbLots: parseInt(buttonAcheter.attributes['data-quantiteNbLots']?.value), | ||||
|       nombreLots: 1, | ||||
|       prixLot: prixLot, | ||||
|       prixTotal: prixLot, | ||||
|       isVente: prixLot > 0 | ||||
|     }; | ||||
|     return venteData; | ||||
|   } | ||||
|  | ||||
|   async onAchat() { | ||||
|     (this.vendeur ?? this.acheteur).achatVente( | ||||
|       this.vendeur?.id, | ||||
|       this.acheteur?.id, | ||||
|       this.venteData, | ||||
|       this.chatMessageIdVente | ||||
|     ); | ||||
|     await $(".nombreLots").change(); | ||||
|     (this.vendeur ?? this.acheteur).achatVente({ | ||||
|       vendeurId: this.vendeur?.id, | ||||
|       acheteurId: this.acheteur?.id, | ||||
|       nombreLots: this.venteData.nombreLots, | ||||
|       prixTotal: this.venteData.prixTotal, | ||||
|       chatMessageIdVente: this.chatMessageIdVente | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   | ||||
| @@ -17,9 +17,7 @@ export class DialogConsommer extends Dialog { | ||||
|       default: consommerData.buttonName, | ||||
|       buttons: { | ||||
|         [consommerData.buttonName]: { | ||||
|           label: consommerData.buttonName, callback: it => { | ||||
|             this.actor.consommer(this.item, this.consommerData.choix); | ||||
|           } | ||||
|           label: consommerData.buttonName, callback: it => this.onConsommer(it) | ||||
|         } | ||||
|       } | ||||
|     }; | ||||
| @@ -31,6 +29,12 @@ export class DialogConsommer extends Dialog { | ||||
|     this.consommerData = consommerData; | ||||
|   } | ||||
|  | ||||
|   async onConsommer(event) { | ||||
|     await $(".se-forcer").change(); | ||||
|     await $(".consommer-doses").change(); | ||||
|     this.actor.consommer(this.item, this.consommerData.choix); | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   static prepareData(actor, item, options) { | ||||
|     const itemData = duplicate(Misc.data(item)); | ||||
| @@ -68,15 +72,19 @@ export class DialogConsommer extends Dialog { | ||||
|   /* -------------------------------------------- */ | ||||
|   activateListeners(html) { | ||||
|     super.activateListeners(html); | ||||
|     html.find(".se-forcer").change(event => { | ||||
|       this.consommerData.choix.seForcer = event.currentTarget.checked; | ||||
|     }); | ||||
|     html.find(".consommer-doses").change(event => { | ||||
|       this.consommerData.choix.doses = Number(event.currentTarget.value); | ||||
|       DialogConsommer.calculDoses(this.consommerData); | ||||
|       $(".total-sust").text(this.consommerData.totalSust) | ||||
|       $(".total-desaltere").text(this.consommerData.totalDesaltere) | ||||
|     }); | ||||
|     html.find(".se-forcer").change(event => this.setSeForcer(event)); | ||||
|     html.find(".consommer-doses").change(event => this.selectDoses(event)); | ||||
|   } | ||||
|  | ||||
|  | ||||
|   setSeForcer(event) { | ||||
|     this.consommerData.choix.seForcer = event.currentTarget.checked; | ||||
|   } | ||||
|  | ||||
|   selectDoses(event) { | ||||
|     this.consommerData.choix.doses = Number(event.currentTarget.value); | ||||
|     DialogConsommer.calculDoses(this.consommerData); | ||||
|     $(".total-sust").text(this.consommerData.totalSust); | ||||
|     $(".total-desaltere").text(this.consommerData.totalDesaltere); | ||||
|   } | ||||
| } | ||||
| @@ -30,7 +30,7 @@ export class DialogItemVente extends Dialog { | ||||
|       title: "Proposer", | ||||
|       content: html, | ||||
|       default: "proposer", | ||||
|       buttons: { "proposer": { label: "Proposer", callback: it => { this.onProposer(); } } } | ||||
|       buttons: { "proposer": { label: "Proposer", callback: it => { this.onProposer(it); } } } | ||||
|     }; | ||||
|  | ||||
|     super(conf, options); | ||||
| @@ -38,7 +38,11 @@ export class DialogItemVente extends Dialog { | ||||
|     this.venteData = venteData; | ||||
|   } | ||||
|  | ||||
|   async onProposer() { | ||||
|   async onProposer(it) { | ||||
|     await $(".tailleLot").change(); | ||||
|     await $(".quantiteNbLots").change(); | ||||
|     await $(".quantiteIllimite").change(); | ||||
|     await $(".prixLot").change(); | ||||
|     this.callback(this.venteData); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -36,6 +36,7 @@ export class DialogSplitItem extends Dialog { | ||||
|   } | ||||
|  | ||||
|   async onSplit(){ | ||||
|     await $(".choix-quantite").change(); | ||||
|     this.callback(this.item, this.splitData.choix.quantite); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -26,8 +26,8 @@ const monnaiesData = [ | ||||
| export class Monnaie { | ||||
|  | ||||
|   static isSystemMonnaie(item) { | ||||
|     let present = monnaiesData.find( monnaie => monnaie.data.valeur_deniers == item.data?.data?.valeur_deniers); | ||||
|     return present != undefined; | ||||
|     let present = monnaiesData.find(monnaie => monnaie.data.valeur_deniers == Misc.data(item)?.data?.valeur_deniers); | ||||
|     return present; | ||||
|   } | ||||
|  | ||||
|   static monnaiesData() { | ||||
| @@ -39,9 +39,12 @@ export class Monnaie { | ||||
|   } | ||||
|  | ||||
|   static monnaiesManquantes(items) { | ||||
|     const valeursPresentes =  Monnaie.filtrerMonnaies(items) | ||||
|       .map(it => Misc.templateData(it).valeur_deniers) | ||||
|     return monnaiesData.filter(monnaie => !valeursPresentes.includes(Misc.templateData(monnaie).valeur_deniers) ); | ||||
|     const valeurs = Monnaie.filtrerMonnaies(items) | ||||
|       .map(it => Misc.templateData(it).valeur_deniers); | ||||
|     const manquantes = monnaiesData.filter(monnaie => !valeurs.find(v => v != Misc.templateData(monnaie).valeur_deniers)); | ||||
|     //const manquantes = monnaiesData.filter(monnaie => !valeurs.find(v => v != Misc.templateData(monnaie).valeur_deniers) ); | ||||
|     //console.log("Valeurs : ", valeurs, manquantes); | ||||
|     return []; //manquantes; | ||||
|   } | ||||
|  | ||||
|   static deValeur(monnaie, v) { | ||||
| @@ -51,4 +54,8 @@ export class Monnaie { | ||||
|   static arrondiDeniers(sols) { | ||||
|     return sols.toFixed(2); | ||||
|   } | ||||
|  | ||||
|   static triValeurDenier() { | ||||
|     return Misc.ascending(item => Misc.data(item).data.valeur_deniers); | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -325,11 +325,26 @@ export class RdDCalendrier extends Application { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   findHeure(heure) { | ||||
|     heure = Grammar.toLowerCaseNoAccent(heure); | ||||
|     let parHeureOuLabel = Object.values(heuresDef).filter(it => (it.heure+1) == heure || Grammar.toLowerCaseNoAccent(it.label) == heure); | ||||
|     if (parHeureOuLabel.length == 1) { | ||||
|       return parHeureOuLabel[0]; | ||||
|     } | ||||
|     let parLabelPartiel = Object.values(heuresDef).filter(it => Grammar.toLowerCaseNoAccent(it.label).includes(heure)); | ||||
|     const matchLength = heure.length; | ||||
|     if(parLabelPartiel.length > 0) { | ||||
|       parLabelPartiel.sort((a,b)=> (a.label.length - matchLength)^2 - (b.label.length- matchLength)^2); | ||||
|       return parLabelPartiel[0]; | ||||
|     } | ||||
|     return undefined; | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   getAjustementAstrologique(heureNaissance, name = 'inconnu') { | ||||
|     let heure = Grammar.toLowerCaseNoAccent(heureNaissance); | ||||
|     if (heure && heuresDef[heure]) { | ||||
|       let hn = heuresDef[heure].heure; | ||||
|   getAjustementAstrologique(heureNaissance, name = undefined) { | ||||
|     let defHeure = this.findHeure(heureNaissance); | ||||
|     if (defHeure) { | ||||
|       let hn = defHeure.heure; | ||||
|       let chiffreAstral = this.getCurrentNombreAstral() ?? 0; | ||||
|       let heureCourante = this.calendrier.heureRdD; | ||||
|       let ecartChance = (hn + chiffreAstral - heureCourante) % 12; | ||||
| @@ -340,9 +355,12 @@ export class RdDCalendrier extends Application { | ||||
|         case 3: case 9: return -2; | ||||
|       } | ||||
|     } | ||||
|     else { | ||||
|     else if (name) { | ||||
|       ui.notifications.warn(name + " n'a pas d'heure de naissance, ou elle est incorrecte : " + heureNaissance); | ||||
|     } | ||||
|     else{ | ||||
|       ui.notifications.warn(heureNaissance+" ne correspond pas à une heure de naissance"); | ||||
|     } | ||||
|     return 0; | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -79,9 +79,11 @@ export class RdDCommands { | ||||
|           <br><strong>/payer 10d</strong> permet d'envoyer un message pour payer 10 deniers` | ||||
|       }); | ||||
|       rddCommands.registerCommand({ | ||||
|         path: ["/astro"], func: (content, msg, params) => RdDUtility.afficherHeuresChanceMalchance(params[0]), | ||||
|         descr: `Affiche les heures de chance et de malchance selon l'heure de naissance donnée en argument. Exemples: | ||||
|           <br><strong>/astro Lyre</strong>` | ||||
|         path: ["/astro"], func: (content, msg, params) => RdDUtility.afficherHeuresChanceMalchance(RdDCommands.toParamString(params)), | ||||
|         descr: `Affiche les heures de chance et de malchance selon l'heure de naissance donnée en argument. Exemples pour l'heure de la Lyre: | ||||
|           <br><strong>/astro 7</strong> | ||||
|           <br><strong>/astro Lyre</strong> | ||||
|           <br><strong>/astro Lyr</strong>` | ||||
|       }); | ||||
|  | ||||
|       rddCommands.registerCommand({ | ||||
| @@ -109,6 +111,10 @@ export class RdDCommands { | ||||
|     this.commandsTable = {}; | ||||
|   } | ||||
|  | ||||
|   static toParamString(params) { | ||||
|     return params.length == 1 ? params[0] : params.reduce((a, b) => `${a} ${b}`, ''); | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   registerCommand(command) { | ||||
|     this._addCommand(this.commandsTable, command.path, '', command); | ||||
|   | ||||
| @@ -222,6 +222,7 @@ export class RdDUtility { | ||||
|     Handlebars.registerHelper('caseTmr-label', coord => TMRUtility.getTMRLabel(coord)); | ||||
|     Handlebars.registerHelper('caseTmr-type', coord => TMRUtility.getTMRType(coord)); | ||||
|     Handlebars.registerHelper('typeTmr-name', coord => TMRUtility.typeTmrName(coord)); | ||||
|     Handlebars.registerHelper('min', (...args) => Math.min(...args.slice(0, -1))); | ||||
|  | ||||
|     Handlebars.registerHelper('sortCompetence', competences => competences.sort((a, b) => { | ||||
|       if (a.name.startsWith("Survie") && b.name.startsWith("Survie")) { | ||||
| @@ -363,6 +364,7 @@ export class RdDUtility { | ||||
|       .concat(formData.nourritureboissons) | ||||
|       .concat(formData.monnaie); | ||||
|     formData.competences = (formData.itemsByType.competence ?? []).concat(formData.itemsByType.competencecreature ?? []); | ||||
|     formData.monnaie.sort(Monnaie.triValeurDenier()); | ||||
|   } | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
| @@ -830,13 +832,18 @@ export class RdDUtility { | ||||
|   /* -------------------------------------------- */ | ||||
|   static afficherHeuresChanceMalchance(heureNaissance) { | ||||
|     if ( game.user.isGM) { | ||||
|       if (heureNaissance) { | ||||
|       let heure = game.system.rdd.calendrier.findHeure(heureNaissance); | ||||
|       if (heureNaissance && heure) { | ||||
|         let ajustement = game.system.rdd.calendrier.getAjustementAstrologique(heureNaissance); | ||||
|         const current = game.system.rdd.calendrier.findHeure(game.system.rdd.calendrier.getCurrentHeure()); | ||||
|         ChatMessage.create({ | ||||
|           content: `A l'heure ${game.system.rdd.calendrier.getCurrentHeure()}, le modificateur de Chance/Malchance pour l'heure de naissance ${heureNaissance} est de : ${ajustement}.`, | ||||
|           content: `A l'heure de <strong>${current.label}</strong>, le modificateur de Chance/Malchance est de <strong>${Misc.toSignedString(ajustement)}</strong> pour l'heure de naissance <strong>${heure.label}</strong>.`, | ||||
|           whisper: ChatMessage.getWhisperRecipients("GM") | ||||
|         }); | ||||
|       } | ||||
|       else if (heureNaissance) { | ||||
|         ui.notifications.warn(heureNaissance+" ne correspond pas à une heure de naissance"); | ||||
|       } | ||||
|       else { | ||||
|         ui.notifications.warn("Pas d'heure de naissance selectionnée"); | ||||
|       } | ||||
|   | ||||
| @@ -32,7 +32,7 @@ export class Conquete extends Draconique { | ||||
|   async _creerConquete(actor, queue) { | ||||
|     let existants = actor.data.items.filter(it => this.isCase(it)).map(it => Misc.data(it).data.coord); | ||||
|     let possibles = TMRUtility.filterTMR(tmr => !TMRUtility.isCaseHumide(tmr) && !existants.includes(tmr.coord)); | ||||
|     let conquete =await RdDDice.rollOneOf(possibles); | ||||
|     let conquete = await RdDDice.rollOneOf(possibles); | ||||
|     await this.createCaseTmr(actor, 'Conquête: ' + conquete.label, conquete, queue.id); | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -13,7 +13,7 @@ export class Rencontre extends Draconique { | ||||
|   async onActorCreateOwned(actor, item) { } | ||||
|  | ||||
|   code() { return 'rencontre' } | ||||
|   tooltip(linkData) { return `${linkData.rencontre.name} de force ${linkData.rencontre.force}` } | ||||
|   tooltip(rencontre) { return `${rencontre.name} de force ${rencontre.force}` } | ||||
|   img() { return 'systems/foundryvtt-reve-de-dragon/icons/heures/hd06.webp' } | ||||
|  | ||||
|   createSprite(pixiTMR) { | ||||
|   | ||||
| @@ -18,4 +18,4 @@ | ||||
| {"_id":"yHvIWLb4TuUAbPGa","name":"Le Groin","permission":{"default":2,"Hp9ImM4o9YRTSdfu":3},"type":"tarot","data":{"concept":"Bêtise, Ignorance, Nullité","aspect":"Négatif","description":""},"folder":"LmM8c5pdDkCsDXka","sort":1750000,"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/tarots/dos-tarot.png","effects":[]} | ||||
| {"_id":"yIIUac5ehspmqDB2","name":"La Déchirure","permission":{"default":2,"Hp9ImM4o9YRTSdfu":3},"type":"tarot","data":{"concept":"Errance, Déroute, Désordre, Séparation","aspect":"Négatif","description":""},"folder":"LmM8c5pdDkCsDXka","sort":1250000,"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/tarots/dos-tarot.png","effects":[]} | ||||
| {"_id":"zP2OF8ZrAYEODxOn","name":"Le Rabot","permission":{"default":2,"Hp9ImM4o9YRTSdfu":3},"type":"tarot","data":{"concept":"Travail, Labeur, Peine, Chagrin","aspect":"Négatif","description":""},"folder":"LmM8c5pdDkCsDXka","sort":1500000,"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/tarots/dos-tarot.png","effects":[]} | ||||
| {"_id":"zSqKPNeQTVjRuni6","name":"Le Soleil","permission":{"default":2,"Hp9ImM4o9YRTSdfu":3},"type":"tarot","data":{"concept":"Clarté, Evidence, Vérité, Franchiuse","aspect":"Positif","description":""},"folder":"LmM8c5pdDkCsDXka","sort":900000,"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/tarots/dos-tarot.png","effects":[]} | ||||
| {"_id":"zSqKPNeQTVjRuni6","name":"Le Soleil","type":"tarot","img":"systems/foundryvtt-reve-de-dragon/icons/tarots/dos-tarot.png","data":{"concept":"Clarté, Evidence, Vérité, Franchise","aspect":"Positif","description":""},"effects":[],"folder":"LmM8c5pdDkCsDXka","sort":900000,"permission":{"default":2,"Hp9ImM4o9YRTSdfu":3},"flags":{}} | ||||
|   | ||||
| @@ -550,10 +550,10 @@ | ||||
|         <ul class="item-list"> | ||||
|           {{#each hautreve.rencontres as |rencontre key|}} | ||||
|           <li class="item flexrow" data-item-id="{{key}}" data-attribute="{{key}}"> | ||||
|             <span class="display-label flex-grow"><a data-item-id="{{key}}">{{rencontre.rencontre.name}} - {{rencontre.coord}}</a></span>  | ||||
|             <span class="flex-shrink">{{caseTmr-label reserve.coord}}</span>  | ||||
|             {{#if rencontre.rencontre.date}} | ||||
|             <span>({{rencontre.rencontre.date}} - {{rencontre.rencontre.heure}})</span>  | ||||
|             <span class="display-label"><a data-item-id="{{key}}">{{rencontre.name}} - {{rencontre.coord}}</a></span>  | ||||
|             <span class="flex-shrink">{{caseTmr-label rencontre.coord}}</span>  | ||||
|             {{#if rencontre.date}} | ||||
|             <span>Le {{rencontre.date}} à {{rencontre.heure}}</span>  | ||||
|             {{/if}} | ||||
|             <div class="item-controls flex-shrink"> | ||||
|               <a class="item-control rencontre-delete" title="Supprimer"><i class="fas fa-trash"></i></a> | ||||
| @@ -567,12 +567,13 @@ | ||||
|           {{#each hautreve.casesTmr as |casetmr key|}} | ||||
|           <li class="item flexrow" data-item-id="{{casetmr._id}}" data-attribute="{{key}}"> | ||||
|             <span class="display-label"><a data-item-id="{{casetmr._id}}">{{casetmr.name}}</a></span>  | ||||
|             <span class="item-controls flex-shrink"> | ||||
|             <div class="item-controls flex-shrink"> | ||||
|               <a class="item-control item-delete" title="Supprimer"><i class="fas fa-trash"></i></a> | ||||
|             </span> | ||||
|             </div> | ||||
|           </li> | ||||
|           {{/each}} | ||||
|         </ul> | ||||
|         <br><br> | ||||
|         {{/if}} | ||||
|       </div> | ||||
|  | ||||
|   | ||||
| @@ -24,9 +24,9 @@ | ||||
|   {{/if}} | ||||
|   {{/if}} | ||||
|  | ||||
|   {{#if (lt item.data.exotisme 0)}} | ||||
|   {{#if (or (lt item.data.qualite 0) (lt item.data.exotisme 0))}} | ||||
|   <p> | ||||
|     Pour surmonter l'exotisme, vous devez effectuer un jet de Volonté/Cuisine à {{numberFormat item.data.exotisme decimals=0 sign=true}}. | ||||
|     Pour surmonter {{#if (lt item.data.qualite 0)}}le mauvais goût{{else}}l'exotisme{{/if}}, vous devez effectuer un jet de Volonté/Cuisine à {{numberFormat (min item.data.exotisme item.data.qualite) decimals=0 sign=true}}. | ||||
|   <br/> | ||||
|     <input class="attribute-value se-forcer" type="checkbox" name="se-forcer" {{#if choix.seForcer}}checked{{/if}}> | ||||
|       <label for="se-forcer">En cas d'échec, voulez-vous vous forcer à manger (et subir un jet de moral en situation malheureuse)?</label> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user