new ItemDatabase()
- Description:
Specialized database for storing and querying game items with rarity-based selection. Extends RarityDatabase to provide item-specific filtering and search capabilities.
This class uses a specific parser when configuration data is added via the
addmethod. The format is as follows:name1; name2!valueRarityEnc!tag1 tag2 tag3 ...One or more names in the first position should be separated with semicolons. The valueRarityEnc value should be in the format
#r#, e.g.50c5for a value of 50, common rarity, and encumbrance of 5. Finally there can be one or more tags in the final position, that must follow theitem.schema.data.
- Source:
Extends
Methods
findAll(optionsopt) → {Array.<Item>}
- Description:
Finds all items matching the specified criteria.
- Source:
- Overrides:
Example
itemDb.findAll({ tags: "weapon sword", minValue: 10, maxValue: 100 });
Parameters:
| Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
{}
|
Search criteria Properties
|
Returns:
Array of matching Item objects
- Type
- Array.<Item>
findOne(optionsopt) → {Item|null}
- Description:
Finds a single random item matching the specified criteria, weighted by rarity (rare items are less likely to be selected).
- Source:
- Overrides:
Example
itemDb.findOne({ tags: "weapon", minValue: 5 });
Parameters:
| Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
{}
|
Search criteria Properties
|
Returns:
A random matching Item object, or null if none found
- Type
- Item | null