diff --git a/src/artigen/artigen.ts b/src/artigen/artigen.ts index d68c1e8..5dc2c1c 100644 --- a/src/artigen/artigen.ts +++ b/src/artigen/artigen.ts @@ -33,6 +33,9 @@ export const runCmd = (rollRequest: QueuedRoll): SolvedRoll => { rerolled: 0, dropped: 0, exploded: 0, + success: 0, + fail: 0, + matches: new Map(), }, rollDistributions: new Map(), }; diff --git a/src/artigen/dice/dice.d.ts b/src/artigen/dice/dice.d.ts index 6983752..6ebe944 100644 --- a/src/artigen/dice/dice.d.ts +++ b/src/artigen/dice/dice.d.ts @@ -29,6 +29,9 @@ export interface CountDetails { rerolled: number; dropped: number; exploded: number; + success: number; + fail: number; + matches: Map; } // RollDistribution is used for storing the raw roll distribution diff --git a/src/artigen/utils/counter.ts b/src/artigen/utils/counter.ts index 55593ca..06f3b65 100644 --- a/src/artigen/utils/counter.ts +++ b/src/artigen/utils/counter.ts @@ -3,13 +3,16 @@ import { CountDetails, RollSet } from 'artigen/dice/dice.d.ts'; import { loopCountCheck } from 'artigen/managers/loopManager.ts'; export const rollCounter = (rollSet: RollSet[]): CountDetails => { - const countDetails = { + const countDetails: CountDetails = { total: 0, successful: 0, failed: 0, rerolled: 0, dropped: 0, exploded: 0, + success: 0, + fail: 0, + matches: new Map(), }; rollSet.forEach((roll) => { @@ -20,6 +23,9 @@ export const rollCounter = (rollSet: RollSet[]): CountDetails => { if (roll.rerolled) countDetails.rerolled++; if (roll.dropped) countDetails.dropped++; if (roll.exploding) countDetails.exploded++; + if (roll.success) countDetails.success++; + if (roll.fail) countDetails.fail++; + if (roll.matchLabel) countDetails.matches.set(roll.matchLabel, (countDetails.matches.get(roll.matchLabel) ?? 0) + 1); }); return countDetails; @@ -29,6 +35,10 @@ export const reduceCountDetails = (counts: CountDetails[]): CountDetails => counts.reduce( (acc, cur) => { loopCountCheck(); + cur.matches.forEach((cnt, label) => { + loopCountCheck(); + acc.matches.set(label, (acc.matches.get(label) ?? 0) + cnt); + }); return { total: acc.total + cur.total, successful: acc.successful + cur.successful, @@ -36,6 +46,9 @@ export const reduceCountDetails = (counts: CountDetails[]): CountDetails => rerolled: acc.rerolled + cur.rerolled, dropped: acc.dropped + cur.dropped, exploded: acc.exploded + cur.exploded, + success: acc.success + cur.success, + fail: acc.fail + cur.fail, + matches: acc.matches, }; }, { @@ -45,5 +58,8 @@ export const reduceCountDetails = (counts: CountDetails[]): CountDetails => rerolled: 0, dropped: 0, exploded: 0, + success: 0, + fail: 0, + matches: new Map(), }, ); diff --git a/src/artigen/utils/embeds.ts b/src/artigen/utils/embeds.ts index 1a89553..ea37d74 100644 --- a/src/artigen/utils/embeds.ts +++ b/src/artigen/utils/embeds.ts @@ -62,12 +62,12 @@ export const generateCountDetailsEmbed = (counts: CountDetails): ArtigenEmbedNoA inline: true, }, { - name: 'Successful Rolls:', + name: 'Critically Successful Rolls:', value: `${counts.successful}`, inline: true, }, { - name: 'Failed Rolls:', + name: 'Critically Failed Rolls:', value: `${counts.failed}`, inline: true, }, @@ -86,6 +86,28 @@ export const generateCountDetailsEmbed = (counts: CountDetails): ArtigenEmbedNoA value: `${counts.exploded}`, inline: true, }, + { + name: 'Successful Rolls:', + value: `${counts.success}`, + inline: true, + }, + { + name: 'Failed Rolls:', + value: `${counts.fail}`, + inline: true, + }, + { + name: 'Matched Roll Labels:', + value: `${ + counts.matches + .entries() + .toArray() + .sort() + .map(([label, count]) => `${label}: ${count}`) + .join(', ') + }`, + inline: true, + }, ]; return {