From cc244719261bd15a0a45c420a32d7d01fb59ca82 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Fri, 9 Apr 2021 17:30:32 +0200 Subject: [PATCH] #171 - Gestion potions / consommation --- module/actor.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/module/actor.js b/module/actor.js index 34ad3486..681a3123 100644 --- a/module/actor.js +++ b/module/actor.js @@ -3309,6 +3309,23 @@ export class RdDActor extends Actor { } } + /* -------------------------------------------- */ + consommerPotionGenerique( potionData ) { + potionData.alias = this.name; + + if (potionData.data.categorie.includes('Enchante')) { + potionData.enchanteTexte = "enchantée"; + potionData.isEnchante = true; + } else { + potionData.enchanteTexte = ""; + potionData.isEnchante = false; + } + ChatMessage.create({ + whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name), + content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-consommer-potion-generique.html`, potionData ) + }); +} + /* -------------------------------------------- */ async consommerPotion( potion ) { const potionData = Misc.data(potion); @@ -3318,9 +3335,9 @@ export class RdDActor extends Actor { } else if( potionData.data.categorie.includes('Repos')) { this.consommerPotionRepos(potionData); } else { - //TODO + this.consommerPotionGenerique(potionData); } - await this.deleteEmbeddedDocuments('Item', [ potion._id ] ); + await this.deleteEmbeddedDocuments('Item', [ potion.id ] ); } /* -------------------------------------------- */