Class

YearZeroRoll

YearZeroRoll(formula, dataopt, optionsopt)

Custom Roll class for Year Zero games.

Constructor

# new YearZeroRoll(formula, dataopt, optionsopt)

Parameters:
Name Type Attributes Description
formula string

The string formula to parse

data Object <optional>

The data object against which to parse attributes within the formula

game GameTypeString <optional>

The game used

name string <optional>

The name of the roll

maxPush number <optional>

The maximum number of times the roll can be pushed

options Object <optional>

Additional data which is preserved in the database

game GameTypeString <optional>

The game used

name string <optional>

The name of the roll

maxPush number <optional>

The maximum number of times the roll can be pushed

yzur boolean <optional>

Forces the roll of a YearZeroRoll in Foundry

View Source yzur.js, line 1055

Extends

  • Roll

Members

number

# readonly ammoSpent

The sum of the ammo dice's values.

View Source yzur.js, line 1233

number

# readonly attributeTrauma

The quantity of traumas ("1" on base dice).

View Source yzur.js, line 1184

number

# readonly baneCount

The quantity of ones (banes).

View Source yzur.js, line 1169

number

# readonly baseSuccessQty

The total successes produced by base dice.

View Source yzur.js, line 1272

number

# readonly bestHitLocation

The best rolled hit location.

View Source yzur.js, line 1292

string

# readonly game

The game used.

View Source yzur.js, line 1087

number

# readonly gearDamage

The quantity of gear damage ("1" on gear dice).

View Source yzur.js, line 1193

number

# readonly hitCount

The quantity of successes on ammo dice.

View Source yzur.js, line 1244

Array.<number>

# readonly hitLocations

The rolled hit locations.

View Source yzur.js, line 1281

number

# readonly jamCount

The quantity of ones (banes) on base dice and ammo dice.

View Source yzur.js, line 1253

boolean

# readonly jammed

Tells if the roll caused a weapon jam.

View Source yzur.js, line 1263

number

# maxPush

The maximum number of pushes.

View Source yzur.js, line 1102

boolean

# readonly mishap

Tells if the roll is a mishap (double 1's).

Deprecated:
  • Yes

View Source yzur.js, line 1221

string

# readonly name

The name of the roll.

View Source yzur.js, line 1095

number

# readonly panic

The quantity of panic ("1" on stress dice).

View Source yzur.js, line 1211

boolean

# readonly pushable

Tells if the roll is pushable.

View Source yzur.js, line 1147

number

# readonly pushCount

The number of times the roll has been pushed.

View Source yzur.js, line 1129

boolean

# readonly pushed

Whether the roll was pushed or not.

View Source yzur.js, line 1138

number

# readonly size

The total number of dice in the roll.

View Source yzur.js, line 1120

number

# readonly stress

The quantity of stress dice.

View Source yzur.js, line 1202

number

# readonly successCount

The quantity of successes.

View Source yzur.js, line 1160

Methods

# static create(formula, dataopt, optionsopt) → {YearZeroRoll}

A factory method which constructs a Roll instance using the default configured Roll class.

Parameters:
Name Type Attributes Default Description
formula string

The formula used to create the Roll instance

data Object <optional>
{}

The data object which provides component data for the formula

options Object <optional>
{}

Additional options which modify or describe this Roll

See:

View Source yzur.js, line 1310

The constructed Roll instance

YearZeroRoll

# static createFromDiceQuantities()

Deprecated:
  • Yes

View Source yzur.js, line 1378

# static forge(dice, dataopt, optionsopt) → {YearZeroRoll}

Generates a roll based on the number of dice.

Parameters:
Name Type Attributes Default Description
dice TermBlok | Array.<TermBlok>

An array of objects that define the dice

data Object <optional>
{}

Additional data to forge the dice

title string <optional>

The name of the roll

yzGame GameTypeString <optional>

The game used

maxPush number <optional>
1

The maximum number of pushes

options Object <optional>

Additional data which is preserved in the database

View Source yzur.js, line 1327

YearZeroRoll

# static generateTermFormula(number, term, flavoropt, maxPushopt) → {string}

Creates a roll formula based on number of dice.

Parameters:
Name Type Attributes Default Description
number number

The quantity of those dice

term DieDeno

The denomination of the dice to create

flavor string <optional>

(optional) Any flavor tied to those dice

maxPush number <optional>
null

(optional) Special maxPush modifier but only for those dice

View Source yzur.js, line 1408

string

# async addDice(qty, type, rangeopt, valueopt, optionsopt) → {Promise.<YearZeroRoll>}

Adds a number of dice to the roll. Note: If a negative quantity is passed, instead it removes that many dice.

Parameters:
Name Type Attributes Default Description
qty number

The quantity to add

type DieTermString

The type of dice to add

range number <optional>
6

The number of faces of the die

value number <optional>

The predefined value for the new dice

options Object <optional>

Additional options that modify the term

View Source yzur.js, line 1517

This roll

Promise.<YearZeroRoll>

# count(type, seedopt, comparisonopt) → {number}

Counts the values of a certain type in the roll. If seed is omitted, counts all the dice of a certain type.

Parameters:
Name Type Attributes Default Description
type DieTypeString

The type of the die

seed number <optional>
null

The value to search, if any

comparison string <optional>
'='

The comparison to use against the seed: >, >=, <, <= or =

View Source yzur.js, line 1475

Total count

number

# duplicate() → {YearZeroRoll}

Creates a deep clone copy of the roll.

View Source yzur.js, line 1962

A copy of this roll instance

YearZeroRoll

# async getRollInfos(templateopt) → {Promise.<string>}

Renders the infos of a Year Zero roll.

Parameters:
Name Type Attributes Default Description
template string <optional>
null

The path to the template

View Source yzur.js, line 1854

Promise.<string>

# getTerms(search) → {Array.<YearZeroDie>|Array.<DiceTerm>}

Gets all the dice terms of a certain type or that match an object of values.

Parameters:
Name Type Description
search DieTypeString | Object

Die type to search or an object with comparison values

View Source yzur.js, line 1444

Array.<YearZeroDie> | Array.<DiceTerm>
Example
// Gets all terms with the type "skill".
let terms = getTerms('skill');

// Gets all terms that have exactly these specifications (it follows the structure of a DiceTerm).
let terms = getTerms({
  type: 'skill',
  number: 1,
  faces: 6,
  options: {
    flavor: 'Attack',
    // ...etc...
  },
  results: {
    result: 3,
    active: true,
    // ...etc...
  },
});

# async getTooltip() → {Promise.<string>}

Renders the tooltip HTML for a Roll instance.

See:

View Source yzur.js, line 1801

The rendered HTML tooltip as a string

Promise.<string>

# async modify(mod) → {Promise.<YearZeroRoll>}

Applies a difficulty modifier to the roll.

Parameters:
Name Type Default Description
mod number 0

Difficulty modifier (bonus or malus)

View Source yzur.js, line 1655

This roll, modified

Promise.<YearZeroRoll>

# async push(optionsopt) → {Promise.<YearZeroRoll>}

Pushes the roll, following the YZ rules.

Parameters:
Name Type Attributes Default Description
options Object <optional>
{}

Options which inform how the Roll is evaluated

View Source yzur.js, line 1629

The roll instance, pushed

Promise.<YearZeroRoll>

# removeDice(qty, search, discardopt, disableopt) → {YearZeroRoll}

Removes a number of dice from the roll.

Parameters:
Name Type Attributes Description
qty number

The quantity to remove

search DieTypeString | Object

The type of dice to remove, or an object of values for comparison

discard boolean <optional>

Whether the term should be marked as "discarded" instead of removed

disable boolean <optional>

Whether the term should be marked as "active: false" instead of removed

View Source yzur.js, line 1574

This roll

YearZeroRoll

# async render(chatOptionsopt) → {Promise.<string>}

Renders a Roll instance to HTML.

Parameters:
Name Type Attributes Description
chatOptions Object <optional>

An object configuring the behavior of the resulting chat message, which is also passed to the template

user string <optional>

The ID of the user that renders the roll

flavor string <optional>

The flavor of the message

template string <optional>

The path to the template that renders the roll

infosTemplate string <optional>

✨ The path to the template that renders the infos box under the roll tooltip

blind boolean <optional>

Whether this is a blind roll

isPrivate boolean <optional>

Whether this roll is private (displays sensitive infos with ??? instead)

See:
  • ✨ Extra features added by the override.
  • (FoundryVTT) Roll.render

View Source yzur.js, line 1881

Promise.<string>

# async toMessage(messageDataopt, optionsopt) → {Promise.<(ChatMessage|ChatMessageData)>}

Transform a Roll instance into a ChatMessage, displaying the roll result. This function can either create the ChatMessage directly, or return the data object that will be used to create.

Parameters:
Name Type Attributes Default Description
messageData Object <optional>

The data object to use when creating the message

user string <optional>

The ID of the user that sends the message

speaker Object <optional>

✨ The identified speaker data

content string <optional>

The HTML content of the message, overriden by the roll.render()'s returned content if left unchanged

type number <optional>
0

The type to use for the message from CONST.CHAT_MESSAGE_STYLES

sound string <optional>

The path to the sound played with the message (WAV format)

options options <optional>

Additional options which modify the created message.

rollMode string <optional>

The template roll mode to use for the message from CONFIG.Dice.rollModes

create boolean <optional>
true

Whether to automatically create the chat message, or only return the prepared chatData object.

See:
  • ✨ Extra features added by the override.
  • (FoundryVTT) Roll.toMessage

View Source yzur.js, line 1939

A promise which resolves to the created ChatMessage entity if create is true or the Object of prepared chatData otherwise.

Promise.<(ChatMessage|ChatMessageData)>