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 the modifier limit or ctx.limits.maxIterations times per initial die (default 1000 generations). :amount generates that many children per match, visited depth-first. At the per-die generation limit the last extra roll is retained even if it matches. If the per-pool generated-roll budget is spent, pending branches stop and only dice that actually generated children are flagged as triggers.
explodeMatchingBatchHandler!m: repeats a complete batch when every die in it has the same value and the optional compare point matches. An optional failure compare point is checked first and zeroes accumulated scoring. Limits count additional batches and are capped by ctx.limits.maxIterations.
keepHandlerk, kh, kl: keeps the highest / lowest qty items, and drops the rest (flag drop). k defaults to highest.
mapHandlermap(expression): evaluates the expression once for each supplied item.
maxHandlermax5: lowers rolls above the value to the value (flag max).
minHandlermin2: raises rolls below the value to the value (flag min).
reRollHandlerr, ro and numeric limits: re-roll rolls that match the compare point (the die's min by default). :amount replaces each match with that many children, visited depth-first. A single replacement retains the original initial value; branching children retain their own.
sortHandlers, sa, sd: sorts the items by value, ascending or descending. s defaults to ascending.
targetHandler>=8, >=8:2f<=2: counts weighted successes and failures.
uniqueHandleru, uo and numeric limits: re-roll 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