From 8a7d8a6930d088c86da967219ac11a7deb454b76 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Wed, 7 Apr 2021 22:46:57 +0200 Subject: [PATCH] Sync --- module/rdd-herbes.js | 81 +++++++++++++++++++++++ templates/chat-appliquer-potion-soin.html | 23 +++++++ templates/chat-consommer-potion-soin.html | 12 ++++ templates/enum-herbesoin-ingredient.html | 11 +++ 4 files changed, 127 insertions(+) create mode 100644 module/rdd-herbes.js create mode 100644 templates/chat-appliquer-potion-soin.html create mode 100644 templates/chat-consommer-potion-soin.html create mode 100644 templates/enum-herbesoin-ingredient.html diff --git a/module/rdd-herbes.js b/module/rdd-herbes.js new file mode 100644 index 00000000..df915c7e --- /dev/null +++ b/module/rdd-herbes.js @@ -0,0 +1,81 @@ +/* -------------------------------------------- */ +import { RdDUtility } from "./rdd-utility.js"; +import { Misc } from "./misc.js"; +import { RdDCalendrier } from "./rdd-calendrier.js"; + +/* -------------------------------------------- */ +export class RdDHerbes extends Item { + + /* -------------------------------------------- */ + static isHerbeSoin( botaniqueItem ) { + return Misc.templateData(botaniqueItem).categorie == 'Soin'; + } + /* -------------------------------------------- */ + static isHerbeRepos( botaniqueItem ) { + return Misc.templateData(botaniqueItem).categorie == 'Repos'; + } + + /* -------------------------------------------- */ + static async initializeHerbes( ) { + this.herbesSoins = await RdDUtility.loadCompendium('foundryvtt-reve-de-dragon.botanique', item => this.isHerbeSoin(item)); + this.herbesRepos = await RdDUtility.loadCompendium('foundryvtt-reve-de-dragon.botanique', item => this.isHerbeRepos(item)); + } + + /* -------------------------------------------- */ + static buildHerbesList(listHerbes, max) { + let list = {} + for ( let herbe of listHerbes) { + let herbeData = Misc.templateData(herbe); + let brins = max - herbeData.niveau; + list[herbe.data.name] = `${herbe.data.name} (Bonus: ${herbeData.niveau}, Brins: ${brins})`; + } + list['Autre'] = 'Autre (Bonus: variable, Brins: variable)' + return list; + } + + /* -------------------------------------------- */ + static updatePotionData( formData ) { + formData.herbesSoins = this.buildHerbesList(this.herbesSoins, 12); + formData.herbesRepos = this.buildHerbesList(this.herbesRepos, 7); + formData.jourMoisOptions = Array(28).fill().map((item, index) => 1 + index); + formData.dateActuelle = game.system.rdd.calendrier.getDateFromIndex(); + formData.splitDate = game.system.rdd.calendrier.getNumericDateFromIndex(formData.data.prdate); + + if (formData.data.categorie.includes('Soin') ) { + formData.isHerbe = true; + this.computeHerbeBonus(formData, this.herbesSoins, 12); + } else if (formData.data.categorie.includes('Repos')) { + formData.isRepos = true; + this.computeHerbeBonus(formData, this.herbesRepos, 7); + } + + if (formData.data.categorie.includes('Enchante') ) { + formData.isEnchante = true; + if ( formData.isHerbe) { + formData.pointsGuerison = this.calculePointsGuerison( formData.data ); + } + if ( formData.isRepos) { + formData.caseRepos = formData.data.herbebonus * formData.data.pr; + } + } + } + + /* -------------------------------------------- */ + static calculePointsGuerison( data ){ + return data.herbebonus * data.pr; + } + + /* -------------------------------------------- */ + static computeHerbeBonus( formData, herbesList, max) { + if ( Number(formData.data.herbebrins) ) { + let herbe = herbesList.find(item => item.name.toLowerCase() == formData.data.herbe.toLowerCase() ); + if( herbe ) { + let herbeData = Misc.templateData(herbe); + let brinsBase = max - herbeData.niveau; + //console.log(herbeData, brinsBase, formData.data.herbebrins); + formData.data.herbebonus = Math.max(herbeData.niveau - Math.max(brinsBase - formData.data.herbebrins, 0), 0); + } + } + } + +} \ No newline at end of file diff --git a/templates/chat-appliquer-potion-soin.html b/templates/chat-appliquer-potion-soin.html new file mode 100644 index 00000000..9d4b9e30 --- /dev/null +++ b/templates/chat-appliquer-potion-soin.html @@ -0,0 +1,23 @@ +potion de soin +

+ {{#if enchante}} + + {{else}} + {{#if reussiteReve}} + {{alias}} a bu la potion et a échoué son Jet de Résistance (Rêve actuelà -8) : la potion fait effet ! + {{else}} + {{alias}} a bu la potion et a réussi son Jet de Résistance (Rêve actuelà -8) : la potion ne fait pas effet ! + {{/if}} + {{/if}} +

+
+{{#if reussiteReve}} +
+ {{alias}} perd 1 point de rêve (déduit autmatiquement) et s'endort pour {{guerisonMinutes}} minutes. A son réveil, les blessures suivantes seront guéries : + +
+{{/if}} diff --git a/templates/chat-consommer-potion-soin.html b/templates/chat-consommer-potion-soin.html new file mode 100644 index 00000000..e629529d --- /dev/null +++ b/templates/chat-consommer-potion-soin.html @@ -0,0 +1,12 @@ +potion de soin +

+ {{alias}} consomme sa Potion de Soins {{enchanteTexte}} de {{name}} ({{data.herbe}}, {{data.herbebrins}} brins). +

+
+
+ {{#if pointsGuerison}} + Elle permet de guérir {{pointsGuerison}} Points de Guérison. + {{else}} + Lors de votre prochain jet de récupération à Chateau Dormant, vous bénéficierez d'un bonus de {{data.herbebonus}} (appliqué automatiquement). + {{/if}} +
diff --git a/templates/enum-herbesoin-ingredient.html b/templates/enum-herbesoin-ingredient.html new file mode 100644 index 00000000..304fb4fb --- /dev/null +++ b/templates/enum-herbesoin-ingredient.html @@ -0,0 +1,11 @@ + + + + + + + + + + +