RogueSharp 2.0 Released
Dice Notation
RogueSharp Version 2.0
on 2.0 of RogueSharp was just released. It now contains better functionality for dealing with Dice and parsing Dice Notation strings.
Dice Notation .NET – Significant portions of the code in RougeSharp.DiceNotation namespace are from this great library. Thank you to Chris Wagner for originally creating this.
Usage
The easiest way to roll dice using dice notation is to use the static Roll method on the Dice class and provide a string representing the dice expression.
Example 1
Example 2
Example 3
Example 4
Creating Expressions Fluently
If you haven’t heard of Fluent interfaces you can check out the link on Wikipedia to get a better description than I could provide. I think of it is using method chaining to produce more readable code. If you have ever used LINQ and seen how you could chain methods together to build your queries, I think that is a decent example. Let’s see how you can build a DiceExpression fluently
Upgrading from v1.X
If you are were using an earlier version of RogueSharp and you used the Dice
or Die
classes there will be some minor changes that you will have to make to use v2.0. I have upgraded the sample for the tutorial series here so you can get an idea of what it will take: https://bitbucket.org/FaronBracy/roguesharpmonogamesamples/commits/25a57cc9820bcb2e75a043d76ca6bf32020db2ff