From a39e2a3256cea071d47ceb47b0e1942f3b10e5da Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sun, 11 Apr 2021 23:03:55 +0200 Subject: [PATCH] Rename herbeData (creer potion d'herbe) --- module/actor.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/module/actor.js b/module/actor.js index 18ba9bb0..22b5f7d9 100644 --- a/module/actor.js +++ b/module/actor.js @@ -3363,33 +3363,34 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ - async fabriquerPotion(potionData) { + async fabriquerPotion(herbeData) { let newPotion = { - name: `Potion de ${potionData.data.categorie} (${potionData.name})`, type: 'potion', + name: `Potion de ${herbeData.data.categorie} (${herbeData.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, + categorie: herbeData.data.categorie, + herbe: herbeData.name, + rarete: herbeData.data.rarete, + herbebrins: herbeData.nbBrins, description: "" } } await this.createEmbeddedDocuments('Item', [newPotion], { renderSheet: true }); - let newQuantite = potionData.data.quantite - potionData.nbBrins; + let newQuantite = herbeData.data.quantite - herbeData.nbBrins; let messageData = { alias: this.name, - categorie: potionData.data.categorie, - herbe: potionData.name, - nbBrinsPotion: potionData.nbBrins, + categorie: herbeData.data.categorie, + herbe: herbeData.name, + nbBrinsPotion: herbeData.nbBrins, nbBrinsReste: newQuantite } + // TODO: if (newQuantite == 0) { - await this.deleteEmbeddedDocuments('Item', [potionData._id]); + await this.deleteEmbeddedDocuments('Item', [herbeData._id]); } else { - let update = { _id: potionData._id, 'data.quantite': newQuantite }; + let update = { _id: herbeData._id, 'data.quantite': newQuantite }; await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity } ChatMessage.create({