typing cleanup

This commit is contained in:
Ean Milligan 2025-05-03 08:12:05 -04:00
parent 9582d91ac1
commit 8befcc1ca1
5 changed files with 13 additions and 12 deletions

View File

@ -19,7 +19,7 @@ export const tokenizeMath = (cmd: string, modifiers: RollModifiers): [ReturnData
loggingEnabled && log(LT.LOG, `Parsing roll ${cmd}`); loggingEnabled && log(LT.LOG, `Parsing roll ${cmd}`);
// Remove all spaces from the operation config and split it by any operator (keeping the operator in mathConf for fullSolver to do math on) // Remove all spaces from the operation config and split it by any operator (keeping the operator in mathConf for fullSolver to do math on)
const mathConf: MathConf[] = <MathConf[]> cmd const mathConf: MathConf[] = cmd
.replace(cmdSplitRegex, '') .replace(cmdSplitRegex, '')
.replace(internalWrapRegex, '') .replace(internalWrapRegex, '')
.replace(/ /g, '') .replace(/ /g, '')

View File

@ -14,7 +14,7 @@ import { assertPrePostBalance } from 'src/artigen/utils/parenBalance.ts';
// parseRoll(fullCmd, modifiers) // parseRoll(fullCmd, modifiers)
// parseRoll handles converting fullCmd into a computer readable format for processing, and finally executes the solving // parseRoll handles converting fullCmd into a computer readable format for processing, and finally executes the solving
export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll => { export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll => {
const returnMsg = <SolvedRoll> { const returnMsg: SolvedRoll = {
error: false, error: false,
errorCode: '', errorCode: '',
errorMsg: '', errorMsg: '',

View File

@ -69,22 +69,22 @@ export const roll = (rollStr: string, modifiers: RollModifiers): RollSet[] => {
reroll: { reroll: {
on: false, on: false,
once: false, once: false,
nums: <number[]> [], nums: [],
}, },
critScore: { critScore: {
on: false, on: false,
range: <number[]> [], range: [],
}, },
critFail: { critFail: {
on: false, on: false,
range: <number[]> [], range: [],
}, },
exploding: { exploding: {
on: false, on: false,
once: false, once: false,
compounding: false, compounding: false,
penetrating: false, penetrating: false,
nums: <number[]> [], nums: [],
}, },
}; };

View File

@ -16,7 +16,7 @@ import { getMatchingParenIdx } from 'artigen/utils/parenBalance.ts';
export const fullSolver = (conf: MathConf[], wrapDetails = false): SolvedStep => { export const fullSolver = (conf: MathConf[], wrapDetails = false): SolvedStep => {
// Initialize PEMDAS // Initialize PEMDAS
const signs = ['^', '*', '/', '%', '+', '-']; const signs = ['^', '*', '/', '%', '+', '-'];
const stepSolve = { const stepSolve: SolvedStep = {
total: 0, total: 0,
details: '', details: '',
containsCrit: false, containsCrit: false,
@ -166,10 +166,11 @@ export const fullSolver = (conf: MathConf[], wrapDetails = false): SolvedStep =>
stepSolve.details = conf[0].toString(); stepSolve.details = conf[0].toString();
} else { } else {
// Else fully populate the stepSolve with what was computed // Else fully populate the stepSolve with what was computed
stepSolve.total = (<SolvedStep> conf[0]).total; const tempConf = <SolvedStep> conf[0];
stepSolve.details = (<SolvedStep> conf[0]).details; stepSolve.total = tempConf.total;
stepSolve.containsCrit = (<SolvedStep> conf[0]).containsCrit; stepSolve.details = tempConf.details;
stepSolve.containsFail = (<SolvedStep> conf[0]).containsFail; stepSolve.containsCrit = tempConf.containsCrit;
stepSolve.containsFail = tempConf.containsFail;
} }
// If this was a nested call, add on parens around the details to show what math we've done // If this was a nested call, add on parens around the details to show what math we've done

2
src/mod.d.ts vendored
View File

@ -1,7 +1,7 @@
// EmojiConf is used as a structure for the emojis stored in config.ts // EmojiConf is used as a structure for the emojis stored in config.ts
export type EmojiConf = { export type EmojiConf = {
name: string; name: string;
aliases: Array<string>; aliases: string[];
id: string; id: string;
animated: boolean; animated: boolean;
deleteSender: boolean; deleteSender: boolean;