Options
All
• Public
• Public/Protected
• All

# Class FateDie

A type of DiceTerm used to represent a three-sided Fate/Fudge die. Mathematically behaves like 1d3-2

## Constructors

• new FateDie(termData: any): FateDie

## Properties

faces: number

The number of faces on the die

number: number

The number of dice of this term to roll, before modifiers are applied

modifiers: string[]

An Array of dice term modifiers which are applied

results: DiceTermResult[]

The array of dice term results which have been rolled

_evaluated: boolean

An internal flag for whether the term has been evaluated

options: any

An object of additional options which describes and modifies the term.

isIntermediate: boolean = false

Is this term intermediate, and should be evaluated first as part of the simplification process?

DENOMINATION: string = "f"

Define the denomination string used to register this DiceTerm type in CONFIG.Dice.terms

MODIFIERS: { r: ((modifier: string, recursive?: boolean) => boolean | void); rr: ((modifier: any) => boolean | void); k: ((modifier: string) => boolean); kh: ((modifier: string) => boolean); kl: ((modifier: string) => boolean); d: ((modifier: string) => boolean); dh: ((modifier: string) => boolean); dl: ((modifier: string) => boolean) } = ...

Define the named modifiers that can be applied for this particular DiceTerm type.

#### Type declaration

• ##### r: ((modifier: string, recursive?: boolean) => boolean | void)
• (modifier: string, recursive?: boolean): boolean | void
• Re-roll the Die, rolling additional results for any values which fall within a target set. If no target number is specified, re-roll the lowest possible result.

20d20r reroll all 1s 20d20r1 reroll all 1s 20d20r=1 reroll all 1s 20d20r1=1 reroll a single 1

#### Parameters

• ##### modifier: string

The matched modifier query

• ##### recursive: boolean = {}

Reroll recursively, continuing to reroll until the condition is no longer met

#### Returns boolean | void

False if the modifier was unmatched

• ##### rr: ((modifier: any) => boolean | void)
• (modifier: any): boolean | void
• see

{@link Die#reroll}

#### Returns boolean | void

• ##### k: ((modifier: string) => boolean)
• (modifier: string): boolean
• Keep a certain number of highest or lowest dice rolls from the result set.

20d20k Keep the 1 highest die 20d20kh Keep the 1 highest die 20d20kh10 Keep the 10 highest die 20d20kl Keep the 1 lowest die 20d20kl10 Keep the 10 lowest die

#### Parameters

• ##### modifier: string

The matched modifier query

#### Returns boolean

• ##### kh: ((modifier: string) => boolean)
• (modifier: string): boolean
• Keep a certain number of highest or lowest dice rolls from the result set.

20d20k Keep the 1 highest die 20d20kh Keep the 1 highest die 20d20kh10 Keep the 10 highest die 20d20kl Keep the 1 lowest die 20d20kl10 Keep the 10 lowest die

#### Parameters

• ##### modifier: string

The matched modifier query

#### Returns boolean

• ##### kl: ((modifier: string) => boolean)
• (modifier: string): boolean
• Keep a certain number of highest or lowest dice rolls from the result set.

20d20k Keep the 1 highest die 20d20kh Keep the 1 highest die 20d20kh10 Keep the 10 highest die 20d20kl Keep the 1 lowest die 20d20kl10 Keep the 10 lowest die

#### Parameters

• ##### modifier: string

The matched modifier query

#### Returns boolean

• ##### d: ((modifier: string) => boolean)
• (modifier: string): boolean
• Drop a certain number of highest or lowest dice rolls from the result set.

20d20d Drop the 1 lowest die 20d20dh Drop the 1 highest die 20d20dl Drop the 1 lowest die 20d20dh10 Drop the 10 highest die 20d20dl10 Drop the 10 lowest die

#### Parameters

• ##### modifier: string

The matched modifier query

#### Returns boolean

• ##### dh: ((modifier: string) => boolean)
• (modifier: string): boolean
• Drop a certain number of highest or lowest dice rolls from the result set.

20d20d Drop the 1 lowest die 20d20dh Drop the 1 highest die 20d20dl Drop the 1 lowest die 20d20dh10 Drop the 10 highest die 20d20dl10 Drop the 10 lowest die

#### Parameters

• ##### modifier: string

The matched modifier query

#### Returns boolean

• ##### dl: ((modifier: string) => boolean)
• (modifier: string): boolean
• Drop a certain number of highest or lowest dice rolls from the result set.

20d20d Drop the 1 lowest die 20d20dh Drop the 1 highest die 20d20dl Drop the 1 lowest die 20d20dh10 Drop the 10 highest die 20d20dl10 Drop the 10 lowest die

#### Parameters

• ##### modifier: string

The matched modifier query

#### Returns boolean

MODIFIERS_REGEXP_STRING: string = "([^ (){}[\\]+\\-*/]+)"

A regular expression pattern which captures the full set of term modifiers Anything until a space, group symbol, or arithmetic operator

MODIFIER_REGEXP: RegExp = ...

A regular expression used to separate individual modifiers

REGEXP: RegExp = ...

A regular expression used to match a term of this type

SERIALIZE_ATTRIBUTES: string[] = ...

An array of additional attributes which should be retained when the term is serialized

FLAVOR_REGEXP_STRING: string = "(?:\\[([^\\]]+)\\])"

A regular expression pattern which identifies optional term-level flavor text

FLAVOR_REGEXP: RegExp = ...

A regular expression which identifies term-level flavor text

## Methods

• roll(__namedParameters?: { minimize: boolean; maximize: boolean }): { result: any; active: boolean }
• Roll the DiceTerm by mapping a random uniform draw against the faces of the dice term.

#### Parameters

• ##### __namedParameters: { minimize: boolean; maximize: boolean } = {}

Options which modify how a random result is produced

#### Returns { result: any; active: boolean }

The produced result

• ##### active: boolean
• getResultLabel(result: any): any
• Return a string used as the label for each rolled result

#### Parameters

• ##### result: any

The rolled result

#### Returns any

The result label

• alter(multiply: number, add: number): DiceTerm
• Alter the DiceTerm by adding or multiplying the number of dice which are rolled

#### Parameters

• ##### multiply: number

A factor to multiply. Dice are multiplied before any additions.

• ##### add: number

A number of dice to add. Dice are added after multiplication.

#### Returns DiceTerm

The altered term

• _evaluateSync(__namedParameters?: { minimize: boolean; maximize: boolean }): FateDie
• This method is temporarily factored out in order to provide different behaviors synchronous evaluation. This will be removed in 0.10.x

#### Returns FateDie

• Get the CSS classes that should be used to display each rolled result

#### Parameters

• ##### result: DiceTermResult

The rolled result

#### Returns string[]

The desired classes

• getTooltipData(): any
• Render the tooltip HTML for a Roll instance

#### Returns any

The data object used to render the default tooltip template for this DiceTerm

• evaluate([options={}]?: { minimize: boolean; maximize: boolean; async: boolean }): RollTerm
• Evaluate the term, processing its inputs and finalizing its total.

#### Parameters

• ##### [options={}]: { minimize: boolean; maximize: boolean; async: boolean } = {}

Options which modify how the RollTerm is evaluated

#### Returns RollTerm

The evaluated RollTerm

• toJSON(): any
• Serialize the RollTerm to a JSON string which allows it to be saved in the database or embedded in text. This method should return an object suitable for passing to the JSON.stringify function.

#### Returns any

• compareResult(result: number, comparison: string, target: number): boolean
• A helper comparison function. Returns a boolean depending on whether the result compares favorably against the target.

#### Parameters

• ##### result: number

The result being compared

• ##### comparison: string

The comparison operator in [=,<,<=,>,>=]

• ##### target: number

The target value

#### Returns boolean

Is the comparison true?

• _keepOrDrop(results: any[], number: number, __namedParameters?: boolean): any[]
• A helper method to modify the results array of a dice term by flagging certain results are kept or dropped.

#### Parameters

• ##### results: any[]

The results array

• ##### number: number

The number to keep or drop

#### Returns any[]

The modified results array

• _applyCount(results: any, comparison: any, target: any, __namedParameters?: { flagSuccess: boolean; flagFailure: boolean }): void
• A reusable helper function to handle the identification and deduction of failures

#### Returns void

• _applyDeduct(results: any, comparison: any, target: any, __namedParameters?: { deductFailure: boolean; invertFailure: boolean }): void
• A reusable helper function to handle the identification and deduction of failures

#### Returns void

• matchTerm(expression: string, [options={}]?: { imputeNumber: boolean }): RegExpMatchArray
• Determine whether a string expression matches this type of term

#### Parameters

• ##### expression: string

The expression to parse

• ##### [options={}]: { imputeNumber: boolean } = {}

Additional options which customize the match

#### Returns RegExpMatchArray

• fromMatch(match: RegExpMatchArray): DiceTerm
• Construct a term of this type given a matched regular expression array.

#### Parameters

• ##### match: RegExpMatchArray

The matched regular expression array

#### Returns DiceTerm

The constructed term

• Construct a RollTerm from a provided data object

#### Parameters

• ##### data: any

Provided data from an un-serialized term

#### Returns RollTerm

The constructed RollTerm

• Reconstruct a RollTerm instance from a provided JSON string

#### Parameters

• ##### json: string

A serialized JSON representation of a DiceTerm

#### Returns RollTerm

A reconstructed RollTerm from the provided JSON

• Define term-specific logic for how a de-serialized data object is restored as a functional RollTerm

#### Parameters

• ##### data: any

The de-serialized term data

#### Returns RollTerm

The re-constructed RollTerm object

## Accessors

• get expression(): string
• inheritdoc

#### Returns string

• get total(): number
• inheritdoc

#### Returns number

• get values(): number[]
• Return an array of rolled values which are still active within this term

#### Returns number[]

• get isDeterministic(): boolean
• inheritdoc

#### Returns boolean

• get formula(): string
• A string representation of the formula, including optional flavor text.

#### Returns string

• get flavor(): string
• Optional flavor text which modifies and describes this term.