From 7808093bc7a6690d6b372a057ddb2020264471e1 Mon Sep 17 00:00:00 2001 From: Ean Milligan Date: Sat, 3 May 2025 16:49:00 -0400 Subject: [PATCH] add initial value to reduce --- src/artigen/artigen.ts | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/artigen/artigen.ts b/src/artigen/artigen.ts index b7a6f20..52e33f2 100644 --- a/src/artigen/artigen.ts +++ b/src/artigen/artigen.ts @@ -117,14 +117,24 @@ export const runCmd = (fullCmd: string, modifiers: RollModifiers): SolvedRoll => returnMsg.line3 = line3; // Reduce counts to a single object - returnMsg.counts = tempCountDetails.reduce((acc, cnt) => ({ - total: acc.total + cnt.total, - successful: acc.successful + cnt.successful, - failed: acc.failed + cnt.failed, - rerolled: acc.rerolled + cnt.rerolled, - dropped: acc.dropped + cnt.dropped, - exploded: acc.exploded + cnt.exploded, - })); + returnMsg.counts = tempCountDetails.reduce( + (acc, cnt) => ({ + total: acc.total + cnt.total, + successful: acc.successful + cnt.successful, + failed: acc.failed + cnt.failed, + rerolled: acc.rerolled + cnt.rerolled, + dropped: acc.dropped + cnt.dropped, + exploded: acc.exploded + cnt.exploded, + }), + { + total: 0, + successful: 0, + failed: 0, + rerolled: 0, + dropped: 0, + exploded: 0, + }, + ); } catch (e) { // Fill in the return block returnMsg.error = true;