Compounding explosions are now functional
This commit is contained in:
parent
7823227f6e
commit
36405421f6
|
@ -522,6 +522,7 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
|
||||||
// If penetrating is on, do the decrements
|
// If penetrating is on, do the decrements
|
||||||
if (rollConf.exploding.penetrating) {
|
if (rollConf.exploding.penetrating) {
|
||||||
for (const penRoll of rollSet) {
|
for (const penRoll of rollSet) {
|
||||||
|
loggingEnabled && log(LT.LOG, `handling ${rollType} ${rollStr} | Handling penetrating explosions ${JSON.stringify(penRoll)}`);
|
||||||
// If loopCount gets too high, stop trying to calculate infinity
|
// If loopCount gets too high, stop trying to calculate infinity
|
||||||
if (loopCount > config.limits.maxLoops) {
|
if (loopCount > config.limits.maxLoops) {
|
||||||
throw new Error('MaxLoopsExceeded');
|
throw new Error('MaxLoopsExceeded');
|
||||||
|
@ -536,6 +537,29 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle compounding explosions
|
||||||
|
if (rollConf.exploding.compounding) {
|
||||||
|
for (let i = 0; i < rollSet.length; i++) {
|
||||||
|
loggingEnabled && log(LT.LOG, `handling ${rollType} ${rollStr} | Handling compounding explosions ${JSON.stringify(rollSet[i])}`);
|
||||||
|
// If loopCount gets too high, stop trying to calculate infinity
|
||||||
|
if (loopCount > config.limits.maxLoops) {
|
||||||
|
throw new Error('MaxLoopsExceeded');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compound the exploding rolls, including the exploding flag and
|
||||||
|
if (rollSet[i].exploding) {
|
||||||
|
rollSet[i - 1].roll = rollSet[i - 1].roll + rollSet[i].roll;
|
||||||
|
rollSet[i - 1].exploding = true;
|
||||||
|
rollSet[i - 1].critFail = rollSet[i - 1].critFail || rollSet[i].critFail;
|
||||||
|
rollSet[i - 1].critHit = rollSet[i - 1].critHit || rollSet[i].critHit;
|
||||||
|
rollSet.splice(i, 1);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
Loading…
Reference in New Issue