So, I implemented the dice rolling for the Narration System that I made-up. It's now on production for IDDQD Social, although there's no FE for it yet. This one uses a dice pool system where you roll d12s for success at 9+ and dice explode at 11+. Here's how dice pools work in greater detail if you're not already familiar:
You pass it one positive integer that is the dice_pool. It rolls Xd12 dice, where X is equal to dice_pool. For every die that lands on 9 or above, it is counted as a "success." For each die that lands on 11 or above, you also re-roll them. These dice can be re-rolled over and over again. Notice how the dice_pool for the example is 14, yet there are 19 results. That's because of those dice, 5 of them landed on 11 or higher. So the dice_pool is one number, but the length of the results array is higher than that. This is defined, expected, behavior.
There is no FE for this yet, but you can still hit the endpoint:
curl -X POST "https://iddqd.social/api/v1/statuses" \ -H "Authorization: Bearer bearer_token_here" \ -H "Content-Type: multipart/form-data" \ --form-string "status=Whatever you want to say here, prepended before the dice roll result." \ -F "source=Pleroma FE" \ -F "visibility=public" \ -F "content_type=text/plain" \ -F "balormo[rng][system]=narration" \ -F "balormo[rng][dice_pool]=14"You can read the commit here:
https://gitgud.io/thestranjer/balormo/-/commit/4a753cec0bf1c7e7da1129b677eabfbbd97fe3f6
It relies on Elixir's polymorphism to capture the right rng values, and uses an accumulator with recursion to loop through the dice_pool. I don't consider myself the best functional programmer but this does work. In the object / activity, it produces data that's shaped like this:
{ "balormo": { "rng": { "system": "narration", "results": [6, 3, 2, 4, 1, 8, 9], "dice_pool": 7, "successes": 1 } } }@p @jeffcliff @sun @dielan @rees @crunklord420 @Hoss @caekislove @Tfmonkey @lain @mint @Eiregoat
RT: https://iddqd.social/objects/084b8320-0abe-4ca8-90c6-2fe0dd8bd575