Skip to content

@dice-roller/rpg-dice-roller / modifiers

modifiers ​

Modifier definitions, handlers, and registries for extending roll behavior.

Classes ​

ClassDescription
ModifierRegistryModifier handlers by name.

Interfaces ​

InterfaceDescription
ModifierHandlerThe behaviour of a modifier.
ModifierInputContext and modifier node supplied to a handler alongside its items.

Type Aliases ​

Type AliasDescription
ModifierHandlerOfThe handler for the modifier with the given name.
ModifierTargetWhat a modifier can be attached to.

Variables ​

VariableDescription
builtInModifierHandlersThe built-in handlers, in execution order. The array, handlers, and their target arrays are frozen.
criticalFailureHandlercf, cf<3: flags rolls matching the compare point (the die's min by default) as critical-failure.
criticalSuccessHandlercs, cs>18: flags rolls matching the compare point (the die's max by default) as critical-success.
dropHandlerd, dl, dh: drops the lowest / highest qty items (flag drop). d defaults to lowest.
explodeHandler!, !!, !p, !!p: rolls another die whenever a roll matches the compare point (the die's max by default), up to ctx.limits.maxIterations times per roll (default 1000). At the limit the last extra roll is retained even if it matches.
keepHandlerk, kh, kl: keeps the highest / lowest qty items, and drops the rest (flag drop). k defaults to highest.
maxHandlermax5: lowers rolls above the value to the value (flag max).
minHandlermin2: raises rolls below the value to the value (flag min).
reRollHandlerr, ro: re-rolls rolls that match the compare point (the die's min by default), replacing the value (the initial value is kept).
sortHandlers, sa, sd: sorts the items by value, ascending or descending. s defaults to ascending.
targetHandler>=8, >=8f<=2: counts successes and failures.
uniqueHandleru, uo: re-rolls rolls whose value an earlier roll already has (optionally only those matching the compare point), replacing the value (the initial value is kept). The first roll is never re-rolled.

Functions ​

FunctionDescription
matchesComparePointWhether the value matches the compare point, e.g. matchesComparePoint({ operator: ">=", value: 8 }, 9).

MIT Licensed · Credits