Chapter 7. Multisided Die

In this chapter, you’ll build on the code written in the previous chapter to let you roll a die of any number of sides. Sometimes you want a random number that doesn’t fit in the range 1 to 6. Ideally, you’d like your virtual dice module to return a random number for any range you give it. You’re going to take your six-sided die from the previous chapter and enhance it so it can change shape to any number of sides like the multisided die used in some tabletop and role-playing games (see FIGURE 7.1).

Image

FIGURE 7.1 Multisided dice

Flexible Functions

If you wanted to expand on what you’ve already done to support dice of ...

Get A Beginner’s Guide to Writing Minecraft Plugins in JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.