From 4762dc33acabf1f2257bd6f96945d4097f6d439f Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Sun, 3 Mar 2024 08:20:30 +0100 Subject: [PATCH] PNJ & Creatures --- modules/mournblade-actor.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/modules/mournblade-actor.js b/modules/mournblade-actor.js index 09936ea..ad06c18 100644 --- a/modules/mournblade-actor.js +++ b/modules/mournblade-actor.js @@ -529,13 +529,17 @@ export class MournbladeActor extends Actor { if (arme.system.nbressources && Number(arme.system.nbressources) > 0) { if (this.type == "creature") { let ressources = duplicate(this.system.ressources) - ressources.value -= arme.system.nbressources - this.update({ 'system.ressources': ressources }) - ChatMessage.create({ - content: "L'utilisation de la capacité/arme a dépensé " + arme.system.nbressources + " ressources.", - whisper: game.user._id, - user: game.user._id - }); + if ( Number(ressources.value) >= Number(arme.system.nbressources)) { + ressources.value -= arme.system.nbressources + this.update({ 'system.ressources': ressources }) + ChatMessage.create({ + content: "L'utilisation de la capacité/arme a dépensé " + arme.system.nbressources + " ressources.", + whisper: game.user._id, + user: game.user._id + }); + } else { + ui.notifications.warn("Points de ressources insuffisants.") + } } else { ui.notifications.warn("Les ressources ne sont pas disponibles pour les personnages.") }