Difference between revisions of "Dice"

From DiceRoller Documentation
m (Skizzerz moved page API/Dice to Dice without leaving a redirect: redo page layout)
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{APIdoc|Dice Namespace}}
 
{{APIdoc|Dice Namespace}}
The Dice namespace contains the base objects interacted with in the library. It is generally not needed to make use of the [[API/Dice/AST|Dice.AST]] or [[API/Dice/Grammar|Dice.Grammar]] namespaces in the course of normal interaction. However, advanced use cases may need to directly access objects in those namespaces.
+
The Dice namespace contains the base objects interacted with in the library. It is generally not needed to make use of the [[Dice/AST|Dice.AST]] or [[Dice/Grammar|Dice.Grammar]] namespaces in the course of normal interaction. However, advanced use cases may need to directly access objects in those namespaces.
 +
 
 +
The [[Dice/PbP|Dice.PbP]] namespace is useful if you need to keep track of multiple rolls in a play-by-post environment.
  
 
== Classes ==
 
== Classes ==
Line 7: Line 9:
 
! Class !! Description
 
! Class !! Description
 
|-
 
|-
| {{public}} {{class}} || [[API/DiceException|DiceException]] || The exception that is thrown whenever an error happens while evaluating a dice expression. This is used to signify an issue with the expression itself rather than any programming error.
+
| {{public}} {{static}} {{class}} || [[Dice/BuiltinFunctions|BuiltinFunctions]] || Contains callbacks for all built-in functions. These functions are automatically registered whenever constructing a new [[Dice/RollerConfig|RollerConfig]] object, but can be removed from the function registry if desired.
 +
|-
 +
| {{public}} {{static}} {{class}} || [[Dice/BuiltinMacros|BuiltinMacros]] || Contains callbacks for all built-in macros. These macros are automatically registered whenever constructing a new [[Dice/RollerConfig|RollerConfig]] object, but can be removed from the macro registry if desired.
 +
|-
 +
| {{public}} {{class}} || [[Dice/DiceException|DiceException]] || The exception that is thrown whenever an error happens while evaluating a dice expression. This is used to signify an issue with the expression itself rather than any programming error.
 +
|-
 +
| {{public}} {{class}} || [[Dice/DiceFunctionAttribute|DiceFunctionAttribute]] || An attribute that can be applied to methods which denotes the method is a valid [[Dice/FunctionCallback|FunctionCallback]]. The [[Dice/FunctionRegistry/RegisterType|FunctionRegistry.RegisterType]] function can be used to register types which contain methods marked with this attribute.
 +
|-
 +
| {{public}} {{class}} || [[Dice/DiceMacroAttribute|DiceMacroAttribute]] || An attribute that can be applied to methods which denotes the method is a valid {{l|MacroCallback}}. The {{l|MacroRegistry.RegisterType}} function can be used to register types which contain methods marked with this attribute.
 +
|-
 +
| {{internal}} {{static}} {{class}} || [[Dice/ExtensionMethods|ExtensionMethods]] || Internal extension methods that are not useful for general consumption.
 +
|-
 +
| {{public}} {{class}} || [[Dice/FunctionContext|FunctionContext]] || Contains the context for a function call, and is passed to function callbacks.
 
|-
 
|-
| {{public}} {{class}} || [[API/DiceFunctionAttribute|DiceFunctionAttribute]] || An attribute that can be applied to methods which denotes the method is a valid [[API/FunctionCallback|FunctionCallback]]. The [[API/FunctionRegistry/RegisterType|FunctionRegistry.RegisterType]] function can be used to register types which contain methods marked with this attribute.
+
| {{public}} {{class}} || [[Dice/FunctionRegistry|FunctionRegistry]] || Allows the user to register callbacks for functions.
 
|-
 
|-
| {{internal}} {{static}} {{class}} || [[API/ExtensionMethods|ExtensionMethods]] || Internal extension methods that are not useful for general consumption.
+
| {{public}} {{class}} || [[/MacroRegistry|MacroRegistry]] || Allows the user to register callbacks for macros.
 
|-
 
|-
| {{public}} {{class}} || [[API/FunctionContext|FunctionContext]] || Contains the context for a function call, and is passed to function callbacks.
+
| {{internal}} {{class}} || [[Dice/InternalContext|InternalContext]] || Opaque contextual information used when evaluating dice expressions.
 
|-
 
|-
| {{public}} {{static}} {{class}} || [[API/FunctionRegistry|FunctionRegistry]] || Allows the user to register callbacks for functions.
+
| {{public}} {{class}} || [[Dice/MacroContext|MacroContext]] || Contains the context for a macro, and is passed to macro callbacks.
 
|-
 
|-
| {{public}} {{class}} || [[API/MacroContext|MacroContext]] || Contains the context for a macro, and is passed to macro callbacks.
+
| {{public}} {{class}} || [[Dice/RollData|RollData]] || Holds data relevant to the scope of a single roll (as opposed to the global scope of RollerConfig).
 
|-
 
|-
| {{public}} {{static}} {{class}} || [[API/Roller|Roller]] || Exposes a function to roll a dice expression.
+
| {{public}} {{static}} {{class}} || [[Dice/Roller|Roller]] || Exposes a function to roll a dice expression.
 
|-
 
|-
| {{public}} {{class}} || [[API/RollerConfig|RollerConfig]] || Contains the configuration for a particular roll.
+
| {{public}} {{class}} || [[Dice/RollerConfig|RollerConfig]] || Contains the configuration for a particular roll.
 
|-
 
|-
| {{public}} {{class}} || [[API/RollResult|RollResult]] || Contains the result of a roll expression.
+
| {{public}} {{class}} || [[Dice/RollResult|RollResult]] || Contains the result of a roll expression.
 
|}
 
|}
  
Line 31: Line 45:
 
! Structure !! Description
 
! Structure !! Description
 
|-
 
|-
| {{public}} {{struct}} || [[API/DieResult|DieResult]] || Contains the result of an individual die.
+
| {{public}} {{struct}} || [[Dice/DieResult|DieResult]] || Contains the result of an individual die.
 
|}
 
|}
  
Line 39: Line 53:
 
! Delegate !! Description
 
! Delegate !! Description
 
|-
 
|-
| {{public}} {{delegate}} || [[API/FunctionCallback|FunctionCallback]] || Encapsulates a method which executes function logic.
+
| {{public}} {{delegate}} || [[Dice/FunctionCallback|FunctionCallback]] || Encapsulates a method which executes function logic.
 
|-
 
|-
| {{public}} {{delegate}} || [[API/MacroCallback|MacroCallback]] || Encapsulates a method which executes macro logic.
+
| {{public}} {{delegate}} || [[Dice/MacroCallback|MacroCallback]] || Encapsulates a method which executes macro logic.
 
|}
 
|}
  
Line 49: Line 63:
 
! Enumeration !! Description
 
! Enumeration !! Description
 
|-
 
|-
| {{public}} {{enum}} || [[API/DiceErrorCode|DiceErrorCode]] || Signifies what specific error happened when a [[API/DiceException|DiceException]] is thrown. This can be used to deliver more user-friendly error messages to the user instead of the error messages created by DiceException without needing to resort to string parsing.
+
| {{public}} {{enum}} || [[Dice/DiceErrorCode|DiceErrorCode]] || Signifies what specific error happened when a [[Dice/DiceException|DiceException]] is thrown. This can be used to deliver more user-friendly error messages to the user instead of the error messages created by DiceException without needing to resort to string parsing.
 +
|-
 +
| {{public}} {{enum}} || [[Dice/DieFlags|DieFlags]] || Metadata attached to a [[Dice/DieResult|DieResult]]. This metadata is not used internally, but may be useful to expose to the end user by changing how die results are displayed appropriately.
 
|-
 
|-
| {{public}} {{enum}} || [[API/DieFlags|DieFlags]] || Metadata attached to a [[API/DieResult|DieResult]]. This metadata is not used internally, but may be useful to expose to the end user by changing how die results are displayed appropriately.
+
| {{public}} {{enum}} || [[Dice/DieType|DieType]] || Indicates what type of die was rolled for a DieResult.
 
|-
 
|-
| {{public}} {{enum}} || [[API/DieType|DieType]] || Indicates what type of die was rolled for a DieResult.
+
| {{public}} {{enum}} || [[Dice/FunctionScope|FunctionScope]] || When registering a function, this indicates what scopes the function should be registered to. When a [[Dice/FunctionCallback|FunctionCallback]] is called, this will indicate the scope from which the function was called from.
 
|-
 
|-
| {{public}} {{enum}} || [[API/FunctionScope|FunctionScope]] || When registering a function, this indicates what scopes the function should be registered to. When a [[API/FunctionCallback|FunctionCallback]] is called, this will indicate the scope from which the function was called from.
+
| {{public}} {{enum}} || [[Dice/FunctionTiming|FunctionTiming]] || When registering a function, this indicates when this function is called in the evaluation of extras and functions.
 
|-
 
|-
| {{public}} {{enum}} || [[API/FunctionTiming|FunctionTiming]] || When registering a function, this indicates when this function is called in the evaluation of extras and functions.
+
| {{public}} {{enum}} || [[Dice/ResultType|ResultType]] || Indicates whether a RollResult's Value represents the total of the roll or the number of successes.
 
|-
 
|-
| {{public}} {{enum}} || [[API/SpecialDie|SpecialDie]] || Some DieResults indicate that they are special dice rather than actual rolls. This enumeration indicates what type of special die the result is. Special dice are used as guidance for display, such as open/close parenthesis when nested math expressions are rolled so that the user can see the dice displayed in the same format as they were specified.
+
| {{public}} {{enum}} || [[Dice/SpecialDie|SpecialDie]] || Some DieResults indicate that they are special dice rather than actual rolls. This enumeration indicates what type of special die the result is. Special dice are used as guidance for display, such as open/close parenthesis when nested math expressions are rolled so that the user can see the dice displayed in the same format as they were specified.
 
|}
 
|}

Latest revision as of 18:04, 23 December 2018

The Dice namespace contains the base objects interacted with in the library. It is generally not needed to make use of the Dice.AST or Dice.Grammar namespaces in the course of normal interaction. However, advanced use cases may need to directly access objects in those namespaces.

The Dice.PbP namespace is useful if you need to keep track of multiple rolls in a play-by-post environment.

Classes

Class Description
S BuiltinFunctions Contains callbacks for all built-in functions. These functions are automatically registered whenever constructing a new RollerConfig object, but can be removed from the function registry if desired.
S BuiltinMacros Contains callbacks for all built-in macros. These macros are automatically registered whenever constructing a new RollerConfig object, but can be removed from the macro registry if desired.
DiceException The exception that is thrown whenever an error happens while evaluating a dice expression. This is used to signify an issue with the expression itself rather than any programming error.
DiceFunctionAttribute An attribute that can be applied to methods which denotes the method is a valid FunctionCallback. The FunctionRegistry.RegisterType function can be used to register types which contain methods marked with this attribute.
DiceMacroAttribute An attribute that can be applied to methods which denotes the method is a valid MacroCallback. The MacroRegistry.RegisterType function can be used to register types which contain methods marked with this attribute.
S ExtensionMethods Internal extension methods that are not useful for general consumption.
FunctionContext Contains the context for a function call, and is passed to function callbacks.
FunctionRegistry Allows the user to register callbacks for functions.
MacroRegistry Allows the user to register callbacks for macros.
InternalContext Opaque contextual information used when evaluating dice expressions.
MacroContext Contains the context for a macro, and is passed to macro callbacks.
RollData Holds data relevant to the scope of a single roll (as opposed to the global scope of RollerConfig).
S Roller Exposes a function to roll a dice expression.
RollerConfig Contains the configuration for a particular roll.
RollResult Contains the result of a roll expression.

Structures

Structure Description
DieResult Contains the result of an individual die.

Delegates

Delegate Description
FunctionCallback Encapsulates a method which executes function logic.
MacroCallback Encapsulates a method which executes macro logic.

Enumerations

Enumeration Description
DiceErrorCode Signifies what specific error happened when a DiceException is thrown. This can be used to deliver more user-friendly error messages to the user instead of the error messages created by DiceException without needing to resort to string parsing.
DieFlags Metadata attached to a DieResult. This metadata is not used internally, but may be useful to expose to the end user by changing how die results are displayed appropriately.
DieType Indicates what type of die was rolled for a DieResult.
FunctionScope When registering a function, this indicates what scopes the function should be registered to. When a FunctionCallback is called, this will indicate the scope from which the function was called from.
FunctionTiming When registering a function, this indicates when this function is called in the evaluation of extras and functions.
ResultType Indicates whether a RollResult's Value represents the total of the roll or the number of successes.
SpecialDie Some DieResults indicate that they are special dice rather than actual rolls. This enumeration indicates what type of special die the result is. Special dice are used as guidance for display, such as open/close parenthesis when nested math expressions are rolled so that the user can see the dice displayed in the same format as they were specified.