mirror of
https://github.com/Burn-E99/TheArtificer.git
synced 2026-01-08 13:27:55 -05:00
Begin adding support for penetrating and compounding explosions
Added rollDecorators help command to make [[?? small enough to fit in discord Added documentation on penetrating and compounding
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import { ping } from './ping.ts';
|
||||
import { rip } from './rip.ts';
|
||||
import { rollHelp } from './rollHelp.ts';
|
||||
import { rollDecorators } from './rollDecorators.ts';
|
||||
import { help } from './help.ts';
|
||||
import { info } from './info.ts';
|
||||
import { privacy } from './privacy.ts';
|
||||
@ -18,6 +19,7 @@ export default {
|
||||
ping,
|
||||
rip,
|
||||
rollHelp,
|
||||
rollDecorators,
|
||||
help,
|
||||
info,
|
||||
privacy,
|
||||
|
||||
@ -26,6 +26,11 @@ export const help = (message: DiscordenoMessage) => {
|
||||
value: `Details on how to use the roll command, listed as \`${config.prefix}xdy...${config.postfix}\` below`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}rollDecorators\` or \`${config.prefix}???\``,
|
||||
value: `Details on how to use decorators on the roll command`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}api [subcommand]\``,
|
||||
value: `Administrative tools for the bots's API, run \`${config.prefix}api help\` for more details`,
|
||||
|
||||
71
src/commands/rollDecorators.ts
Normal file
71
src/commands/rollDecorators.ts
Normal file
@ -0,0 +1,71 @@
|
||||
import config from '../../config.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { infoColor2 } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
export const rollDecorators = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('rollDecorators')).catch((e) => utils.commonLoggers.dbError('rollHelp.ts:15', 'call sproc INC_CNT on', e));
|
||||
|
||||
message.send({
|
||||
embeds: [
|
||||
{
|
||||
color: infoColor2,
|
||||
title: 'Roll Command Decorators:',
|
||||
description: `This command also has some useful decorators that can used. These decorators simply need to be placed after all rolls in the message.
|
||||
|
||||
Examples: \`${config.prefix}d20${config.postfix} -nd\`, \`${config.prefix}d20${config.postfix} -nd -s\`, \`${config.prefix}d20${config.postfix} ${config.prefix}d20${config.postfix} ${config.prefix}d20${config.postfix} -o a\``,
|
||||
fields: [
|
||||
{
|
||||
name: '`-nd` - No Details',
|
||||
value: 'Suppresses all details of the requested roll',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-snd` - Super No Details',
|
||||
value: 'Suppresses all details of the requested roll and hides no details message',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-s` - Spoiler',
|
||||
value: 'Spoilers all details of the requested roll',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-m` - Maximize Roll',
|
||||
value: 'Rolls the theoretical maximum roll, cannot be used with -n',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-n` - Nominal Roll',
|
||||
value: 'Rolls the theoretical nominal roll, cannot be used with -m',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-gm @user1 @user2 @usern` - GM Roll',
|
||||
value: 'Rolls the requested roll in GM mode, suppressing all publicly shown results and details and sending the results directly to the specified GMs',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-c` - Count Rolls',
|
||||
value: 'Shows the Count Embed, containing the count of successful rolls, failed rolls, rerolls, drops, and explosions',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-o [direction]` - Order Roll',
|
||||
value: `Rolls the requested roll and orders the results in the requested direction
|
||||
|
||||
Available directions:
|
||||
\`a\` - Ascending (least to greatest)
|
||||
\`d\` - Descending (greatest to least)`,
|
||||
inline: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('rollHelp.ts:247', message, e));
|
||||
};
|
||||
@ -20,7 +20,9 @@ export const rollHelp = (message: DiscordenoMessage) => {
|
||||
|
||||
This command also can fully solve math equations with parenthesis.
|
||||
|
||||
The Artificer supports most of the [Roll20 formatting](https://artificer.eanm.dev/roll20). More details and examples can be found [here](https://artificer.eanm.dev/roll20).`,
|
||||
The Artificer supports most of the [Roll20 formatting](https://artificer.eanm.dev/roll20). More details and examples can be found [here](https://artificer.eanm.dev/roll20).
|
||||
|
||||
Run \`[[???\` or \`[[rollDecorators\` for details on the roll decorators.`,
|
||||
},
|
||||
{
|
||||
color: infoColor2,
|
||||
@ -131,6 +133,16 @@ Additionally, replace \`x\` with \`F\` to roll Fate dice`,
|
||||
value: 'Exploding Once, rolls one `dy` for each original crit success',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!p` [Optional]',
|
||||
value: 'Penetrating Explosion, rolls one `dy` for each crit success, but subtracts one from each resulting explosion',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!!` [Optional]',
|
||||
value: 'Compounding Explosion, rolls one `dy` for each crit success, but adds the resulting explosion to the die that caused this explosion',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!=u` [Optional]',
|
||||
value: 'Explode on `u`, rolls another `dy` for every die that lands on `u`',
|
||||
@ -141,6 +153,11 @@ Additionally, replace \`x\` with \`F\` to roll Fate dice`,
|
||||
value: 'Explode on `u` and greater, rolls another `dy` for every die that lands on `u` or greater',
|
||||
inline: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
color: infoColor2,
|
||||
fields: [
|
||||
{
|
||||
name: '`!<u` [Optional]',
|
||||
value: 'Explode on `u` and under, rolls another `dy` for every die that lands on `u` or less',
|
||||
@ -151,11 +168,6 @@ Additionally, replace \`x\` with \`F\` to roll Fate dice`,
|
||||
value: 'Explodes Once on `u`, rolls another `dy` for each original die that landed on `u`',
|
||||
inline: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
color: infoColor2,
|
||||
fields: [
|
||||
{
|
||||
name: '`!o>u` [Optional]',
|
||||
value: 'Explode Once on `u` and greater, rolls another `dy` for each original die that landed on `u` or greater',
|
||||
@ -166,6 +178,36 @@ Additionally, replace \`x\` with \`F\` to roll Fate dice`,
|
||||
value: 'Explode Once on `u` and under, rolls another `dy` for each original die that landed on `u` or less',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!p=u` [Optional]',
|
||||
value: 'Penetrating Explosion on `u`, rolls one `dy` for each die that lands on `u`, but subtracts one from each resulting explosion',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!p>u` [Optional]',
|
||||
value: 'Penetrating Explosion on `u` and greater, rolls one `dy` for each die that lands on `u` or greater, but subtracts one from each resulting explosion',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!p<u` [Optional]',
|
||||
value: 'Penetrating Explosion on `u` and under, rolls one `dy` for each die that lands on `u` or under, but subtracts one from each resulting explosion',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!!=u` [Optional]',
|
||||
value: 'Compounding Explosion on `u`, rolls one `dy` for each die that lands on `u`, but adds the resulting explosion to the die that caused this explosion',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!!>u` [Optional]',
|
||||
value: 'Compounding Explosion on `u` and greater, rolls one `dy` for each die that lands on `u` or greater, but adds the resulting explosion to the die that caused this explosion',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!!<u` [Optional]',
|
||||
value: 'Compounding Explosion on `u` and under, rolls one `dy` for each die that lands on `u` or under, but adds the resulting explosion to the die that caused this explosion',
|
||||
inline: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@ -188,59 +230,6 @@ Additionally, replace \`x\` with \`F\` to roll Fate dice`,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
color: infoColor2,
|
||||
title: 'Roll Command Decorators:',
|
||||
description: `This command also has some useful decorators that can used. These decorators simply need to be placed after all rolls in the message.
|
||||
|
||||
Examples: \`${config.prefix}d20${config.postfix} -nd\`, \`${config.prefix}d20${config.postfix} -nd -s\`, \`${config.prefix}d20${config.postfix} ${config.prefix}d20${config.postfix} ${config.prefix}d20${config.postfix} -o a\``,
|
||||
fields: [
|
||||
{
|
||||
name: '`-nd` - No Details',
|
||||
value: 'Suppresses all details of the requested roll',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-snd` - Super No Details',
|
||||
value: 'Suppresses all details of the requested roll and hides no details message',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-s` - Spoiler',
|
||||
value: 'Spoilers all details of the requested roll',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-m` - Maximize Roll',
|
||||
value: 'Rolls the theoretical maximum roll, cannot be used with -n',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-n` - Nominal Roll',
|
||||
value: 'Rolls the theoretical nominal roll, cannot be used with -m',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-gm @user1 @user2 @usern` - GM Roll',
|
||||
value: 'Rolls the requested roll in GM mode, suppressing all publicly shown results and details and sending the results directly to the specified GMs',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-c` - Count Rolls',
|
||||
value: 'Shows the Count Embed, containing the count of successful rolls, failed rolls, rerolls, drops, and explosions',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-o [direction]` - Order Roll',
|
||||
value: `Rolls the requested roll and orders the results in the requested direction
|
||||
|
||||
Available directions:
|
||||
\`a\` - Ascending (least to greatest)
|
||||
\`d\` - Descending (greatest to least)`,
|
||||
inline: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
color: successColor,
|
||||
title: 'Results Formatting:',
|
||||
|
||||
@ -60,6 +60,8 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
|
||||
exploding: {
|
||||
on: false,
|
||||
once: false,
|
||||
compounding: false,
|
||||
penetrating: false,
|
||||
nums: <number[]> [],
|
||||
},
|
||||
};
|
||||
@ -261,10 +263,10 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
|
||||
rollConf.critFail.range.push(i);
|
||||
}
|
||||
break;
|
||||
case '!o':
|
||||
rollConf.exploding.once = true;
|
||||
// falls through as !o functions the same as ! in this context
|
||||
case '!':
|
||||
case '!o':
|
||||
case '!p':
|
||||
case '!!':
|
||||
// Configure Exploding
|
||||
rollConf.exploding.on = true;
|
||||
if (afterNumIdx > 0) {
|
||||
@ -275,18 +277,18 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
|
||||
afterNumIdx = 1;
|
||||
}
|
||||
break;
|
||||
case '!o=':
|
||||
rollConf.exploding.once = true;
|
||||
// falls through as !o= functions the same as != in this context
|
||||
case '!=':
|
||||
case '!o=':
|
||||
case '!p=':
|
||||
case '!!=':
|
||||
// Configure Exploding (this can happen multiple times)
|
||||
rollConf.exploding.on = true;
|
||||
rollConf.exploding.nums.push(tNum);
|
||||
break;
|
||||
case '!o>':
|
||||
rollConf.exploding.once = true;
|
||||
// falls through as !o> functions the same as !> in this context
|
||||
case '!>':
|
||||
case '!o>':
|
||||
case '!p>':
|
||||
case '!!>':
|
||||
// Configure Exploding for all numbers greater than or equal to tNum (this could happen multiple times, but why)
|
||||
rollConf.exploding.on = true;
|
||||
for (let i = tNum; i <= rollConf.dieSize; i++) {
|
||||
@ -294,10 +296,10 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
|
||||
rollConf.exploding.nums.push(i);
|
||||
}
|
||||
break;
|
||||
case '!o<':
|
||||
rollConf.exploding.once = true;
|
||||
// falls through as !o< functions the same as !< in this context
|
||||
case '!<':
|
||||
case '!o<':
|
||||
case '!p<':
|
||||
case '!!<':
|
||||
// Configure Exploding for all numbers less than or equal to tNum (this could happen multiple times, but why)
|
||||
rollConf.exploding.on = true;
|
||||
for (let i = 1; i <= tNum; i++) {
|
||||
@ -309,6 +311,29 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
|
||||
// Throw error immediately if unknown op is encountered
|
||||
throw new Error(`UnknownOperation_${tSep}`);
|
||||
}
|
||||
|
||||
// Exploding flags get set in their own switch statement to avoid weird duplicated code
|
||||
switch (tSep) {
|
||||
case '!o':
|
||||
case '!o=':
|
||||
case '!o>':
|
||||
case '!o<':
|
||||
rollConf.exploding.once = true;
|
||||
break;
|
||||
case '!p':
|
||||
case '!p=':
|
||||
case '!p>':
|
||||
case '!p<':
|
||||
rollConf.exploding.penetrating = true;
|
||||
break;
|
||||
case '!!':
|
||||
case '!!=':
|
||||
case '!!>':
|
||||
case '!!<':
|
||||
rollConf.exploding.compounding = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// Finally slice off everything else parsed this loop
|
||||
remains = remains.slice(afterNumIdx);
|
||||
}
|
||||
|
||||
2
src/solver/solver.d.ts
vendored
2
src/solver/solver.d.ts
vendored
@ -95,6 +95,8 @@ export type RollConf = {
|
||||
exploding: {
|
||||
on: boolean;
|
||||
once: boolean;
|
||||
compounding: boolean;
|
||||
penetrating: boolean;
|
||||
nums: number[];
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user