From 07e76733ec6ee20b9f4a6c79996cbc9151ccd3ea Mon Sep 17 00:00:00 2001 From: Ean Milligan Date: Sat, 3 May 2025 08:21:11 -0400 Subject: [PATCH] some renames --- src/artigen/{roller.ts => executeRoll.ts} | 2 +- .../{rollFormatter.ts => generateSolvedRoll.ts} | 10 +++++----- src/artigen/{solver.ts => mathSolver.ts} | 8 ++++---- src/artigen/mathTokenizer.ts | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) rename src/artigen/{roller.ts => executeRoll.ts} (99%) rename src/artigen/{rollFormatter.ts => generateSolvedRoll.ts} (86%) rename src/artigen/{solver.ts => mathSolver.ts} (96%) diff --git a/src/artigen/roller.ts b/src/artigen/executeRoll.ts similarity index 99% rename from src/artigen/roller.ts rename to src/artigen/executeRoll.ts index 51433a5..04d04ae 100644 --- a/src/artigen/roller.ts +++ b/src/artigen/executeRoll.ts @@ -24,7 +24,7 @@ const throwDoubleSepError = (sep: string): void => { // roll(rollStr, modifiers) returns RollSet // roll parses and executes the rollStr -export const roll = (rollStr: string, modifiers: RollModifiers): RollSet[] => { +export const executeRoll = (rollStr: string, modifiers: RollModifiers): RollSet[] => { /* Roll Capabilities * Deciphers and rolls a single dice roll set * diff --git a/src/artigen/rollFormatter.ts b/src/artigen/generateSolvedRoll.ts similarity index 86% rename from src/artigen/rollFormatter.ts rename to src/artigen/generateSolvedRoll.ts index 0008373..793bb13 100644 --- a/src/artigen/rollFormatter.ts +++ b/src/artigen/generateSolvedRoll.ts @@ -2,21 +2,21 @@ import { log, LogTypes as LT } from '@Log4Deno'; import { rollCounter } from './utils/counter.ts'; import { RollModifiers } from 'src/mod.d.ts'; -import { roll } from 'artigen/roller.ts'; +import { executeRoll } from 'artigen/executeRoll.ts'; import { RollFormat } from 'artigen/solver.d.ts'; import { loggingEnabled } from 'artigen/utils/logFlag.ts'; -// formatRoll(rollConf, modifiers) returns one SolvedStep -// formatRoll handles creating and formatting the completed rolls into the SolvedStep format -export const formatRoll = (rollConf: string, modifiers: RollModifiers): RollFormat => { +// generateSolvedRoll(rollConf, modifiers) returns one SolvedStep +// generateSolvedRoll handles creating and formatting the completed rolls into the SolvedStep format +export const generateSolvedRoll = (rollConf: string, modifiers: RollModifiers): RollFormat => { let tempTotal = 0; let tempDetails = '['; let tempCrit = false; let tempFail = false; // Generate the roll, passing flags thru - const tempRollSet = roll(rollConf, modifiers); + const tempRollSet = executeRoll(rollConf, modifiers); // Loop thru all parts of the roll to document everything that was done to create the total roll tempRollSet.forEach((e) => { diff --git a/src/artigen/solver.ts b/src/artigen/mathSolver.ts similarity index 96% rename from src/artigen/solver.ts rename to src/artigen/mathSolver.ts index 1e70af4..3654ad2 100644 --- a/src/artigen/solver.ts +++ b/src/artigen/mathSolver.ts @@ -11,9 +11,9 @@ import { legalMath, legalMathOperators } from 'artigen/utils/legalMath.ts'; import { loggingEnabled } from 'artigen/utils/logFlag.ts'; import { getMatchingParenIdx } from 'artigen/utils/parenBalance.ts'; -// fullSolver(conf, wrapDetails) returns one condensed SolvedStep -// fullSolver is a function that recursively solves the full roll and math -export const fullSolver = (conf: MathConf[], wrapDetails = false): SolvedStep => { +// mathSolver(conf, wrapDetails) returns one condensed SolvedStep +// mathSolver is a function that recursively solves the full roll and math +export const mathSolver = (conf: MathConf[], wrapDetails = false): SolvedStep => { // Initialize PEMDAS const signs = ['^', '*', '/', '%', '+', '-']; const stepSolve: SolvedStep = { @@ -37,7 +37,7 @@ export const fullSolver = (conf: MathConf[], wrapDetails = false): SolvedStep => const closeParenIdx = getMatchingParenIdx(conf, openParenIdx); // Call the solver on the items between openParenIdx and closeParenIdx (excluding the parens) - const parenSolve = fullSolver(conf.slice(openParenIdx + 1, closeParenIdx), true); + const parenSolve = mathSolver(conf.slice(openParenIdx + 1, closeParenIdx), true); // Replace the items between openParenIdx and closeParenIdx (including the parens) with its solved equivalent conf.splice(openParenIdx, closeParenIdx - openParenIdx + 1, parenSolve); diff --git a/src/artigen/mathTokenizer.ts b/src/artigen/mathTokenizer.ts index cb38c55..31fbad6 100644 --- a/src/artigen/mathTokenizer.ts +++ b/src/artigen/mathTokenizer.ts @@ -1,7 +1,7 @@ import { log, LogTypes as LT } from '@Log4Deno'; -import { formatRoll } from 'artigen/rollFormatter.ts'; -import { fullSolver } from 'artigen/solver.ts'; +import { generateSolvedRoll } from 'artigen/generateSolvedRoll.ts'; +import { mathSolver } from 'artigen/mathSolver.ts'; import { CountDetails, MathConf, ReturnData, SolvedStep } from 'artigen/solver.d.ts'; import { cmdSplitRegex, internalWrapRegex } from 'artigen/utils/escape.ts'; @@ -112,7 +112,7 @@ export const tokenizeMath = (cmd: string, modifiers: RollModifiers): [ReturnData i += 2; } else if (![...operators, ...legalMathOperators].includes(strMathConfI)) { // If nothing else has handled it by now, try it as a roll - const formattedRoll = formatRoll(strMathConfI, modifiers); + const formattedRoll = generateSolvedRoll(strMathConfI, modifiers); mathConf[i] = formattedRoll.solvedStep; countDetails.push(formattedRoll.countDetails); } @@ -138,7 +138,7 @@ export const tokenizeMath = (cmd: string, modifiers: RollModifiers): [ReturnData } // Now that mathConf is parsed, send it into the solver - const tempSolved = fullSolver(mathConf); + const tempSolved = mathSolver(mathConf); // Push all of this step's solved data into the temp array return [