Add loopCountCheck to more loops
This commit is contained in:
parent
5e1a509c96
commit
7a0b49dc0c
|
@ -3,6 +3,7 @@ import { log, LogTypes as LT } from '@Log4Deno';
|
|||
import { SolvedRoll } from 'artigen/artigen.d.ts';
|
||||
import { tokenizeCmd } from 'artigen/cmdTokenizer.ts';
|
||||
|
||||
import { loopCountCheck } from 'artigen/managers/loopManager.ts';
|
||||
import { QueuedRoll } from 'artigen/managers/manager.d.ts';
|
||||
|
||||
import { cmdSplitRegex, escapeCharacters } from 'artigen/utils/escape.ts';
|
||||
|
@ -77,6 +78,8 @@ export const runCmd = (rollRequest: QueuedRoll): SolvedRoll => {
|
|||
|
||||
// Fill out all of the details and results now
|
||||
tempReturnData.forEach((e) => {
|
||||
loopCountCheck();
|
||||
|
||||
loggingEnabled && log(LT.LOG, `Parsing roll ${rollRequest.rollCmd} | Making return text ${JSON.stringify(e)}`);
|
||||
let preFormat = '';
|
||||
let postFormat = '';
|
||||
|
|
|
@ -3,6 +3,8 @@ import { log, LogTypes as LT } from '@Log4Deno';
|
|||
import { RollFormat, RollModifiers } from 'artigen/dice/dice.d.ts';
|
||||
import { executeRoll } from 'artigen/dice/executeRoll.ts';
|
||||
|
||||
import { loopCountCheck } from 'artigen/managers/loopManager.ts';
|
||||
|
||||
import { rollCounter } from 'artigen/utils/counter.ts';
|
||||
import { loggingEnabled } from 'artigen/utils/logFlag.ts';
|
||||
|
||||
|
@ -19,6 +21,8 @@ export const generateFormattedRoll = (rollConf: string, modifiers: RollModifiers
|
|||
|
||||
// Loop thru all parts of the roll to document everything that was done to create the total roll
|
||||
tempRollSet.forEach((e) => {
|
||||
loopCountCheck();
|
||||
|
||||
loggingEnabled && log(LT.LOG, `Formatting roll ${rollConf} | ${JSON.stringify(e)}`);
|
||||
let preFormat = '';
|
||||
let postFormat = '';
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import { CountDetails, RollSet } from 'artigen/dice/dice.d.ts';
|
||||
|
||||
import { loopCountCheck } from 'artigen/managers/loopManager.ts';
|
||||
|
||||
export const rollCounter = (rollSet: RollSet[]): CountDetails => {
|
||||
const countDetails = {
|
||||
total: 0,
|
||||
|
@ -11,6 +13,7 @@ export const rollCounter = (rollSet: RollSet[]): CountDetails => {
|
|||
};
|
||||
|
||||
rollSet.forEach((roll) => {
|
||||
loopCountCheck();
|
||||
countDetails.total++;
|
||||
if (roll.critHit) countDetails.successful++;
|
||||
if (roll.critFail) countDetails.failed++;
|
||||
|
@ -24,14 +27,17 @@ export const rollCounter = (rollSet: RollSet[]): CountDetails => {
|
|||
|
||||
export const reduceCountDetails = (counts: CountDetails[]): CountDetails => {
|
||||
return counts.reduce(
|
||||
(acc, cnt) => ({
|
||||
(acc, cnt) => {
|
||||
loopCountCheck();
|
||||
return {
|
||||
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,
|
||||
|
|
Loading…
Reference in New Issue