Open bdc4 opened 2 years ago
Yeah, this is actually what I was trying to get at by asking this question (https://github.com/dice-roller/rpg-dice-roller/issues/241). This would be super useful!
I put together PR #244 as an attempt to get this implemented. Thanks @GreenImp for making this such an easy and pleasant project to work on!
Thanks @erik-jenkins! I'll check out your pull request and see if I can leverage that as well if that's alright with you :) I agree, I would love to see both of what we're asking for implemented in the source itself. Good luck with whatever you're working on!
Just thinking about this, and I'm not sure how feasible it would be, but would it make sense to store the actual Dice object against the Result object, rather than just a string side?
I just put up PR #252 to try that out, it seems to work pretty well! The one thing I haven't tried yet is to see how serialization of the RollResult
is affected.
I just started using this library and it's great, but one of the first things I tried to do was get the number of sides for a given die being rolled. I was surprised to find that to be not an easy thing to do. Coming here, I see this open issue, which seems to be exactly what I was looking for, but then see that it's been in limbo for almost a year. Are there any plans to get the pull request pushed through?
Alternatively, what's the recommended way of getting the type of die/dice being rolled from a DiceRoll result?
Bumping this - I wanted to use it with a deterministic 3d dice roller, which requires knowing both the results and the die types
I'm trying to build a UI for the dice output that shows the matching die image (ie: d4, d20, ect) that corresponds to the die roll. However, the RollResult class structure / output doesn't contain that information, just the results after the roll calculation.
I would love an additional property added to the RollResult class that shows the die type used to generate that roll result. ie: "rolls": [{ "sides": d20, // or even just 20 <----- "calculationValue": 4, "initialValue": 4, "modifierFlags": "", "modifiers": [], "type": "result", "useInTotal": true, "value": 4 // ... ect }]
I've tried trying to customize the RollResult class to capture this, but I am having a hard time... Honestly, TypeScript is well out of my wheelhouse... If anyone has a suggestion so I can implement this on my own, I am all ears!
Thanks in advance. Please let me know if you need more info from me :)