diff --git a/module/actor.js b/module/actor.js index 91abbdc7..fcdf4751 100644 --- a/module/actor.js +++ b/module/actor.js @@ -29,7 +29,7 @@ import { RdDCarac } from "./rdd-carac.js"; import { Monnaie } from "./item-monnaie.js"; import { RdDHerbes } from "./rdd-herbes.js"; import { DialogConsommer } from "./dialog-consommer.js"; -import { RdDItem } from "./item.js"; +import { DialogFabriquerPotion } from "./dialog-fabriquer-potion.js"; /* -------------------------------------------- */ @@ -3308,6 +3308,47 @@ export class RdDActor extends Actor { this.bonusRepos = potionData.data.herbeBonus; } } + /* -------------------------------------------- */ + dialogFabriquerPotion( herbe ) { + DialogFabriquerPotion.create(this, herbe, { + html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-fabriquer-potion-base.html', + }, []); + } + + /* -------------------------------------------- */ + async fabriquerPotion( potionData ) { + let newPotion = { + name: `Potion de ${potionData.data.categorie} (${potionData.name})`, type: 'potion', + img: "systems/foundryvtt-reve-de-dragon/icons/objets/fiole_verre.webp", + data: { quantite: 1, valeur_deniers: 1, encombrement: 0.01, + categorie: potionData.data.categorie, + herbe: potionData.name, + rarete: potionData.data.rarete, + herbebrins: potionData.nbBrins, + description: "" } + } + await this.createEmbeddedDocuments('Item', [newPotion], { renderSheet: true }); + + let newQuantite = potionData.data.quantite - potionData.nbBrins; + let messageData = { + alias: this.name, + categorie: potionData.data.categorie, + herbe: potionData.name, + nbBrinsPotion: potionData.nbBrins, + nbBrinsReste: newQuantite + } + if (newQuantite == 0 ) { + await this.deleteEmbeddedDocuments('Item', [ potionData._id ] ); + } else { + let update = { _id: potionData._id, 'data.quantite': newQuantite}; + const updated = await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity + } + ChatMessage.create({ + whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name), + content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-fabriquer-potion-base.html`, messageData ) + }); + + } /* -------------------------------------------- */ async consommerPotionGenerique( potionData ) { diff --git a/module/dialog-consommer.js b/module/dialog-consommer.js index f49c5d1c..13ea1387 100644 --- a/module/dialog-consommer.js +++ b/module/dialog-consommer.js @@ -63,6 +63,7 @@ export class DialogConsommer extends Dialog { this.consommerData = consommerData; } + /* -------------------------------------------- */ activateListeners(html) { super.activateListeners(html); diff --git a/module/item-sheet.js b/module/item-sheet.js index 90b188e6..00c300ec 100644 --- a/module/item-sheet.js +++ b/module/item-sheet.js @@ -65,6 +65,11 @@ export class RdDItemSheet extends ItemSheet { isSoins: false, isEnchante: false } + if ( this.actor ) { + formData.isOwned = true; + formData.actorId = this.actor.id; + } + formData.categorieCompetences = RdDItemCompetence.getCategorieCompetences(); if ( formData.type == 'tache' || formData.type == 'livre' || formData.type == 'meditation' || formData.type == 'oeuvre') { formData.caracList = duplicate(game.system.model.Actor.personnage.carac); @@ -83,11 +88,9 @@ export class RdDItemSheet extends ItemSheet { this.dateUpdated = undefined; } RdDHerbes.updatePotionData(formData); - } - - if ( this.actor ) { - formData.isOwned = true; - formData.actorId = this.actor.id; + } + if ( formData.isOwned && formData.type == 'herbe' && (formData.data.categorie == 'Soin' || formData.data.categorie == 'Repos') ) { + formData.isIngredientPotionBase = true; } formData.bonusCaseList = RdDItemSort.getBonusCaseList(formData, true); @@ -128,7 +131,12 @@ export class RdDItemSheet extends ItemSheet { let actor = game.actors.get( actorId ); actor.consommerPotion( this.item ); }); - + html.find('.creer-potion-base').click((event) => { + let actorId = event.currentTarget.attributes['data-actor-id'].value; + let actor = game.actors.get( actorId ); + actor.dialogFabriquerPotion( this.item ); + }); + html.find('.alchimie-tache a').click((event) => { let actorId = event.currentTarget.attributes['data-actor-id'].value; let recetteId = event.currentTarget.attributes['data-recette-id'].value; diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 310330c1..a0bd3da4 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -139,6 +139,7 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/enum-categorie-vehicule.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-competence.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-herbesoin-ingredient.html', + 'systems/foundryvtt-reve-de-dragon/templates/enum-categorie-potion.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-initpremierround.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-rarete.html', 'systems/foundryvtt-reve-de-dragon/templates/sort-draconic.html', @@ -188,7 +189,8 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/chat-actor-turn-summary.html', 'systems/foundryvtt-reve-de-dragon/templates/chat-actor-competence-xp.html', 'systems/foundryvtt-reve-de-dragon/templates/chat-actor-carac-xp.html', - 'systems/foundryvtt-reve-de-dragon/templates/chat-potionenchantee-chateaudormant.html' + 'systems/foundryvtt-reve-de-dragon/templates/chat-potionenchantee-chateaudormant.html', + 'systems/foundryvtt-reve-de-dragon/templates/chat-fabriquer-potion-base.html' ]; Handlebars.registerHelper('upperFirst', str => Misc.upperFirst(str ?? 'Null')); @@ -201,6 +203,14 @@ export class RdDUtility { return loadTemplates(templatePaths); } + /* -------------------------------------------- */ + static buildListOptions( min, max ) { + let options = "" + for(let i=min; i<= max; i++) { + options += `` + } + return options; + } /* -------------------------------------------- */ static checkNull(items) { @@ -533,9 +543,6 @@ export class RdDUtility { } } - - - /* -------------------------------------------- */ static async chatListeners(html) { RdDCombat.registerChatCallbacks(html); diff --git a/packs/botanique.db b/packs/botanique.db index 1faf01c2..99a45e7e 100644 --- a/packs/botanique.db +++ b/packs/botanique.db @@ -58,3 +58,4 @@ {"name":"Amandelle","permission":{"default":0,"rYShh2P1DNavdoBD":3},"type":"ingredient","data":{"description":"

Fruit de l’amandelier, un petit arbuste à feuilles très découpées de couleur mauve pâle à violet foncé. L’amandelle est une noix plate et allongée au goût d’amande allié au parfum de violette.

\n

Fréquente.

","niveau":0,"encombrement":0.01,"base":0,"quantite":1,"milieu":"Tous","rarete":"Frequente","categorie":"Cuisine","cout":0},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/botanique/Amandelle.png","effects":[],"_id":"w7jEFHGFrcrKAesQ"} {"name":"Blèmissure","permission":{"default":0,"rYShh2P1DNavdoBD":3},"type":"ingredient","data":{"description":"

Champignon affectant la forme d’une éponge, de couleur gris blême, apparaissant sur les troncs des arbres.

\n

M4 \\ P 1 minute \\ D2 \\ -4 \\ Élixir des Gnomes +14, Huile de Sélikanthe +10.

\n

Fréquente.

","niveau":0,"encombrement":0,"base":0,"quantite":1,"milieu":"Forêts sombres et humides","rarete":"Frequente","categorie":"","cout":0},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/botanique/Bl%C3%A8missure.png","effects":[],"_id":"wNBWvJSd9i1zHspR"} {"name":"Herbe de lune","permission":{"default":0,"rYShh2P1DNavdoBD":3},"type":"herbe","data":{"description":"

Petite herbacée aux feuilles en forme de polygone à 7 côtés, d’un bleu très pâle, presque translucide, ne poussant qu’en haute montagne, à partir de 2000 mètres, et uniquement dans les recoins pouvant être éclairés par la lune.

L’herbe de lune possède un fort pouvoir onirique sur celui qui la consomme\"; en termes de jeu, elle permet de gagner des points de rêve. Elle doit être cueillie de nuit et lorsque la lune l’éclaire, faute de quoi son pouvoir est nul. Sa force dépend de la phase lunaire durant laquelle elle est cueillie.

Une fois séchée, l’herbe de lune peut être fumée dans une pipe ou préparée en décoction. Dans les deux cas, une dose doit être composée de 7 brins. Dès la dose absorbée (bue ou fumée), le consommateur doit jouer un JR r-force, c’est-à-dire un jet de points de rêve ajusté négativement à la force de l’herbe. Si le JR réussit, aucun effet ne se produit\"; s’il échoue, le consommateur gagne immédiatement un nombre de points de rêve égal à la force de l’herbe, puis en échange, marque un nombre identique de points de fatigue. On peut ainsi gagner des points de rêve même si le seuil de rêve est dépassé, mais se souvenir que dépasser le triple de son seuil provoque l’éclatement.

L’herbe de lune est parfois trouvable chez les herboristes, mais n’est pas bon marché. Une dose (7 brins) vaut usuellement un nombre de sols égal à sa force. Une dose de force 6 vaut ainsi 6 sols.
Rare.

","niveau":null,"base":0,"quantite":1,"milieu":"Hautes montagnes","rarete":"Rare","categorie":"","cout":null},"flags":{"core":{"sheetClass":"foundryvtt-reve-de-dragon.RdDItemSheet"}},"img":"systems/foundryvtt-reve-de-dragon/icons/botanique/Herbe%20de%20lune.png","effects":[],"_id":"x4wGXTdmrzaOn8Sh"} +{"name":"Amandelle","type":"ingredient","img":"systems/foundryvtt-reve-de-dragon/icons/botanique/Amandelle.png","data":{"description":"

Fruit de l’amandelier, un petit arbuste à feuilles très découpées de couleur mauve pâle à violet foncé. L’amandelle est une noix plate et allongée au goût d’amande allié au parfum de violette.

\n

Fréquente.

","niveau":0,"encombrement":0.01,"base":0,"quantite":1,"milieu":"Tous","rarete":"Frequente","categorie":"Cuisine","cout":0},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"jtRmvSuwkwMmIMf0":3},"flags":{"core":{"sourceId":"Compendium.foundryvtt-reve-de-dragon.botanique.w7jEFHGFrcrKAesQ"}},"_id":"QN2KLZLNL1JUh2bF"} diff --git a/templates/enum-categorie-ingredient.html b/templates/enum-categorie-ingredient.html index a70476e9..596f15ff 100644 --- a/templates/enum-categorie-ingredient.html +++ b/templates/enum-categorie-ingredient.html @@ -1,10 +1,6 @@ - - - - - - - - - + + + + + diff --git a/templates/item-herbe-sheet.html b/templates/item-herbe-sheet.html index 84cf84a6..8a8049bd 100644 --- a/templates/item-herbe-sheet.html +++ b/templates/item-herbe-sheet.html @@ -3,6 +3,11 @@

+ {{#if isIngredientPotionBase}} +
+ Fabriquer une potion depuis cette plante +
+ {{/if}}
diff --git a/templates/item-ingredient-sheet.html b/templates/item-ingredient-sheet.html index 6429cb9d..601aa2b5 100644 --- a/templates/item-ingredient-sheet.html +++ b/templates/item-ingredient-sheet.html @@ -14,7 +14,7 @@
- +
diff --git a/templates/item-potion-sheet.html b/templates/item-potion-sheet.html index 0a0d78cf..5f4aa541 100644 --- a/templates/item-potion-sheet.html +++ b/templates/item-potion-sheet.html @@ -5,7 +5,7 @@

{{#if isOwned}}
- Consommer cette potion et appliquer ses effets + Consommer cette potion et appliquer ses effets
{{/if}}
@@ -37,7 +37,7 @@