Add OVA Dice documentation
Additionally, simplified the ova dropper
This commit is contained in:
parent
169ed564ae
commit
a06042e6d4
|
@ -104,6 +104,9 @@ The Artificer comes with a few supplemental commands to the main rolling command
|
|||
* CWOD Dice - `[[xcwody]]`
|
||||
* `x` - Number of CWOD dice to roll
|
||||
* `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:
|
||||
* `-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
|
||||
|
|
|
@ -178,6 +178,13 @@ The Artificer supports most of the [Roll20 formatting](https://artificer.eanm.de
|
|||
\`y\` - Difficulty to roll at`,
|
||||
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,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
|
@ -561,18 +561,21 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
|
|||
|
||||
// Handle OVA dropping/keeping
|
||||
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) {
|
||||
loggingEnabled && log(LT.LOG, `handling ${rollType} ${rollStr} | incrementing rollCounts for ${roll}`);
|
||||
rollCounts[roll.roll - 1]++;
|
||||
loggingEnabled && log(LT.LOG, `handling ${rollType} ${rollStr} | incrementing rollVals for ${roll}`);
|
||||
rollVals[roll.roll - 1] += roll.roll;
|
||||
}
|
||||
|
||||
const rollVals: Array<number> = rollCounts.map((cnt, idx) => (cnt * (idx + 1)));
|
||||
|
||||
const maxRoll = rollVals.indexOf(Math.max(...rollVals)) + 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;
|
||||
|
||||
// Drop all dice that are not a part of the max
|
||||
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) {
|
||||
rollSet[i].dropped = true;
|
||||
rollSet[i].critFail = false;
|
||||
|
|
Loading…
Reference in New Issue