From 5383804af73a7e562f4e80ee20df85d495101db2 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Wed, 23 Feb 2022 16:17:34 +0200 Subject: [PATCH] Fixed error with damage failing to apply if existing damage was undefined --- .../creature/creatureProperties/methods/damageProperty.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/imports/api/creature/creatureProperties/methods/damageProperty.js b/app/imports/api/creature/creatureProperties/methods/damageProperty.js index b05823a9..573e004a 100644 --- a/app/imports/api/creature/creatureProperties/methods/damageProperty.js +++ b/app/imports/api/creature/creatureProperties/methods/damageProperty.js @@ -47,7 +47,7 @@ const damageProperty = new ValidatedMethod({ export function damagePropertyWork({property, operation, value}){ let damage, newValue; if (operation === 'set'){ - const total = property.total; + const total = property.total || 0; // Set represents what we want the value to be after damage // So we need the actual damage to get to that value damage = total - value; @@ -57,8 +57,8 @@ export function damagePropertyWork({property, operation, value}){ if (damage < 0) damage = 0; newValue = property.total - damage; } else if (operation === 'increment'){ - let currentValue = property.value; - let currentDamage = property.damage; + let currentValue = property.value || 0; + let currentDamage = property.damage || 0; let increment = value; // Can't increase damage above the remaining value if (increment > currentValue) increment = currentValue;