TecKnow / STADiceRoller

Dice roller and probability visualizer compatible with the Star Trek Adventures TTRPG.
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Allow the application to "roll dice." #9

Open TecKnow opened 1 year ago

TecKnow commented 1 year ago

Right now the app only displays probability distribution information. It can't actually be used to make rolls. Complete STA roll functionality depends on UI and probability distribution support for assists, so it can't be implemented right now. However, basic roll functionality still requires investigating JS's randomness functionality, which can be done now.

Specifically, it must be decided if cryptographically secure random number generation is desirable, and then a function for doing that when possible, and falling back if not, needs to be implemented.

TecKnow commented 1 year ago

Be aware that calling random functions might result in the same sort of synchronization problems that were seen when implementing the table. The server's pre-generated DOM won't match the one on the client.

Since the site is currently deployed statically, this shouldn't be a problem in production but it can cause the development server to complain and isn't good long-term.

TecKnow commented 1 year ago

Be aware that the window object only exists on the client side. If the server tries to call any of these objects while pre-generating the page, it will fail. This is probably similar to how server-side code for loading static data needed to be carefully isolated, since node functions don't exist on the client side. This will come up if the crypto API is used for secure randomness.