some renames

This commit is contained in:
Ean Milligan 2025-05-03 08:21:11 -04:00
parent 8befcc1ca1
commit 07e76733ec
4 changed files with 14 additions and 14 deletions

View File

@ -24,7 +24,7 @@ const throwDoubleSepError = (sep: string): void => {
// roll(rollStr, modifiers) returns RollSet // roll(rollStr, modifiers) returns RollSet
// roll parses and executes the rollStr // roll parses and executes the rollStr
export const roll = (rollStr: string, modifiers: RollModifiers): RollSet[] => { export const executeRoll = (rollStr: string, modifiers: RollModifiers): RollSet[] => {
/* Roll Capabilities /* Roll Capabilities
* Deciphers and rolls a single dice roll set * Deciphers and rolls a single dice roll set
* *

View File

@ -2,21 +2,21 @@ import { log, LogTypes as LT } from '@Log4Deno';
import { rollCounter } from './utils/counter.ts'; import { rollCounter } from './utils/counter.ts';
import { RollModifiers } from 'src/mod.d.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 { RollFormat } from 'artigen/solver.d.ts';
import { loggingEnabled } from 'artigen/utils/logFlag.ts'; import { loggingEnabled } from 'artigen/utils/logFlag.ts';
// formatRoll(rollConf, modifiers) returns one SolvedStep // generateSolvedRoll(rollConf, modifiers) returns one SolvedStep
// formatRoll handles creating and formatting the completed rolls into the SolvedStep format // generateSolvedRoll handles creating and formatting the completed rolls into the SolvedStep format
export const formatRoll = (rollConf: string, modifiers: RollModifiers): RollFormat => { export const generateSolvedRoll = (rollConf: string, modifiers: RollModifiers): RollFormat => {
let tempTotal = 0; let tempTotal = 0;
let tempDetails = '['; let tempDetails = '[';
let tempCrit = false; let tempCrit = false;
let tempFail = false; let tempFail = false;
// Generate the roll, passing flags thru // 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 // Loop thru all parts of the roll to document everything that was done to create the total roll
tempRollSet.forEach((e) => { tempRollSet.forEach((e) => {

View File

@ -11,9 +11,9 @@ import { legalMath, legalMathOperators } from 'artigen/utils/legalMath.ts';
import { loggingEnabled } from 'artigen/utils/logFlag.ts'; import { loggingEnabled } from 'artigen/utils/logFlag.ts';
import { getMatchingParenIdx } from 'artigen/utils/parenBalance.ts'; import { getMatchingParenIdx } from 'artigen/utils/parenBalance.ts';
// fullSolver(conf, wrapDetails) returns one condensed SolvedStep // mathSolver(conf, wrapDetails) returns one condensed SolvedStep
// fullSolver is a function that recursively solves the full roll and math // mathSolver is a function that recursively solves the full roll and math
export const fullSolver = (conf: MathConf[], wrapDetails = false): SolvedStep => { export const mathSolver = (conf: MathConf[], wrapDetails = false): SolvedStep => {
// Initialize PEMDAS // Initialize PEMDAS
const signs = ['^', '*', '/', '%', '+', '-']; const signs = ['^', '*', '/', '%', '+', '-'];
const stepSolve: SolvedStep = { const stepSolve: SolvedStep = {
@ -37,7 +37,7 @@ export const fullSolver = (conf: MathConf[], wrapDetails = false): SolvedStep =>
const closeParenIdx = getMatchingParenIdx(conf, openParenIdx); const closeParenIdx = getMatchingParenIdx(conf, openParenIdx);
// Call the solver on the items between openParenIdx and closeParenIdx (excluding the parens) // 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 // Replace the items between openParenIdx and closeParenIdx (including the parens) with its solved equivalent
conf.splice(openParenIdx, closeParenIdx - openParenIdx + 1, parenSolve); conf.splice(openParenIdx, closeParenIdx - openParenIdx + 1, parenSolve);

View File

@ -1,7 +1,7 @@
import { log, LogTypes as LT } from '@Log4Deno'; import { log, LogTypes as LT } from '@Log4Deno';
import { formatRoll } from 'artigen/rollFormatter.ts'; import { generateSolvedRoll } from 'artigen/generateSolvedRoll.ts';
import { fullSolver } from 'artigen/solver.ts'; import { mathSolver } from 'artigen/mathSolver.ts';
import { CountDetails, MathConf, ReturnData, SolvedStep } from 'artigen/solver.d.ts'; import { CountDetails, MathConf, ReturnData, SolvedStep } from 'artigen/solver.d.ts';
import { cmdSplitRegex, internalWrapRegex } from 'artigen/utils/escape.ts'; import { cmdSplitRegex, internalWrapRegex } from 'artigen/utils/escape.ts';
@ -112,7 +112,7 @@ export const tokenizeMath = (cmd: string, modifiers: RollModifiers): [ReturnData
i += 2; i += 2;
} else if (![...operators, ...legalMathOperators].includes(strMathConfI)) { } else if (![...operators, ...legalMathOperators].includes(strMathConfI)) {
// If nothing else has handled it by now, try it as a roll // 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; mathConf[i] = formattedRoll.solvedStep;
countDetails.push(formattedRoll.countDetails); 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 // 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 // Push all of this step's solved data into the temp array
return [ return [