Git Product home page Git Product logo

Comments (9)

skizzerz avatar skizzerz commented on June 6, 2024 1

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.

from diceroller.

skizzerz avatar skizzerz commented on June 6, 2024

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.

from diceroller.

sdsalyer avatar sdsalyer commented on June 6, 2024

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!

from diceroller.

sdsalyer avatar sdsalyer commented on June 6, 2024

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;
        }

from diceroller.

skizzerz avatar skizzerz commented on June 6, 2024

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)

from diceroller.

sdsalyer avatar sdsalyer commented on June 6, 2024

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. :-)

from diceroller.

skizzerz avatar skizzerz commented on June 6, 2024

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.

from diceroller.

sdsalyer avatar sdsalyer commented on June 6, 2024

Haha... sweet. Thanks for all your help!

from diceroller.

skizzerz avatar skizzerz commented on June 6, 2024

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.

from diceroller.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.