Comments (9)
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.
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.
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.
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.
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.
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.
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.
Haha... sweet. Thanks for all your help!
from diceroller.
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)
- The type initializer for 'Dice.Roller' threw an exception. HOT 6
- Incorrect Parse HOT 3
- Coin Flips? HOT 1
- Tab Completion? HOT 12
- Generic step up/step down HOT 1
- Bugs in D&D Beyond's implementation of DiceRoller (Part one) HOT 1
- Bugs in D&D Beyond's implementation - 2: "Dice rolls not yet available for this section" HOT 3
- Dice expression for 1D6 where 6 -> 2 successes, 3 or 4 -> 1 success? HOT 3
- min-max HOT 2
- Allow N(dice count) to be ignored and equal to 1 by default HOT 6
- Possibility of parsing Roll20, DiceParser, RPGDiceRoller or other expression into a function HOT 4
- Link to Documentation is Broken HOT 2
- Alter Function Timing of explosion when used with the keephighest HOT 9
- Cyberpunk Red Style Explode Once, Implode Once rolls. (or Compound Once/Collapse Once) HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from diceroller.