Skip to content

Introduction ​

API

The technical API is for people wanting to delve a bit deeper into the parts that make up the library.

Namespaces ​

NamespaceDescription
astExpression tree nodes and notation helpers for inspecting or constructing rolls.
diceDie definitions, presets, and registries for extending dice notation.
enginesRandom engines for controlling how dice are rolled.
errorsError classes raised while parsing, evaluating, and importing rolls.
modifiersModifier definitions, handlers, and registries for extending roll behavior.
presentersPresenters that format evaluated rolls and their results.
resultsResult types and helpers for inspecting evaluated expressions.

Classes ​

ClassDescription
EvaluatorWalks the AST and builds the result tree.
ParserParses dice notation into the AST.
RollOne evaluated notation: the result tree and its totals.
RollerRolls notation and keeps a history of the rolls.
RollHistoryA log of rolls.
RollSettingsResolved RollOptions, with the services built from them.

Interfaces ​

InterfaceDescription
EvaluatorRegistriesRegistries used to resolve dice and modifier handlers during evaluation.
HistoryDataA roll history.
NumberGeneratorGenerates numbers in a range from a RandomEngine.
ParserOptionsOptions for parsing notation.
PresenterTurns a roll, a roll history, or a result node into any output, e.g. text, HTML or Markdown.
RandomEngineA source of randomness.
RollContextEverything that changes per roll but isn't part of the notation.
RollDataA roll, with its result tree and totals.
RollLimitsSafety limits for a single roll.
RollOptionsHow notation is parsed, rolled and presented. Every option is optional.

Type Aliases ​

Type AliasDescription
DieLikeA range or faces definition with optional behaviour overrides.
EncodedThe data with every number (except literal ones, like version) as an EncodedNumber.
EncodedExportDataAnything that has been exported.
EncodedHistoryDataAn exported roll history: JSON-safe, with non-finite numbers tagged.
EncodedNumberA number in exported data: a finite number as it is, otherwise a tag, e.g. { "$number": "Infinity" }, so it survives JSON (which would turn it into null).
EncodedRollDataAn exported roll: JSON-safe, with non-finite numbers tagged.
ExportFormatA supported export format.
ExpressionNodeAny node that evaluates to a number.
ExpressionResultA result for an expression node; individual dice and group members are nested within it.
NonFiniteNumberThe tag names used for non-finite numbers.
PresentableA roll, history, or evaluated expression result; an individual die result is not presentable.
RollerOptionsOptions shared by all rolls made or imported by a roller.
RollModeHow dice are rolled.
TaggedDieResultA die result carrying an internal pool tag during flattened group modifier handling.

Variables ​

VariableDescription
EXPORT_FORMATS- object: plain JSON-safe data (EncodedRollData / EncodedHistoryData) - json: that data as a JSON string - base64: that JSON string, base64-encoded (UTF-8)
NON_FINITE_NUMBERSThe numbers JSON can't represent, by their tag.

Functions ​

FunctionDescription
rollShorthand for new Roll(input, options): rolls notation (or an AST) once, without a history.

MIT Licensed · Credits