Rolls a set of dice, as determined by the D20 die system.
To use RollGen, simple adhere to the verbose, fluid syntax:
var standardRoll = dice.Roll(3).d6();
var customRoll = dice.Roll(92).d(66);
var parsedRoll = dice.Roll("5+3d4*2");
You can obtain a Dice
object in one of 2 ways:
-
Recommended Use the Ninject Bootstrapper to inject the
Dice
object into your constructorvar kernel = new StandardKernel(); var rollGenModuleLoader = new RollGenModuleLoader(); rollGenModuleLoader.LoadModules(kernel);
Your particular syntax for how the Ninject injection should work will depend on your project (class library, web site, etc.)
-
Manually build the
Dice
object:var random = new Random(); var dice = new RandomDice(random);
Important If you are newing up dice objects multiple times, the seed for the
Random
class that you use will potentially be the same, and will not produce random results. The Ninject bootstrapper has taken this into account and helps ensure random seeds for theRandom
object - which is why it is the recommended way to build yourDice
object.
###Installing RollGen Install via the NuGet Package Manager.
That depends on your project. If you are making a library that will only reference RollGen, but does not expressly implement it (such as the TreasureGen project), then you only need the RollGen package. If you actually want to run and implement the dice (such as on the DnDGenSite or in the tests for TreasureGen), then you need RollGen.Bootstrap, which will install RollGen as a dependency.