add success/fail/matches to count details
This commit is contained in:
parent
d715214c01
commit
3f6162a1a4
|
@ -33,6 +33,9 @@ export const runCmd = (rollRequest: QueuedRoll): SolvedRoll => {
|
||||||
rerolled: 0,
|
rerolled: 0,
|
||||||
dropped: 0,
|
dropped: 0,
|
||||||
exploded: 0,
|
exploded: 0,
|
||||||
|
success: 0,
|
||||||
|
fail: 0,
|
||||||
|
matches: new Map<string, number>(),
|
||||||
},
|
},
|
||||||
rollDistributions: new Map<string, number[]>(),
|
rollDistributions: new Map<string, number[]>(),
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,6 +29,9 @@ export interface CountDetails {
|
||||||
rerolled: number;
|
rerolled: number;
|
||||||
dropped: number;
|
dropped: number;
|
||||||
exploded: number;
|
exploded: number;
|
||||||
|
success: number;
|
||||||
|
fail: number;
|
||||||
|
matches: Map<string, number>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// RollDistribution is used for storing the raw roll distribution
|
// RollDistribution is used for storing the raw roll distribution
|
||||||
|
|
|
@ -3,13 +3,16 @@ import { CountDetails, RollSet } from 'artigen/dice/dice.d.ts';
|
||||||
import { loopCountCheck } from 'artigen/managers/loopManager.ts';
|
import { loopCountCheck } from 'artigen/managers/loopManager.ts';
|
||||||
|
|
||||||
export const rollCounter = (rollSet: RollSet[]): CountDetails => {
|
export const rollCounter = (rollSet: RollSet[]): CountDetails => {
|
||||||
const countDetails = {
|
const countDetails: CountDetails = {
|
||||||
total: 0,
|
total: 0,
|
||||||
successful: 0,
|
successful: 0,
|
||||||
failed: 0,
|
failed: 0,
|
||||||
rerolled: 0,
|
rerolled: 0,
|
||||||
dropped: 0,
|
dropped: 0,
|
||||||
exploded: 0,
|
exploded: 0,
|
||||||
|
success: 0,
|
||||||
|
fail: 0,
|
||||||
|
matches: new Map<string, number>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
rollSet.forEach((roll) => {
|
rollSet.forEach((roll) => {
|
||||||
|
@ -20,6 +23,9 @@ export const rollCounter = (rollSet: RollSet[]): CountDetails => {
|
||||||
if (roll.rerolled) countDetails.rerolled++;
|
if (roll.rerolled) countDetails.rerolled++;
|
||||||
if (roll.dropped) countDetails.dropped++;
|
if (roll.dropped) countDetails.dropped++;
|
||||||
if (roll.exploding) countDetails.exploded++;
|
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;
|
return countDetails;
|
||||||
|
@ -29,6 +35,10 @@ export const reduceCountDetails = (counts: CountDetails[]): CountDetails =>
|
||||||
counts.reduce(
|
counts.reduce(
|
||||||
(acc, cur) => {
|
(acc, cur) => {
|
||||||
loopCountCheck();
|
loopCountCheck();
|
||||||
|
cur.matches.forEach((cnt, label) => {
|
||||||
|
loopCountCheck();
|
||||||
|
acc.matches.set(label, (acc.matches.get(label) ?? 0) + cnt);
|
||||||
|
});
|
||||||
return {
|
return {
|
||||||
total: acc.total + cur.total,
|
total: acc.total + cur.total,
|
||||||
successful: acc.successful + cur.successful,
|
successful: acc.successful + cur.successful,
|
||||||
|
@ -36,6 +46,9 @@ export const reduceCountDetails = (counts: CountDetails[]): CountDetails =>
|
||||||
rerolled: acc.rerolled + cur.rerolled,
|
rerolled: acc.rerolled + cur.rerolled,
|
||||||
dropped: acc.dropped + cur.dropped,
|
dropped: acc.dropped + cur.dropped,
|
||||||
exploded: acc.exploded + cur.exploded,
|
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,
|
rerolled: 0,
|
||||||
dropped: 0,
|
dropped: 0,
|
||||||
exploded: 0,
|
exploded: 0,
|
||||||
|
success: 0,
|
||||||
|
fail: 0,
|
||||||
|
matches: new Map<string, number>(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -62,12 +62,12 @@ export const generateCountDetailsEmbed = (counts: CountDetails): ArtigenEmbedNoA
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Successful Rolls:',
|
name: 'Critically Successful Rolls:',
|
||||||
value: `${counts.successful}`,
|
value: `${counts.successful}`,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Failed Rolls:',
|
name: 'Critically Failed Rolls:',
|
||||||
value: `${counts.failed}`,
|
value: `${counts.failed}`,
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
|
@ -86,6 +86,28 @@ export const generateCountDetailsEmbed = (counts: CountDetails): ArtigenEmbedNoA
|
||||||
value: `${counts.exploded}`,
|
value: `${counts.exploded}`,
|
||||||
inline: true,
|
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 {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue