From 48dc63750dc6046be1fbd6db8b3fcbc7e074a5c2 Mon Sep 17 00:00:00 2001 From: Jeremy Valentine <38669521+valentine195@users.noreply.github.com> Date: Thu, 11 Jan 2024 20:14:55 -0500 Subject: [PATCH] fix: ignore null player levels when finding daily budget --- src/utils/rpg-system/dnd5e.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/utils/rpg-system/dnd5e.ts b/src/utils/rpg-system/dnd5e.ts index 5d13c5e2..6669c6f7 100644 --- a/src/utils/rpg-system/dnd5e.ts +++ b/src/utils/rpg-system/dnd5e.ts @@ -190,13 +190,16 @@ ${thresholdSummary}`; return [ { displayName: "Daily Budget", - minValue: playerLevels.reduce( - (acc, lv) => - acc + - XP_THRESHOLDS_PER_LEVEL[Math.max(1, Math.min(lv, 20))] - .daily, - 0 - ) + minValue: playerLevels + .filter((l) => l && l > 0) + .reduce( + (acc, lv) => + acc + + XP_THRESHOLDS_PER_LEVEL[ + Math.max(1, Math.min(lv, 20)) + ].daily, + 0 + ) } ]; }