A C# port of Dicebag by 8bitskull, originally in Lua for Defold.
Dicebag is an addon of probability functions designed specifically for games. Inspired by this excellent blog post: https://www.redblobgames.com/articles/probability/damage-rolls.html
After dropping the files to your project, you can access the proparility functions with the "Dicebag" namespace
Main Dicebag class hosting most of the propability functions.
The random generator used by Dicebag. To set a seed for the generator, do the following:
Dicebag.Dicebag.R = new System.Random(seed);
50% chance of returning either true or false
Roll one or multiple dices. Returns resulting roll value. PARAMETERS
_numOfDice
(int) optional | specify how many dices to roll_numOfSides
(int) optional | specify the side count of each dice_modifier
(int) optional | modifier added to the total roll
Roll one or more dice with advantage or disadvantage PARAMETERS
_numOfDice
(int) required | specify how many dices to roll_numOfResults
(int) required | specify how many of rolled dices will be in the final result_advantage
(bool) optional | true = discriminate against low values / false = discriminate against high values_numOfSides
(int) optional | specify the side count of each dice
Roll a dice with custom sides PARAMETERS
_customDice
(Dicebag.Dice.CustomDice) required | specify a custom dice to use_numOfDice
(int) optional | specify how many dices to roll
Custom dice containing an array of Dicebag.Dice.DieSide
PARAMETERS
_sides
(Dicebag.Dice.DieSide[]) required | array of Dicebag.Dice.DieSide to use for the Die
Custom DiceSide used for creating CustomDices PARAMETERS
_weight
(float) required | weight is used to determine how likely it is to roll this DieSide_value
(int) required | value of the DieSide given when rolled
A bag of green (success) and red (fail) "marbles" that you can draw from. PARAMETERS
_successCount
(int) required | number of green marbles_failCount
(int) required | number of red marbles_resetOnSuccess
(bool) required | true = refill the MarbleBag when green marble is picked
Draw a marble from marble bag. Returns true if marble is green and false if marble is red.
Reset marbles in the bag
A rollable table where entries are removed as they are rolled PARAMETERS
_tableItems
(Dicebag.RotaingTableItem[]) required | array of RotatingTableItems
Roll a value from a rollable table. Returns the value specified in the table.
Reset table's items to the original ones
PARAMETERS
_weight
(float) required | value used to determine how likely it is to roll this item_value
(int) required | value given when rolled_resetOnRoll
(bool) required | true = reset the table's items when this item is rolled