maxPool Demo

What is maxPool Demo?

A maxPool returns the single largest result from within the pool.



How the Template Works

The code for this demo creates an object showcasing a feature of the RollPlayer.js library and returns it to the template as demo.rollable. Both when the page loads and when the button above is pressed the template code calls demo.rollable.roll() and the returned result is displayed above. This process is identicle for all the demos allowing the explanations below to focus on only the object being demoed.

Every result is also logged to the console if you want to see a history after a bunch of button clicks.




  • Derek Pennycuff

Full source

  1. 1: var demo = function() {
  2. 2: var trait_die = RollPlayer.explodingDie(8);
  3. 3: var wild_die = RollPlayer.explodingDie();
  4. 4: var pool_wildcard = RollPlayer.maxPool(trait_die, wild_die);
  5. 5: return { rollable : pool_wildcard };
  6. 6: }();


We're creating a wrapper object called demo so that the template code can access the inner workings of this particular example.

  1. 1: var demo = function() {

We can build a Savage Worlds style roll using a custom callback function an a maxPool() of exploding dice.

  1. 2: var trait_die = RollPlayer.explodingDie(8);
  2. 3: var wild_die = RollPlayer.explodingDie();

We want to return the larger number from the 2 dice. maxPool() does the trick.

  1. 4: var pool_wildcard = RollPlayer.maxPool(trait_die, wild_die);

Return an object so that our template code can access the star of this example as demo.rollable

  1. 5: return { rollable : pool_wildcard };
  2. 6: }();

Tutorial Builder is © Christian Heilmann, 2008. Licensed under the BSD license.