DiceTray 1.1.1
dotnet add package DiceTray --version 1.1.1
NuGet\Install-Package DiceTray -Version 1.1.1
<PackageReference Include="DiceTray" Version="1.1.1" />
<PackageVersion Include="DiceTray" Version="1.1.1" />
<PackageReference Include="DiceTray" />
paket add DiceTray --version 1.1.1
#r "nuget: DiceTray, 1.1.1"
#:package DiceTray@1.1.1
#addin nuget:?package=DiceTray&version=1.1.1
#tool nuget:?package=DiceTray&version=1.1.1
DiceTray
A cryptographically random dice rolling library for tabletop RPG applications, built on System.Security.Cryptography.RandomNumberGenerator for better randomness than the standard System.Random library.
Available on NuGet.org and jamescordrey.com.
Installation
dotnet add package DiceTray
Usage
DiceTray supports both a fluent interface and a non-fluent interface. Both styles are fully chainable and always return a RollResult object.
Fluent Interface
Roll a single d20:
using DiceTray;
RollResult result = Dice.Take(1).D(20).Roll();
Chain multiple dice groups:
RollResult result = Dice.Take(1).D(20).And(3).D(6).And(1).D(8).Roll();
Non-Fluent Interface
Roll 3d6:
RollResult result = Dice.Take(3, 6).Roll();
Chain multiple dice groups:
RollResult result = Dice.Take(1, 20).And(3, 6).Roll();
Mixing Styles
The two styles can be mixed freely in the same chain:
RollResult result = Dice.Take(1, 20).And(3).D(6).Roll();
Dice Notation
You can also pass a dice notation string directly to Roll():
RollResult result = Dice.Roll("1d20+2d10+3d6+2d8");
The notation is case insensitive and supports whitespace around the + separator:
RollResult result = Dice.Roll("1D20 + 2D10");
Invalid notation will throw an ArgumentException.
Results
Every call returns a RollResult object regardless of how many groups were rolled.
RollResult result = Dice.Take(1).D(20).And(3).D(6).Roll();
result.Total; // Grand total of all groups
result.Rolls.Count; // Number of groups (2 in this case)
result.Rolls[0].Sides; // 20
result.Rolls[0].Total; // Total of the 1d20
result.Rolls[0].IndividualRolls; // int[] of each die result
result.Rolls[1].Sides; // 6
result.Rolls[1].Total; // Total of the 3d6
result.Rolls[1].IndividualRolls; // int[] of each die result
RollResult
| Property | Type | Description |
|---|---|---|
Total |
int |
Sum of all roll group totals |
Rolls |
List<Roll> |
Individual roll groups |
Roll
| Property | Type | Description |
|---|---|---|
Total |
int |
Sum of all individual rolls in this group |
Sides |
int |
Number of sides on the die |
IndividualRolls |
int[] |
Each individual die result |
License
MIT © Damadar
Changelog
1.1.1
- Added XML documentation comments for IntelliSense support
- Updated package icon
1.1.0
- Added dice notation string parsing via
Dice.Roll(string) - Supports case insensitive notation and whitespace
1.0.0
- Initial release
- Fluent and non-fluent interfaces
- Cryptographically random number generation via
RandomNumberGenerator RollResultandRollmodels with pre-calculated totals
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.1 | 338 | 2/27/2026 |
Initial release.