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:
- Overrides:
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(param) → {Array.<Model>}
- Description:
This returns all items that match regardless of rarity, or an empty array if none match.
- Source:
- Overrides:
Parameters:
| Name | Type | Description |
|---|---|---|
param |
* |
Returns:
all models that match
- Type
- Array.<Model>
findOne(param) → {Model|null}
- Description:
This returns one random item that matches, respecting rarity.
- Source:
- Overrides:
Parameters:
| Name | Type | Description |
|---|---|---|
param |
* |
Returns:
a random matching model, or null if none found
- Type
- Model | null