From 23e848fe401e88c0cdb66e088e4afbd0f506c94c Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Mon, 15 Aug 2022 15:12:14 +0200 Subject: [PATCH] Fixed hit dice recovery calculation on long rest --- app/imports/api/creature/creatures/methods/restCreature.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/imports/api/creature/creatures/methods/restCreature.js b/app/imports/api/creature/creatures/methods/restCreature.js index 7af25d1e..49d228aa 100644 --- a/app/imports/api/creature/creatures/methods/restCreature.js +++ b/app/imports/api/creature/creatures/methods/restCreature.js @@ -107,7 +107,7 @@ function doRestWork(restType, actionContext) { fields: { hitDiceSize: 1, damage: 1, - value: 1, + total: 1, } }).fetch(); // Use a collator to do sorting in natural order @@ -118,7 +118,7 @@ function doRestWork(restType, actionContext) { let compare = (a, b) => collator.compare(b.hitDiceSize, a.hitDiceSize) hitDice.sort(compare); // Get the total number of hit dice that can be recovered this rest - let totalHd = hitDice.reduce((sum, hd) => sum + (hd.value || 0), 0); + let totalHd = hitDice.reduce((sum, hd) => sum + (hd.total || 0), 0); let resetMultiplier = actionContext.creature.settings.hitDiceResetMultiplier || 0.5; let recoverableHd = Math.max(Math.floor(totalHd*resetMultiplier), 1); // recover each hit dice in turn until the recoverable amount is used up