RarityDatabase

RarityDatabase

new RarityDatabase()

Description:
  • Database that supports rarity-based item selection using frequency weighting.

Source:

Extends

Members

models :Array

Description:
  • Array of models stored in the database.

Source:
Inherited From:

Array of models stored in the database.

Type:
  • Array

parser :function

Description:
  • Parser function used to process data before passing it to the model constructor

Source:
Inherited From:

Parser function used to process data before passing it to the model constructor

Type:
  • function

Methods

add(…data) → {Database}

Description:
  • Adds one or more data items to the database.

Source:
Inherited From:
Example
database.add(item1, item2, item3);
Parameters:
Name Type Attributes Description
data * <repeatable>

Data items to add to the database

Returns:

Returns this instance for method chaining

Type
Database

findAll(optionsopt) → {Array}

Description:
  • Finds all models that match the specified criteria. Subclasses may add additional search parameters, but all models support searching by tags.

Source:
Inherited From:
Example
database.findAll({ tags: "weapon firearm" });
Parameters:
Name Type Attributes Default Description
options Object <optional>
{}

Search criteria

Properties
Name Type Attributes Description
tags string <optional>

Tag filter string

Returns:

Array of matching models

Type
Array

findOne(optionsopt) → {*}

Description:
  • Finds a random model that matches the specified criteria. Subclasses may add additional search parameters, but all models support searching by tags.

Source:
Inherited From:
Example
database.findOne({ tags: "weapon firearm" });
Parameters:
Name Type Attributes Default Description
options Object <optional>
{}

Search criteria

Properties
Name Type Attributes Description
tags string <optional>

Tag filter string

Returns:

A random matching model, or undefined if none found

Type
*