1
1
mirror of https://github.com/Burn-E99/TheArtificer.git synced 2026-06-04 09:03:50 -04:00

[untested] - deno fmt

This commit is contained in:
Ean Milligan
2025-05-01 18:01:23 -04:00
parent 6e1c6e8db3
commit f50dec29c7
20 changed files with 76 additions and 105 deletions

View File

@@ -35,7 +35,7 @@ The results for this roll will replace this message when it is done.`,
setInterval(() => {
log(
LT.LOG,
`Checking rollQueue for items, rollQueue length: ${rollQueue.length}, currentWorkers: ${currentWorkers}, config.limits.maxWorkers: ${config.limits.maxWorkers}`
`Checking rollQueue for items, rollQueue length: ${rollQueue.length}, currentWorkers: ${currentWorkers}, config.limits.maxWorkers: ${config.limits.maxWorkers}`,
);
if (rollQueue.length && currentWorkers < config.limits.maxWorkers) {
const temp = rollQueue.shift();

View File

@@ -35,12 +35,12 @@ export const handleRollWorker = (rq: QueuedRoll) => {
(
await generateRollEmbed(
rq.dd.message.authorId,
<SolvedRoll>{
<SolvedRoll> {
error: true,
errorCode: 'TooComplex',
errorMsg: 'Error: Roll took too long to process, try breaking roll down into simpler parts',
},
<RollModifiers>{}
<RollModifiers> {},
)
).embed,
],
@@ -166,14 +166,14 @@ export const handleRollWorker = (rq: QueuedRoll) => {
JSON.stringify(
rq.modifiers.count
? {
counts: countEmbed,
details: pubEmbedDetails,
}
counts: countEmbed,
details: pubEmbedDetails,
}
: {
details: pubEmbedDetails,
}
)
)
details: pubEmbedDetails,
},
),
),
);
}
}

View File

@@ -12,7 +12,7 @@ import { fullSolver } from 'artigen/solver.ts';
// parseRoll handles converting fullCmd into a computer readable format for processing, and finally executes the solving
export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll => {
const operators = ['(', ')', '^', '*', '/', '%', '+', '-'];
const returnMsg = <SolvedRoll>{
const returnMsg = <SolvedRoll> {
error: false,
errorCode: '',
errorMsg: '',
@@ -54,7 +54,7 @@ export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll
const [tempConf, tempFormat] = sepRoll.split(config.postfix);
// 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: (string | number | SolvedStep)[] = <(string | number | SolvedStep)[]>tempConf.replace(/ /g, '').split(/([-+()*/^]|(?<![d%])%)/g);
const mathConf: (string | number | SolvedStep)[] = <(string | number | SolvedStep)[]> tempConf.replace(/ /g, '').split(/([-+()*/^]|(?<![d%])%)/g);
// Verify there are equal numbers of opening and closing parenthesis by adding 1 for opening parens and subtracting 1 for closing parens
let parenCnt = 0;
@@ -147,7 +147,7 @@ export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll
containsCrit: false,
containsFail: false,
},
]
],
);
i += 2;
} else if (!legalMathOperators.includes(strMathConfI) && legalMathOperators.some((mathOp) => strMathConfI.endsWith(mathOp))) {
@@ -173,10 +173,10 @@ export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll
} else {
// Handle normally, just set current item to negative
if (typeof mathConf[i] === 'number') {
mathConf[i] = <number>mathConf[i] * -1;
mathConf[i] = <number> mathConf[i] * -1;
} else {
(<SolvedStep>mathConf[i]).total = (<SolvedStep>mathConf[i]).total * -1;
(<SolvedStep>mathConf[i]).details = `-${(<SolvedStep>mathConf[i]).details}`;
(<SolvedStep> mathConf[i]).total = (<SolvedStep> mathConf[i]).total * -1;
(<SolvedStep> mathConf[i]).details = `-${(<SolvedStep> mathConf[i]).details}`;
}
mathConf.splice(i - 1, 1);
i--;
@@ -255,10 +255,12 @@ export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll
// Populate line2 (the results) and line3 (the details) with their data
if (modifiers.order === '') {
line2 += `${preFormat}${modifiers.commaTotals ? e.rollTotal.toLocaleString() : e.rollTotal}${postFormat}${escapeCharacters(
e.rollPostFormat,
'|*_~`'
)} `;
line2 += `${preFormat}${modifiers.commaTotals ? e.rollTotal.toLocaleString() : e.rollTotal}${postFormat}${
escapeCharacters(
e.rollPostFormat,
'|*_~`',
)
} `;
} else {
// If order is on, turn rolls into csv without formatting
line2 += `${preFormat}${modifiers.commaTotals ? e.rollTotal.toLocaleString() : e.rollTotal}${postFormat}, `;

View File

@@ -36,7 +36,7 @@ export const genFateRoll = (modifiers: RollModifiers): number => {
return 0;
} else {
const sides = [-1, -1, 0, 0, 1, 1];
return sides[genRoll(6, modifiers, <DPercentConf>{ on: false }) - 1];
return sides[genRoll(6, modifiers, <DPercentConf> { on: false }) - 1];
}
};

View File

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

View File

@@ -186,10 +186,10 @@ export const fullSolver = (conf: (string | number | SolvedStep)[], wrapDetails:
stepSolve.details = conf[0].toString();
} else {
// Else fully populate the stepSolve with what was computed
stepSolve.total = (<SolvedStep>conf[0]).total;
stepSolve.details = (<SolvedStep>conf[0]).details;
stepSolve.containsCrit = (<SolvedStep>conf[0]).containsCrit;
stepSolve.containsFail = (<SolvedStep>conf[0]).containsFail;
stepSolve.total = (<SolvedStep> conf[0]).total;
stepSolve.details = (<SolvedStep> conf[0]).details;
stepSolve.containsCrit = (<SolvedStep> conf[0]).containsCrit;
stepSolve.containsFail = (<SolvedStep> conf[0]).containsFail;
}
// If this was a nested call, add on parens around the details to show what math we've done