Global

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
Name Type Attributes Default Description
value Number | String <optional>
10

the total value of items to add to the bag. The method will get as close to this value as possible, but may go over. If the value is a string, it is treated as dice notation.

repeat Number <optional>
20

This is the percentage chance that the last item selected will be added again. Can range from 0% (no repeated items) to 100% (only one item, as many as are needed to reach the other specified limits).

count Number <optional>
Number.MAX_VALUE

affects how many items will be added to the bag. The bag will not exceed this number of items.

enc Number <optional>
Number.MAX_VALUE

the maximum encumbrance of the bag. The method will get as close to this value as possible, but may go over.

uncountable Boolean <optional>
false

if true, items in the bag are treated as uncountable.

minValue Number <optional>
0

the minimum value of any items added to the bag (for some applications, like store stock, it is desirable to set this number above 0).

tags String <optional>
"*"

tags that will be used to search for items to add to the bag.

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
Name Type Attributes Default Description
possessions string <optional>
"None"

Starting possessions or equipment (can be "None", "Walk-About", or "Traveling")

age number <optional>
roll("14+3d12")

Character age in years

traits Object <optional>
{}

Initial trait values (e.g., { Cunning: 2, Strong: 2 })

gender string <optional>

Character gender ("male" or "female"). If not provided, randomly selected.

heritage string <optional>

Character heritage ("latino" or "anglo" lead to specific names, but any heritage can be provided). If not provided, randomly selected.

name string <optional>

Character name. If not provided, a name is generated.

preProfession string | Object <optional>

Character pre-collapse profession/career. Can be a profession name string or profession object, selected from the values returned by the getPreProfessions function. The option ”soldier” will select a military branch as a pre-collapse profession.

postProfession string | Object <optional>

Character post-collapse profession/career. Can be a profession name string or profession object, selected from the values returned by the getPostProfessions function. The option ”soldier” will select a military branch as a post-collapse profession. If “soldier” is selected pre-and post-collapse, the same branch will be used for both.

isChild boolean <optional>
false

Whether to create a child character (affects age and training)

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
Name Type Description
gender String

'male' or 'female' name. Optional. If not specified, gender is 50/50.

heritage String

'anglo' or 'latino' (Optional. If not specified, 20% of names are Latino).

given String

set the given name to this name

family String

set the family name to this name

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
Name Type Attributes Description
profession String | Profession <optional>

profession name or instance

gender String <optional>

gender of character (male or female)

traveling Boolean <optional>

should this bag include extended equipment for exploring, and not just walk-abouts?

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
Name Type Attributes Default Description
name string <optional>

Name substring to match

tags string <optional>

Tag filter string

minValue number <optional>
0

Minimum item value

maxValue number <optional>
Number.MAX_VALUE

Maximum item value

minEnc number <optional>
0

Minimum encumbrance

maxEnc number <optional>
Number.MAX_VALUE

Maximum encumbrance

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
Name Type Attributes Default Description
name string <optional>

Name substring to match

tags string <optional>

Tag filter string

minValue number <optional>
0

Minimum item value

maxValue number <optional>
Number.MAX_VALUE

Maximum item value

minEnc number <optional>
0

Minimum encumbrance

maxEnc number <optional>
Number.MAX_VALUE

Maximum encumbrance

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
Name Type Attributes Default Description
period String <optional>
'weekly'

one of 'weekly', 'monthly', 'biweekly' or 'bimonthly'

dayOfWeek String <optional>

one of 'Saturday' to 'Sunday', if you want the dates to be adjusted to the next day of the week (for example if a periodical is always published on Mondays).

startDate String | Date <optional>
'1956-01-01'

a string (in format 'YYYY-MM-DD') or a date object that is the date on which the sequence will start.

endDate String | Date <optional>
'1958-07-14'

a string (in format 'YYYY-MM-DD') or a date object that is the date before which the sequence will end.

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