Add OVA Dice documentation

Additionally, simplified the ova dropper
This commit is contained in:
Ean Milligan (Bastion) 2022-07-04 22:26:14 -04:00
parent 169ed564ae
commit a06042e6d4
3 changed files with 21 additions and 8 deletions

View File

@ -104,6 +104,9 @@ The Artificer comes with a few supplemental commands to the main rolling command
* CWOD Dice - `[[xcwody]]` * CWOD Dice - `[[xcwody]]`
* `x` - Number of CWOD dice to roll * `x` - Number of CWOD dice to roll
* `y` - Difficulty to roll at * `y` - Difficulty to roll at
* OVA Dice - `[[xovady]]`
* `x` - Number of OVA dice to roll
* `y` - Size of the die to roll (defaults to 6 if omitted)
* This command also has some useful decorators that can used. These decorators simply need to be placed after all rolls in the message: * This command also has some useful decorators that can used. These decorators simply need to be placed after all rolls in the message:
* `-c` - Count - Shows the Count Embed, containing the count of successful rolls, failed rolls, rerolls, drops, and explosions * `-c` - Count - Shows the Count Embed, containing the count of successful rolls, failed rolls, rerolls, drops, and explosions
* `-nd` - No Details - Suppresses all details of the requested roll * `-nd` - No Details - Suppresses all details of the requested roll

View File

@ -178,6 +178,13 @@ The Artificer supports most of the [Roll20 formatting](https://artificer.eanm.de
\`y\` - Difficulty to roll at`, \`y\` - Difficulty to roll at`,
inline: true, inline: true,
}, },
{
name: 'OVA Rolling',
value: `\`${config.prefix}xovady${config.postfix}\`
\`x\` - Number of OVA dice to roll
\`y\` - Size of the die to roll (defaults to 6 if omitted)`,
inline: true,
},
], ],
}, },
{ {

View File

@ -561,18 +561,21 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
// Handle OVA dropping/keeping // Handle OVA dropping/keeping
if (rollType === 'ova') { if (rollType === 'ova') {
const rollCounts: Array<number> = new Array(rollConf.dieSize).fill(0); // Make "empty" vals array to easily sum up which die value is the greatest
const rollVals: Array<number> = new Array(rollConf.dieSize).fill(0);
// Sum up all rolls
for (const roll of rollSet) { for (const roll of rollSet) {
loggingEnabled && log(LT.LOG, `handling ${rollType} ${rollStr} | incrementing rollCounts for ${roll}`); loggingEnabled && log(LT.LOG, `handling ${rollType} ${rollStr} | incrementing rollVals for ${roll}`);
rollCounts[roll.roll - 1]++; rollVals[roll.roll - 1] += roll.roll;
} }
const rollVals: Array<number> = rollCounts.map((cnt, idx) => (cnt * (idx + 1))); // Find max value, using lastIndexOf to use the greatest die size max in case of duplicate maximums
const maxRoll = rollVals.lastIndexOf(Math.max(...rollVals)) + 1;
const maxRoll = rollVals.indexOf(Math.max(...rollVals)) + 1;
// Drop all dice that are not a part of the max
for (let i = 0; i < rollSet.length; i++) { for (let i = 0; i < rollSet.length; i++) {
loggingEnabled && log(LT.LOG, `handling ${rollType} ${rollStr} | checking if this roll should be dropped ${rollSet[i].roll} | to keep: ${maxRoll}`);
if (rollSet[i].roll !== maxRoll) { if (rollSet[i].roll !== maxRoll) {
rollSet[i].dropped = true; rollSet[i].dropped = true;
rollSet[i].critFail = false; rollSet[i].critFail = false;