Difference between revisions of "Dice/Roller"

From DiceRoller Documentation
m
 
(8 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
Provides a Roll method to perform dice rolls.
 
Provides a Roll method to perform dice rolls.
  
* '''Namespace:''' [[API/Dice|Dice]]
+
{{ns}}
* '''Assembly:''' DiceRoller (in DiceRoller.dll)
 
  
 
== Inheritance Hierarchy ==
 
== Inheritance Hierarchy ==
Line 16: Line 15:
 
== Constructors ==
 
== Constructors ==
 
{| class="wikitable"
 
{| class="wikitable"
! !! Name !! Description
+
! style="width: 5em" |
 +
! Name !! Description
 
|-
 
|-
| {{static}} {{method}} || [[API/Roller/Roller|Roller()]] || Static constructor which initializes DefaultConfig.
+
| {{static}} {{method}} || [[Dice/Roller/Roller|Roller()]] || Static constructor which initializes DefaultConfig.
 
|}
 
|}
  
 
== Properties ==
 
== Properties ==
 
{| class="wikitable"
 
{| class="wikitable"
! !! Name !! Description
+
! style="width: 5em" |
 +
! Name !! Description
 
|-
 
|-
| {{public}} {{static}} {{property}} || [[API/Roller/DefaultConfig|DefaultConfig]] || Gets or sets the default roller configuration.
+
| {{public}} {{static}} {{property}} || [[Dice/Roller/DefaultConfig|DefaultConfig]] || Gets or sets the default roller configuration.
 
|}
 
|}
  
 
== Methods ==
 
== Methods ==
 
{| class="wikitable"
 
{| class="wikitable"
! !! Name !! Description
+
! style="width: 5em" |
 +
! Name !! Description
 
|-
 
|-
| {{public}} {{static}} {{method}} || [[API/Roller/Roll|Roll(String, RollerConfig)]] || Rolls dice according to the string expression and an optional config.
+
| {{public}} {{static}} {{method}} || [[/Average (String)|Average(String)]] || Evaluates the string expression, using the default configuration and fixing all dice to their average value.
 +
|-
 +
| {{public}} {{static}} {{method}} || [[/Average (String, RollerConfig)|Average(String, RollerConfig)]] || Evaluates the string expression, using the specified configuration and fixing all dice to their average value.
 +
|-
 +
| {{public}} {{static}} {{method}} || [[/Average (String, RollerConfig, RollData)|Average(String, RollerConfig, RollData)]] || Evaluates the string expression, using the specified configuration and {{l|Dice.RollData|RollData}} and fixing all dice to their average value.
 +
|-
 +
| {{internal}} {{static}} {{method}} || [[/Parse|Parse(String, RollerConfig)]] || Parses the diceExpr into an AST without evaluating it.
 +
|-
 +
| {{public}} {{static}} {{method}} || [[/Max (String)|Max(String)]] || Evaluates the string expression, using the default configuration and fixing all dice to their maximum value.
 +
|-
 +
| {{public}} {{static}} {{method}} || [[/Max (String, RollerConfig)|Max(String, RollerConfig)]] || Evaluates the string expression, using the specified configuration and fixing all dice to their maximum value.
 +
|-
 +
| {{public}} {{static}} {{method}} || [[/Max (String, RollerConfig, RollData)|Max(String, RollerConfig, RollData)]] || Evaluates the string expression, using the specified configuration and {{l|Dice.RollData|RollData}} and fixing all dice to their maximum value.
 +
|-
 +
| {{public}} {{static}} {{method}} || [[/Min (String)|Min(String)]] || Evaluates the string expression, using the default configuration and fixing all dice to their minimum value.
 +
|-
 +
| {{public}} {{static}} {{method}} || [[/Min (String, RollerConfig)|Min(String, RollerConfig)]] || Evaluates the string expression, using the specified configuration and fixing all dice to their minimum value.
 +
|-
 +
| {{public}} {{static}} {{method}} || [[/Min (String, RollerConfig, RollData)|Min(String, RollerConfig, RollData)]] || Evaluates the string expression, using the specified configuration and {{l|Dice.RollData|RollData}} and fixing all dice to their minimum value.
 +
|-
 +
| {{public}} {{static}} {{method}} || [[/Roll (String)|Roll(String)]] || Rolls dice according to the string expression, using the default configuration.
 +
|-
 +
| {{public}} {{static}} {{method}} || [[/Roll (String, RollerConfig)|Roll(String, RollerConfig)]] || Rolls dice according to the string expression and configuration.
 +
|-
 +
| {{public}} {{static}} {{method}} || [[/Roll (String, RollerConfig, RollData)|Roll(String, RollerConfig, RollData)]] || Rolls dice according to the string expression and configuration and with the given {{l|Dice.RollData|RollData}}.
 +
|-
 +
| {{internal}} {{static}} {{method}} || [[/Roll (DiceAST, RollerConfig)|Roll(DiceAST, RollerConfig)]] || Evaluates the root of the tree, returning the RollResult.
 
|}
 
|}
  
Line 39: Line 67:
  
 
== Thread Safety ==
 
== Thread Safety ==
The DefaultConfig property is not thread safe. Calling Roll with a {{cs|null}} [[API/RollerConfig|RollerConfig]] will make use of the DefaultConfig property. To be thread safe, call Roll with a RollerConfig that was created just for that thread.
+
The DefaultConfig property is not thread safe. Calling Roll with a {{cs|null}} [[Dice/RollerConfig|RollerConfig]] will make use of the DefaultConfig property. To be thread safe, call Roll with a RollerConfig that was created just for that thread.

Latest revision as of 20:16, 23 December 2018

Provides a Roll method to perform dice rolls.

  • Namespace: Dice
  • Assembly: DiceRoller (in DiceRoller.dll)

Inheritance Hierarchy

System.Object

Dice.Roller

Syntax

public static class Roller

Constructors

Name Description
S Roller() Static constructor which initializes DefaultConfig.

Properties

Name Description
S DefaultConfig Gets or sets the default roller configuration.

Methods

Name Description
S Average(String) Evaluates the string expression, using the default configuration and fixing all dice to their average value.
S Average(String, RollerConfig) Evaluates the string expression, using the specified configuration and fixing all dice to their average value.
S Average(String, RollerConfig, RollData) Evaluates the string expression, using the specified configuration and RollData and fixing all dice to their average value.
S Parse(String, RollerConfig) Parses the diceExpr into an AST without evaluating it.
S Max(String) Evaluates the string expression, using the default configuration and fixing all dice to their maximum value.
S Max(String, RollerConfig) Evaluates the string expression, using the specified configuration and fixing all dice to their maximum value.
S Max(String, RollerConfig, RollData) Evaluates the string expression, using the specified configuration and RollData and fixing all dice to their maximum value.
S Min(String) Evaluates the string expression, using the default configuration and fixing all dice to their minimum value.
S Min(String, RollerConfig) Evaluates the string expression, using the specified configuration and fixing all dice to their minimum value.
S Min(String, RollerConfig, RollData) Evaluates the string expression, using the specified configuration and RollData and fixing all dice to their minimum value.
S Roll(String) Rolls dice according to the string expression, using the default configuration.
S Roll(String, RollerConfig) Rolls dice according to the string expression and configuration.
S Roll(String, RollerConfig, RollData) Rolls dice according to the string expression and configuration and with the given RollData.
S Roll(DiceAST, RollerConfig) Evaluates the root of the tree, returning the RollResult.

Remarks

The Roller class is the main entry point to the library, and allows you to roll dice according to a given dice expression. To customize various aspects of a roll, a configuration can be passed in.

Thread Safety

The DefaultConfig property is not thread safe. Calling Roll with a null RollerConfig will make use of the DefaultConfig property. To be thread safe, call Roll with a RollerConfig that was created just for that thread.