For a character sheet I'm working on, I'm implementing a roller button for a special exploding dice mechanic that sort of goes like the following: The player rolls a single die, like a d6. If the result is the highest number on that die, then roll the next largest die up (d8) and keep the higher of the two rolls. Continue this pattern up to a d20 each time the maximum result is rolled on the die. For a d12, the dice equation I have isn't too bad. {1d11, floor(1d12/12)*{1d0 + 12, 1d20}k1}k1 In Javascript, this might be equivalent to: var d12 = Math.ceil(Math.random()*12);
var d20 = Math.ceil(Math.random()*20);
if(d12 === 12)
return Math.max(12, d20);
else
return d12; For a d10, it gets a little more complicated and some slowdown is noticeable when it is processed: {1d9, floor(1d10/10)*{1d0 + 10, {1d11, floor(1d12/12)*{1d0 + 12, 1d20}k1}k1}k1}k1 In Javascript, this might be equivalent to: var d10 = Math.ceil(Math.random()*10);
var d12 = Math.ceil(Math.random()*12);
var d20 = Math.ceil(Math.random()*20);
if(d10 === 10) {
if(d12 === 12)
return Math.max(12, d20);
else
return d12;
}
else
return d10; ...and so forth. For d6 and lower though, the dice system seems to have so much trouble processing it that it causes Chrome to crash. Since it's not even a combinatoric equation, I wouldn't expect it to take such a long time to compute, especially since it only has to process groups of 2 at a time in any of these equations (albeit nested groups of 2). Here's the equation for exploding a d4 with this mechanic: {1d3, floor(1d4/4)*{1d0 + 4, {1d5, floor(1d6/6)*{1d0 + 6, {1d7, floor(1d8/8)*{1d0 + 8, {1d9, floor(1d10/10)*{1d0 + 10, {1d11, floor(1d12/12)*{1d0 + 12, 1d20}k1}k1}k1}k1}k1}k1}k1}k1}k1}k1 From the Chrome development console, here is a sample of output first from exploding a d10 with this system (finishes after a second), and then exploding a d6 with it (stuck in limbo). // The d10 roll:
app.js?1494260277:44 Begin processing op!
app.js?1494260277:44 Levels deep: 0
app.js?1494260277:44 Finished 0
app.js?1494260277:44 Levels deep: 0
app.js?1494260277:44 Inline rolls complete!
app.js?1494260277:42 Descending into madness...
app.js?1494260277:42 Descending into madness...
app.js?1494260277:42 Descending into madness...
app.js?1494260277:42 Descending into madness...
app.js?1494260277:44 Finished after going 2 levels deep.
// The d6 roll:
app.js?1494260277:44 Begin processing op!
Levels deep: 0
app.js?1494260277:31 Firebase Offline
app.js?1494260277:35 Player -abc123 is offline...
app.js?1494260277:44 Finished 0
app.js?1494260277:44 Levels deep: 0
app.js?1494260277:44 Inline rolls complete!
firebase.2.4.0.js:106 Uncaught Error: Firebase.setWithPriority failed: First argument path specified exceeds the maximum depth that can be written (32) or object contains a cycle in property 'campaign-abc123-abc123.chat.-abc123.inlinerolls.0.results.rolls.0.rolls.1.3.rolls.1.0.rolls.1.3.rolls.1.0.rolls.1.3.rolls.1.0.rolls.1.3.rolls.0.0.type'
at of (firebase.2.4.0.js:106)
at nf.push (firebase.2.4.0.js:105)
at firebase.2.4.0.js:124
at Fb (firebase.2.4.0.js:28)
at hg (firebase.2.4.0.js:123)
at firebase.2.4.0.js:124
at Fb (firebase.2.4.0.js:28)
at hg (firebase.2.4.0.js:123)
at firebase.2.4.0.js:124
at Fb (firebase.2.4.0.js:28)
of @ firebase.2.4.0.js:106
nf.push @ firebase.2.4.0.js:105
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
(anonymous) @ firebase.2.4.0.js:124
Fb @ firebase.2.4.0.js:28
hg @ firebase.2.4.0.js:123
gg @ firebase.2.4.0.js:122
X.Ob @ firebase.2.4.0.js:259
s @ app.js?1494260277:44
(anonymous) @ app.js?1494260277:44
(anonymous) @ base.js?1492617404:1
app.js?1494260277:31 Timeout ref showed error!
app.js?1494260277:31 Firebase Online