foundryvtt / unfulfilled-rolls

A module that allows individual rolls to be fulfilled by other sources
MIT License
3 stars 5 forks source link

Die size emulation for Bluetooth dice #21

Open zeel01 opened 1 year ago

zeel01 commented 1 year ago

When using a Bluetooth Die provider, it would be useful if we could choose a particular physical die shape to emulate the results of a lesser die. This would allow for more rolls to be resolved using a smaller number of physical dice, and therefore a lower investment in hardware while still retaining full functionality.

Additionally, this feature would allow for the rolling of certain esoteric dice such as d5, d3, and d2 using an appropriate larger die.

The following is a list of common dice and smaller sizes they can emulate:

Note that all 7 standard die sizes could be emulated with just the d20, d12, and d8 - only 3 physical dice. The d20 in particular is useful, as that's the only size of Pixels dice currently available.

Any rolled value can be translated to the equivalent value on a given die size using the expression (size, roll) => ((roll - 1) % size) + 1;, where size is the number of faces on the die you want to emulate, and roll is the value rolled on the die you actually used. As long as you use a die with a number of faces that is a whole-number multiple of the number of faces on the target die, this will be just as fair as having rolled the correct die size.

The following could be a potential user interface:

image

Here, the potential die shapes that could evaluate to the d4 are listed after the provider selection box. The checkboxes that are not available (no physical dice are connected) are disabled. The only option that can be chosen is d20, which is available and can be evaluated as a d4 fairly.