diff --git a/src/artigen/artigen.ts b/src/artigen/artigen.ts index 65aafab..e610f00 100644 --- a/src/artigen/artigen.ts +++ b/src/artigen/artigen.ts @@ -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 = ''; diff --git a/src/artigen/dice/generateFormattedRoll.ts b/src/artigen/dice/generateFormattedRoll.ts index eb6b52d..a5f02a7 100644 --- a/src/artigen/dice/generateFormattedRoll.ts +++ b/src/artigen/dice/generateFormattedRoll.ts @@ -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 = ''; diff --git a/src/artigen/utils/counter.ts b/src/artigen/utils/counter.ts index c09b13e..cff069f 100644 --- a/src/artigen/utils/counter.ts +++ b/src/artigen/utils/counter.ts @@ -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) => ({ - 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, - }), + (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,