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

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

@@ -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,
},
],
},
{

View File

@@ -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;