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

add -ns decorator

This commit is contained in:
Ean Milligan
2025-07-13 06:04:50 -04:00
parent 3b3ce821bd
commit d386561855
7 changed files with 27 additions and 4 deletions

View File

@@ -96,6 +96,7 @@ export const runCmd = (rollRequest: QueuedRoll): SolvedRoll => {
"One or more of the rolls requested appear to be more complex than what the Nominal calculator is intended for. For a better approximation of this roll's nominal value, please rerun this roll with the `-sn` flag.\n";
}
const line2Space = rollRequest.modifiers.noSpaces ? '' : ' ';
// Fill out all of the details and results now
tempReturnData.forEach((e, i) => {
loopCountCheck();
@@ -118,9 +119,9 @@ export const runCmd = (rollRequest: QueuedRoll): SolvedRoll => {
// Populate line2 (the results) and line3 (the details) with their data
if (rollRequest.modifiers.order === '') {
line2 += `${e.rollPreFormat ? escapeCharacters(e.rollPreFormat, '|*_~`') : ' '}${preFormat}${rollRequest.modifiers.commaTotals ? e.rollTotal.toLocaleString() : e.rollTotal}${postFormat}${
e.rollPostFormat ? escapeCharacters(e.rollPostFormat, '|*_~`') : ''
}`;
line2 += `${e.rollPreFormat ? escapeCharacters(e.rollPreFormat, '|*_~`') : line2Space}${preFormat}${
rollRequest.modifiers.commaTotals ? e.rollTotal.toLocaleString() : e.rollTotal
}${postFormat}${e.rollPostFormat ? escapeCharacters(e.rollPostFormat, '|*_~`') : ''}`;
} else {
// If order is on, turn rolls into csv without formatting
line2 += `${preFormat}${rollRequest.modifiers.commaTotals ? e.rollTotal.toLocaleString() : e.rollTotal}${postFormat}, `;

View File

@@ -63,6 +63,7 @@ export interface RollModifiers {
rollDist: boolean;
numberVariables: boolean;
customDiceShapes: CustomDiceShapes;
noSpaces: boolean;
yVars: Map<string, number>;
apiWarn: string;
valid: boolean;

View File

@@ -24,6 +24,7 @@ export const Modifiers = Object.freeze({
NumberVariables: '-nv',
VariablesNumber: '-vn',
CustomDiceShapes: '-cd',
NoSpaces: '-ns',
});
// args will look like this: ['-sn', ' ', '10'] as spaces/newlines are split on their own
@@ -46,6 +47,7 @@ export const getModifiers = (args: string[]): [RollModifiers, string[]] => {
rollDist: false,
numberVariables: false,
customDiceShapes: new Map<string, number[]>(),
noSpaces: false,
yVars: new Map<string, number>(),
apiWarn: '',
valid: true,
@@ -199,6 +201,9 @@ export const getModifiers = (args: string[]): [RollModifiers, string[]] => {
log(LT.LOG, `Generated Custom Dice: ${JSON.stringify(modifiers.customDiceShapes.entries().toArray())}`);
break;
}
case Modifiers.NoSpaces:
modifiers.noSpaces = true;
break;
default:
// Default case should not mess with the array
defaultCase = true;

View File

@@ -194,6 +194,19 @@ If multiple custom dice are needed, separate their configurations with a \`;\`.
],
},
],
[
'-ns',
{
name: 'No Spaces',
description: `**Usage:** \`-ns\`
Removes the default padding added space between rolls.`,
example: [
'`[[d4]][[d4]]` will normally return as `2 2` for readability',
'`[[d4]][[d4]] -ns` will remove the added padding to follow the exact input format and return as `22`',
],
},
],
]);
export const DecoratorsHelpPages: HelpPage = {

View File

@@ -102,6 +102,7 @@ export const apiRoll = async (query: Map<string, string>, apiUserid: bigint): Pr
rollDist: query.has('rd'),
numberVariables: query.has('nv') || query.has('vn'),
customDiceShapes: new Map<string, number[]>(),
noSpaces: query.has('ns'),
yVars: new Map<string, number>(),
apiWarn: hideWarn ? '' : apiWarning,
valid: true,