Constructor
new Actors()
- Source:
- See:
-
- Actor The Actor entity.
- ActorDirectory All Actors which exist in the world are rendered within the ActorDirectory sidebar tab.
Example
Retrieve an existing Actor by its id
let actor = game.actors.get(actorId);
Extends
Members
(static) registeredSheets :Array.<ActorSheet>
- Source:
Return an Array of currently registered sheet classes for this Entity type
Type:
_source :Array.<object>
- Source:
- Overrides:
The source data is, itself, a mapping of IDs to data objects
Type:
- Array.<object>
apps :Array.<Application>
- Source:
- Overrides:
An Array of application references which will be automatically updated when the collection content changes
Type:
directory :SidebarDirectory|null
- Source:
- Overrides:
Return a reference to the SidebarDirectory application for this EntityCollection, or null if it has not yet been created.
Type:
- SidebarDirectory | null
entity :string
- Source:
- Overrides:
Return a reference to the base Entity name which is contained within this EntityCollection.
Type:
- string
entries
- Source:
- Overrides:
Return an Array of all the entry values in the Collection
name :string
- Source:
- Overrides:
The EntityCollection name
Type:
- string
object :Entity
- Source:
- Overrides:
Return a reference to the Entity subclass which should be used when creating elements of this EntityCollection. This should always be an explicit reference to the class which is used in this game to represent the entity, and not the base implementation of that entity type.
Type:
tokens :Object
- Source:
A mapping of synthetic Token Actors which are currently active within the viewed Scene. Each Actor is referenced by the Token.id.
Type:
- Object
Methods
(static) registerSheet()
- Source:
Register an Actor sheet class as a candidate which can be used to display Actors of a given type See EntitySheetConfig.registerSheet for details
Example
Register a new ActorSheet subclass for use with certain Actor types.
Actors.registerSheet("dnd5e", ActorSheet5eCharacter, { types: ["character"], makeDefault: true });
(static) unregisterSheet()
- Source:
Unregister an Actor sheet class, removing it from the list of avaliable sheet Applications to use See EntitySheetConfig.unregisterSheet for details
Example
Deregister the default ActorSheet subclass to replace it with others.
Actors.unregisterSheet("core", ActorSheet);
filter(condition) → {Array.<V>}
- Source:
- Overrides:
- See:
-
- {Array#filter}
Filter the Collection, returning an Array of entries which match a functional condition.
Example
let c = new Collection([["a", "AA"], ["b", "AB"], ["c", "CC"]]);
let hasA = c.filters(entry => entry.slice(0) === "A");
Parameters:
Name | Type | Description |
---|---|---|
condition |
function | The functional condition to test |
Returns:
An Array of matched values
- Type
- Array.<V>
find(condition) → {V|null}
- Source:
- Overrides:
- See:
-
- {Array#find}
Find an entry in the Map using an functional condition.
Example
let c = new Collection([["a", "A"], ["b", "B"], ["c", "C"]]);
let a = c.find(entry => entry === "A");
Parameters:
Name | Type | Description |
---|---|---|
condition |
function | The functional condition to test |
Returns:
The value, if found, otherwise null
- Type
- V | null
fromCompendium(data) → {Object}
- Source:
- Overrides:
Apply data transformations when importing an Entity from a Compendium pack
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | The original Compendium entry data |
Returns:
The processed data ready for Entity creation
- Type
- Object
get(key, strict) → {V|null}
- Source:
- Overrides:
Get an element from the Collection by its key.
Example
let c = new Collection([["a", "A"], ["b", "B"], ["c", "C"]]);
c.get("a"); // "A"
c.get("d"); // null
c.get("d", {strict: true}); // throws Error
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The key of the entry to retrieve |
strict |
boolean | Throw an Error if the requested id does not exist, otherwise return null. Default false |
Returns:
The retrieved entry value, if the key exists, otherwise null
- Type
- V | null
getName(name, strict) → {Entity|null}
- Source:
- Overrides:
Get an entry from the Collection by name. Use of this method assumes that the objects stored in the collection have a "name" attribute.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name of the entry to retrieve |
strict |
boolean | Throw an Error if the requested id does not exist, otherwise return null. Default false. |
Returns:
The retrieved Entity, if one was found, otherwise null;
- Type
- Entity | null
(async) importFromCollection(collection, entryId, updateDataopt, optionsopt) → {Promise.<Entity>}
- Source:
- Overrides:
Import an Entity from a compendium collection, adding it to the current World.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
collection |
string | The name of the pack from which to import |
|
entryId |
string | The ID of the compendium entry to import |
|
updateData |
Object |
<optional> |
Optional additional data used to modify the imported Entity before it is created |
options |
Object |
<optional> |
Optional arguments passed to the Entity.create method |
Returns:
A Promise containing the imported Entity
- Type
- Promise.<Entity>
insert(entity)
- Source:
- Overrides:
Add a new Entity to the EntityCollection, asserting that they are of the correct type.
Parameters:
Name | Type | Description |
---|---|---|
entity |
Entity | The entity instance to add to the collection |
map(transformer) → {Array.<V>}
- Source:
- Overrides:
Transform each element of the Collection into a new form, returning an Array of transformed values
Parameters:
Name | Type | Description |
---|---|---|
transformer |
function | The transformation function to apply to each entry value |
Returns:
An Array of transformed values
- Type
- Array.<V>
reduce(evaluator, initial) → {any}
- Source:
- Overrides:
- See:
-
- {Array#reduce}
Reduce the Collection by applying an evaluator function and accumulating entries
Example
let c = new Collection([["a", "A"], ["b", "B"], ["c", "C"]]);
let letters = c.reduce((s, l) => {
return s + l;
}, ""); // "ABC"
Parameters:
Name | Type | Description |
---|---|---|
evaluator |
function | A function which mutates the accumulator each iteration |
initial |
any | An initial value which accumulates with each iteration |
Returns:
The accumulated result
- Type
- any
remove(id)
- Source:
- Overrides:
Remove an Entity from the EntityCollection by its ID.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The entity ID which should be removed |
render() → {this}
- Source:
- Overrides:
Render any Applications associated with this EntityCollection
Returns:
A reference to the rendered EntityCollection
- Type
- this