Methods
addToSequence(props, id, alias)
- Description:
Add or append to a sequence in the props object. If a sequence with the given id exists, append the alias to its options. Otherwise, create a new sequence with the id and alias.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
props |
Object | The props object containing sequences |
id |
string | The sequence id (typically the type name) |
alias |
string | The alias to add to the sequence options |
(static) createAppearance(character) → {String}
- Description:
Describe a character's appearance and behavior. This description will be different each time the character is passed to this function.
- Source:
Example
createAppearance({ character })
=> "Long brown hair, short stature"
Parameters:
| Name | Type | Description |
|---|---|---|
character |
Character | The character to describe. |
Returns:
A description of the appearance and behavior of the character
- Type
- String
createBag(paramsopt) → {Bag}
- Description:
Creates a collection of objects, held in a collection type known as a Bag.
- Source:
Example
createBag({ count: 3, tags: "house"}).toString()
=> "A television (5/20), a winter jacket (worn; 0.5/10), and a ceramic bowl (3/1)."
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object |
<optional> |
Properties
|
Returns:
a bag containing items that meet the specified criteria
- Type
- Bag
createCharacter(options) → {Character}
- Description:
Creates a new character with customizable attributes and generated characteristics.
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Character creation options Properties
|
Returns:
A new Character instance with generated or specified attributes
- Type
- Character
createCharacterName(params) → {CharacterName}
- Description:
Generate a random name for a mid-century American, of the kind that would be wandering around an atomic era apocalypse. Does not add a nickname.
- Source:
Example
createCharacterName({gender: 'female', heritage: 'latino'})
=> {"given": "Elena", "family": "Silva", "gender": "female", "heritage": "latino"}
let girl = createCharacterName({gender: 'female'})
girl.toString()
=> "Ada King"
Parameters:
| Name | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object |
Properties
|
Returns:
- Type
- CharacterName
createKit(params) → {Object}
- Description:
Generate the possessions that would be on the person of an active NPC (e.g. out on patrol, out for a night on the town, out on a raid or in the middle of criminal activity).
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object |
Properties
|
Returns:
An object of two bags, one under the property "clothing" and another under the bag of "possessions".
- Type
- Object
createLocation()
- Description:
Create a location. You must supply the type of a location template and an instance tree will be created from that point in the template hierarchy, working downward throw all child nodes templates, returning the resulting instance tree. Tags are not currently used in selection of templates, but may be in the future.
- Source:
createMagazineTitle() → {String}
- Description:
Magazines will be produced as generic items in bags, loot, etc. This method returns a magazine with an auto-generated title, usually pretty silly. The titles are random so these magazines are not considered collectible.
- Source:
Returns:
magazine with a title
- Type
- String
findAll(optionsopt) → {Array.<Item>}
- Description:
Finds all items matching the specified criteria.
- Source:
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>
findAll(param) → {Array.<Model>}
- Description:
This returns all items that match regardless of rarity, or an empty array if none match.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
param |
* |
Returns:
all models that match
- Type
- Array.<Model>
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:
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
findOne(param) → {Model|null}
- Description:
This returns one random item that matches, respecting rarity.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
param |
* |
Returns:
a random matching model, or null if none found
- Type
- Model | null
idFilter(m, id) → {boolean}
- Description:
Filters models by ID.
- Source:
Example
models.filter(m => idFilter(m, "item123"));
Parameters:
| Name | Type | Description |
|---|---|---|
m |
Object | The model to test |
id |
* | The ID to match against (undefined means no filtering) |
Returns:
True if the model matches or no ID filter is specified
- Type
- boolean
namesFilter(m, name) → {boolean}
- Description:
Filters models by checking if a name exists in the model's names array.
- Source:
Example
models.filter(m => namesFilter(m, "John"));
Parameters:
| Name | Type | Description |
|---|---|---|
m |
Object | The model to test |
name |
string | The name to search for (undefined means no filtering) |
Returns:
True if the model contains the name or no name filter is specified
- Type
- boolean
tagFilter(m, tags) → {boolean}
- Description:
Filters models by tags using tag matching logic.
- Source:
Example
models.filter(m => tagFilter(m, "weapon firearm"));
Parameters:
| Name | Type | Description |
|---|---|---|
m |
Object | The model to test |
tags |
string | The tag filter string (undefined means no filtering) |
Returns:
True if the model matches or no tag filter is specified
- Type
- boolean
timeSeries(paramsopt) → {Array}
- Description:
Create a date series for periodicals, in the past.
- Source:
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
Object |
<optional> |
params Properties
|
Returns:
an array of string dates in the format 'Monday 2 Jan 1956'.
- Type
- Array
typeFilter(m, type) → {boolean}
- Description:
Filters models by type (case-insensitive).
- Source:
Example
models.filter(m => typeFilter(m, "weapon"));
Parameters:
| Name | Type | Description |
|---|---|---|
m |
Object | The model to test |
type |
string | The type to match against (undefined means no filtering) |
Returns:
True if the model matches or no type filter is specified
- Type
- boolean