Add Number Variables flag
This commit is contained in:
		
							parent
							
								
									41fbb1bd50
								
							
						
					
					
						commit
						7116851139
					
				| 
						 | 
				
			
			@ -5,7 +5,7 @@ meta {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
get {
 | 
			
		||||
  url: http://localhost:8166/api/roll?user=[discord-user-id]&channel=[discord-channel-id]&rollstr=[artificer-roll-cmd]&documentation=All items below are optional. Flags do not need values.&nd=[no-details-flag]&snd=[super-no-details-flag]&hr=[hide-raw-roll-details-flag]&s=[spoiler-results-flag]&m-or-max=[max-roll-flag, cannot be used with n flag]&min=[min-roll-flag, cannot be used with n, sn, or max]&n=[nominal-roll-flag, cannot be used with sn, max or min flag]&sn=[simulated-nominal-flag, cannot be used with max, min, n. or cc]&gms=[csv-of-discord-user-ids-to-be-dmed-results]&o=[order-rolls, must be a or d]&c=[count-flag]&cc=[confirm-crit-flag, cannot be used with sn]&rd=[roll-dist-flag]
 | 
			
		||||
  url: http://localhost:8166/api/roll?user=[discord-user-id]&channel=[discord-channel-id]&rollstr=[artificer-roll-cmd]&documentation=All items below are optional. Flags do not need values.&nd=[no-details-flag]&snd=[super-no-details-flag]&hr=[hide-raw-roll-details-flag]&s=[spoiler-results-flag]&m-or-max=[max-roll-flag, cannot be used with n flag]&min=[min-roll-flag, cannot be used with n, sn, or max]&n=[nominal-roll-flag, cannot be used with sn, max or min flag]&sn=[simulated-nominal-flag, can pass number with it, cannot be used with max, min, n. or cc]&gms=[csv-of-discord-user-ids-to-be-dmed-results]&o=[order-rolls, must be a or d]&c=[count-flag]&cc=[confirm-crit-flag, cannot be used with sn]&rd=[roll-dist-flag]&nv-or-vn=[number-variables-flag]
 | 
			
		||||
  body: none
 | 
			
		||||
  auth: inherit
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -28,4 +28,5 @@ params:query {
 | 
			
		|||
  c: [count-flag]
 | 
			
		||||
  cc: [confirm-crit-flag, cannot be used with sn]
 | 
			
		||||
  rd: [roll-dist-flag]
 | 
			
		||||
  nv-or-vn: [number-variables-flag]
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -136,6 +136,7 @@ The Artificer comes with a few supplemental commands to the main rolling command
 | 
			
		|||
    * `-cc` - Confirm Critical Hits - Automatically rerolls whenever a crit hits, cannot be used with `-sn`
 | 
			
		||||
    * `-rd` - Roll Distribution - Shows a raw roll distribution of all dice in roll
 | 
			
		||||
    * `-hr` - Hide Raw - Hide the raw input, showing only the results/details of the roll
 | 
			
		||||
    * `-nv` or `-vn` - Number Variables - Adds `xN` before each roll command in the details section for debug reasons
 | 
			
		||||
  * The results have some formatting applied on them to provide details on what happened during this roll.
 | 
			
		||||
    * Critical successes will be **bolded**
 | 
			
		||||
    * Critical fails will be <ins>underlined</ins>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -96,7 +96,7 @@ export const runCmd = (rollRequest: QueuedRoll): SolvedRoll => {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    // Fill out all of the details and results now
 | 
			
		||||
    tempReturnData.forEach((e) => {
 | 
			
		||||
    tempReturnData.forEach((e, i) => {
 | 
			
		||||
      loopCountCheck();
 | 
			
		||||
 | 
			
		||||
      loggingEnabled && log(LT.LOG, `Parsing roll ${rollRequest.rollCmd} | Making return text ${JSON.stringify(e)}`);
 | 
			
		||||
| 
						 | 
				
			
			@ -125,8 +125,14 @@ export const runCmd = (rollRequest: QueuedRoll): SolvedRoll => {
 | 
			
		|||
        line2 += `${preFormat}${rollRequest.modifiers.commaTotals ? e.rollTotal.toLocaleString() : e.rollTotal}${postFormat}, `;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      const varNum = `\`x${i}\`: `;
 | 
			
		||||
      const rollDetails = rollRequest.modifiers.noDetails || rollRequest.modifiers.simulatedNominal > 0 ? ' = ' : ` = ${e.rollDetails} = `;
 | 
			
		||||
      line3 += `\`${e.initConfig.replaceAll(' ', '')}\`${rollDetails}${preFormat}${rollRequest.modifiers.commaTotals ? e.rollTotal.toLocaleString() : e.rollTotal}${postFormat}\n`;
 | 
			
		||||
      line3 += `${rollRequest.modifiers.numberVariables && i + 1 !== tempReturnData.length ? varNum : ''}\`${
 | 
			
		||||
        e.initConfig.replaceAll(
 | 
			
		||||
          ' ',
 | 
			
		||||
          '',
 | 
			
		||||
        )
 | 
			
		||||
      }\`${rollDetails}${preFormat}${rollRequest.modifiers.commaTotals ? e.rollTotal.toLocaleString() : e.rollTotal}${postFormat}\n`;
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    // If order is on, remove trailing ", "
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,6 +55,7 @@ export interface RollModifiers {
 | 
			
		|||
  commaTotals: boolean;
 | 
			
		||||
  confirmCrit: boolean;
 | 
			
		||||
  rollDist: boolean;
 | 
			
		||||
  numberVariables: boolean;
 | 
			
		||||
  apiWarn: string;
 | 
			
		||||
  valid: boolean;
 | 
			
		||||
  error: Error;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,6 +19,8 @@ export const Modifiers = Object.freeze({
 | 
			
		|||
  CommaTotals: '-ct',
 | 
			
		||||
  ConfirmCrit: '-cc',
 | 
			
		||||
  RollDistribution: '-rd',
 | 
			
		||||
  NumberVariables: '-nv',
 | 
			
		||||
  VariablesNumber: '-vn',
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
export const getModifiers = (args: string[]): [RollModifiers, string[]] => {
 | 
			
		||||
| 
						 | 
				
			
			@ -38,6 +40,7 @@ export const getModifiers = (args: string[]): [RollModifiers, string[]] => {
 | 
			
		|||
    commaTotals: false,
 | 
			
		||||
    confirmCrit: false,
 | 
			
		||||
    rollDist: false,
 | 
			
		||||
    numberVariables: false,
 | 
			
		||||
    apiWarn: '',
 | 
			
		||||
    valid: true,
 | 
			
		||||
    error: new Error(),
 | 
			
		||||
| 
						 | 
				
			
			@ -122,6 +125,10 @@ export const getModifiers = (args: string[]): [RollModifiers, string[]] => {
 | 
			
		|||
      case Modifiers.RollDistribution:
 | 
			
		||||
        modifiers.rollDist = true;
 | 
			
		||||
        break;
 | 
			
		||||
      case Modifiers.NumberVariables:
 | 
			
		||||
      case Modifiers.VariablesNumber:
 | 
			
		||||
        modifiers.numberVariables = true;
 | 
			
		||||
        break;
 | 
			
		||||
      default:
 | 
			
		||||
        // Default case should not mess with the array
 | 
			
		||||
        defaultCase = true;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -162,6 +162,16 @@ Shows a raw roll distribution of all dice in roll.`,
 | 
			
		|||
      example: ['`[[1000d20]] -rd`'],
 | 
			
		||||
    },
 | 
			
		||||
  ],
 | 
			
		||||
  [
 | 
			
		||||
    '-nv',
 | 
			
		||||
    {
 | 
			
		||||
      name: 'Number Variables',
 | 
			
		||||
      description: `**Usage:** \`-nv\` or \`-vn\`
 | 
			
		||||
 | 
			
		||||
Mainly a debug decorator, useful when creating complex rolls that will be reused.  Will not number the final roll command in the list as it will not be available for use.`,
 | 
			
		||||
      example: ['`[[d20]] [[d20]] [[d20]] -vn`'],
 | 
			
		||||
    },
 | 
			
		||||
  ],
 | 
			
		||||
]);
 | 
			
		||||
 | 
			
		||||
export const DecoratorsHelpPages: HelpPage = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -46,19 +46,20 @@ Damage: 14`,
 | 
			
		|||
 | 
			
		||||
This message must contain multiple roll commands in it (such as \`[[d4]] [[d8]]\`).  Nested dice rolls are not able to be used as a variable, but can use variables inside them.
 | 
			
		||||
 | 
			
		||||
Variables are numbered from \`x0\` to \`xN\`, where \`N\` equals two less than the total number of roll commands in the message.
 | 
			
		||||
Variables are numbered from \`x0\` to \`xN\`, where \`N\` equals two less than the total number of roll commands in the message.  You can add the "Number Variables" flag (\`-nv\`) to your command to see what will be assigned to each roll command.
 | 
			
		||||
 | 
			
		||||
**Notes about this example:**
 | 
			
		||||
- The example below starts with \`[[0]]\` so that it is a valid roll command.  See the \`Miscellaneous Features>User Formatting\` help page for more details.
 | 
			
		||||
- It is recommended to use the "Super No Details" flag (\`-snd\`) in combination with the "Hide Raw" flag (\`-hr\`) to only show the formatted results.  This example does not use it to show exactly what is happening.
 | 
			
		||||
- The example makes use of Nested Roll Commands to use the "To Hit" as the number of dice to roll for the "Explosion".`,
 | 
			
		||||
      example: [
 | 
			
		||||
        `\`\`\`[[0]]<=(this is x0) ${config.name} attacks the dragon with their Magical Sword of Extra Strength and Explosions!
 | 
			
		||||
        `If you send:
 | 
			
		||||
\`\`\`[[0]]<=(this is x0) ${config.name} attacks the dragon with their Magical Sword of Extra Strength and Explosions!
 | 
			
		||||
Strength Check: [[d20 + 8 + 2 - 1]]<=(this is x1)
 | 
			
		||||
To Hit: [[d20 + 4 - 1 + 8]]<=(this is x2)
 | 
			
		||||
Damage: [[(d8 + 10) * x1]]<=(this is x3)
 | 
			
		||||
Explosion: [[ [[x2]]d10! * x3 ]]\`\`\`
 | 
			
		||||
The above results in the following:
 | 
			
		||||
${config.name} will respond with:
 | 
			
		||||
 | 
			
		||||
@$ rolled:
 | 
			
		||||
\`[[0]] ${config.name} attacks the dragon with their Magical Sword of Extra Strength and Explosions! Strength Check: [[d20 + 8 + 2 - 1]] To Hit: [[d20 + 4 - 1 + 8]] Damage: [[(d8 + 10) * x1]] Explosion: [[ [[x2]]d10! * x3 ]]\`
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -99,6 +99,7 @@ export const apiRoll = async (query: Map<string, string>, apiUserid: bigint): Pr
 | 
			
		|||
          commaTotals: query.has('ct'),
 | 
			
		||||
          confirmCrit: query.has('cc'),
 | 
			
		||||
          rollDist: query.has('rd'),
 | 
			
		||||
          numberVariables: query.has('nv') || query.has('vn'),
 | 
			
		||||
          apiWarn: hideWarn ? '' : apiWarning,
 | 
			
		||||
          valid: true,
 | 
			
		||||
          error: new Error(),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue