add initial value to reduce

This commit is contained in:
Ean Milligan 2025-05-03 16:49:00 -04:00
parent 9d7aed2773
commit 7808093bc7
1 changed files with 18 additions and 8 deletions

View File

@ -117,14 +117,24 @@ export const runCmd = (fullCmd: string, modifiers: RollModifiers): SolvedRoll =>
returnMsg.line3 = line3; returnMsg.line3 = line3;
// Reduce counts to a single object // Reduce counts to a single object
returnMsg.counts = tempCountDetails.reduce((acc, cnt) => ({ returnMsg.counts = tempCountDetails.reduce(
total: acc.total + cnt.total, (acc, cnt) => ({
successful: acc.successful + cnt.successful, total: acc.total + cnt.total,
failed: acc.failed + cnt.failed, successful: acc.successful + cnt.successful,
rerolled: acc.rerolled + cnt.rerolled, failed: acc.failed + cnt.failed,
dropped: acc.dropped + cnt.dropped, rerolled: acc.rerolled + cnt.rerolled,
exploded: acc.exploded + cnt.exploded, dropped: acc.dropped + cnt.dropped,
})); exploded: acc.exploded + cnt.exploded,
}),
{
total: 0,
successful: 0,
failed: 0,
rerolled: 0,
dropped: 0,
exploded: 0,
},
);
} catch (e) { } catch (e) {
// Fill in the return block // Fill in the return block
returnMsg.error = true; returnMsg.error = true;