Closed sdsalyer closed 5 years ago
Thanks for the heads-up, 3.2.0 was still a bit of a work in progress and then I promptly forgot that I never released it.
No problem. :) I was able to check out and build without issue. There are newer versions of the Antlr4 and TupleValue libraries, so I went ahead and updated those locally. I imagine you'll update/close this issue if you find the time to publish it to NuGet.org?
Great work on this, by the way. This is the only library I've seen that supports grouping and comparisons, among other things. Looking forward to playing around with it!
No problem. :) I was able to check out and build without issue. There are newer versions of the Antlr4 and TupleValue libraries, so I went ahead and updated those locally. I imagine you'll update/close this issue if you find the time to publish it to NuGet.org?
Correct. I need to ensure that this library is compatible back to .NET Framework 4.5 as one of the groups using this library is stuck on that version, which is why the ValueTuple nuget package is referenced. The package is unnecessary if you are using .NET Frameowrk 4.7+, .NET Core 1.0+, or .NET Standard 2.0+ and you can safely uninstall it in those cases without impacting anything.
My ETA for getting 3.2.0 on nuget is probably a week or two, as I'd like to finish those Max/Min/Average APIs I mentioned in the changelog which are currently a WIP. I will indeed close out this task once the NuGet package is updated.
Great work on this, by the way. This is the only library I've seen that supports grouping and comparisons, among other things. Looking forward to playing around with it!
Thanks! If you have any suggestions for new features feel free to open another issue or create a PR. My experience is largely with d20-based games (D&D, Pathfinder, HackMaster, etc.) and so that's what most of the features here target.
Probably not the appropriate place to ask questions, but... Is there a way to do a nested roll? For example, if I want to roll two d6's and compare each to the result of a d10 to count successes, I would think that would be a syntax like {1d6,1d6}>1d10
but the comparison operator seems to be expecting a numeric value rather than a roll.
EDIT: I was able to do this by implementing a macro that just passes the arguments along to Roller.Roll
and assigns the results to the context.
Roller.DefaultConfig.MacroRegistry.RegisterMacro("r", RollMacro);
...
private void RollMacro(MacroContext context)
{
string expression = string.Join(" ", context.Arguments.Skip(1));
RollResult result = Roller.Roll(expression);
context.ValueType = result.ResultType;
context.Values = result.Values;
context.Value = result.Value;
}
You can put a roll whenever a number is expected by wrapping it in parenthesis: 2d6>(1d10)
(or {1d6,1d6}>(1d10)
if you want to have a grouped roll for whatever reason)
I tried the parenthesis approach, but the expression on the right apparently isn't evaluated. I ended up with an exception, Roller.Roll("2d6>(1d10)");
-> Error processing the dice expression: extraneous input '(' expecting {T_NUMBER, T_MACRO, T_MINUS}
. Not sure if this could be related to changing the ANTLR version in my local build? But, the macro approach seems to work fine, so I'll stick with that for now. :-)
Looks to be a grammar bug; I'll get that addressed in 3.2.0 as well. Well, notsomuch "bug" as "I intentionally wrote the grammar that way" but I cannot figure out why I wrote the grammar that way to deny math expressions in comparisons. That restriction doesn't match what I have in the documentation (I have written "Math expressions can be wrapped in parenthesis as well to clearly denote which expressions should be evaluated first, or to inject a math operation into any location where a number would normally be expected.") so either the code is wrong or the documentation is wrong, and if you find the feature of having math on the right-hand side of a comparison useful, then I'll claim that the code is wrong 🙂.
While you could fix it yourself by editing DiceGrammarParser.g4 and then running antlr to re-generate the parser class, it's not the easiest thing to do. The top of the .g4 file contains an example command to run so that you can re-generate the relevant files in that case.
Haha... sweet. Thanks for all your help!
Ended up bumping version up to 4.0.0 because I wanted to make a couple of backwards-incompatible changes with regards to how nested rolls are displayed.
Public API documentation should be fully updated for new features soon, although there are still a ton of redlinks (missing documentation) for internals.
Hi there,
I'm hoping to use your library in a Xamarin.Forms app, but it doesn't seem to be compatible with monoandroid81 due to targeting .NET Framework 4.6.1. I see on your documentation website that you've created a 3.2.0 version ( https://skizzerz.net/DiceRoller/Changelog#3.2.0 ) that targets .NET Standard 2.0, but that doesn't seem to be reflected on
Github orNuGet.org, as I only see version 3.1.0.Is there some way I could get my hands on the 3.2.0 version?Thanks for your help!EDIT: I see now the Dice.csproj is targetting .NET Standard 2.0. I will pull the code down and build it, but I'll leave this here as a reminder that NuGet is still on the previous version. :)