Penetrating explosions are now functional, added formatting for explosions

This commit is contained in:
Ean Milligan (Bastion) 2022-07-05 22:19:10 -04:00
parent 54f081db74
commit 7823227f6e
3 changed files with 26 additions and 0 deletions

View File

@ -250,6 +250,11 @@ Additionally, replace \`x\` with \`F\` to roll Fate dice`,
value: 'Rolls that were dropped or rerolled ~~crossed out~~.', value: 'Rolls that were dropped or rerolled ~~crossed out~~.',
inline: true, inline: true,
}, },
{
name: 'Exclamation mark (`!`)',
value: 'Rolls that were caused by an explosion have an exclamation mark (`!`) after them.',
inline: true,
},
], ],
}, },
], ],

View File

@ -61,6 +61,10 @@ export const formatRoll = (rollConf: string, maximiseRoll: boolean, nominalRoll:
preFormat = `~~${preFormat}`; preFormat = `~~${preFormat}`;
postFormat = `${postFormat}~~`; postFormat = `${postFormat}~~`;
} }
if (e.exploding) {
// Add ! to indicate the roll came from an explosion
postFormat = `!${postFormat}`;
}
// Finally add this to the roll's details // Finally add this to the roll's details
tempDetails += `${preFormat}${e.roll}${postFormat} + `; tempDetails += `${preFormat}${e.roll}${postFormat} + `;

View File

@ -519,6 +519,23 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
} }
} }
// If penetrating is on, do the decrements
if (rollConf.exploding.penetrating) {
for (const penRoll of rollSet) {
// If loopCount gets too high, stop trying to calculate infinity
if (loopCount > config.limits.maxLoops) {
throw new Error('MaxLoopsExceeded');
}
// If the die was from an explosion, decrement it by one
if (penRoll.exploding) {
penRoll.roll--;
}
loopCount++;
}
}
// If we need to handle the drop/keep flags // If we need to handle the drop/keep flags
if (dkdkCnt > 0) { if (dkdkCnt > 0) {
// Count how many rerolled dice there are if the reroll flag was on // Count how many rerolled dice there are if the reroll flag was on