Constructor
new Actors()
- See:
-
- Actor The Actor entity
- ActorDirectory The ActorDirectory sidebar directory
Example
Retrieve an existing Actor by its id
let actor = game.actors.get(actorId);
Extends
Members
(static) registeredSheets :Array.<ActorSheet>
Return an Array of currently registered sheet classes for this Entity type
Type:
apps :Array.<Application>
- Inherited From:
An Array of application references which will be automatically updated when the collection content changes
Type:
contents :Array.<*>
- Inherited From:
Return an Array of all the entry values in the Collection
Type:
- Array.<*>
directory :SidebarDirectory|null
- Inherited From:
Return a reference to the SidebarDirectory application for this WorldCollection, or null if it has not yet been created.
Type:
- SidebarDirectory | null
documentClass :function
- Inherited From:
A reference to the Document class definition which is contained within this DocumentCollection.
Type:
- function
name :string
- Inherited From:
The Collection class name
Type:
- string
tokens :Object.<string, Actor>
A mapping of synthetic Token Actors which are currently active within the viewed Scene. Each Actor is referenced by the Token.id.
Type:
- Object.<string, Actor>
Methods
(static) registerSheet()
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()
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);
_onCreateDocuments(documents, result, options, userId)
- Inherited From:
Follow-up actions taken after a set of Documents in this Collection are created.
Parameters:
Name | Type | Description |
---|---|---|
documents |
Array.<Document> | An Array of created Documents |
result |
Array.<object> | An Array of created data objects |
options |
object | Options which modified the creation operation |
userId |
string | The ID of the User who triggered the operation |
_onDeleteDocuments(documents, result, options, userId)
- Inherited From:
Follow-up actions taken after a set of Documents in this Collection are deleted.
Parameters:
Name | Type | Description |
---|---|---|
documents |
Array.<Document> | An Array of deleted Documents |
result |
Array.<object> | An Array of document IDs being deleted |
options |
object | Options which modified the deletion operation |
userId |
string | The ID of the User who triggered the operation |
_onUpdateDocuments(documents, result, options, userId)
- Inherited From:
Follow-up actions taken after a set of Documents in this Collection are updated.
Parameters:
Name | Type | Description |
---|---|---|
documents |
Array.<Document> | An Array of updated Documents |
result |
Array.<object> | An Array of incremental data objects |
options |
object | Options which modified the update operation |
userId |
string | The ID of the User who triggered the operation |
_preCreateDocuments(result, options, userId)
- Inherited From:
Preliminary actions taken before a set of Documents in this Collection are created.
Parameters:
Name | Type | Description |
---|---|---|
result |
Array.<object> | An Array of created data objects |
options |
object | Options which modified the creation operation |
userId |
string | The ID of the User who triggered the operation |
_preDeleteDocuments(result, options, userId)
- Inherited From:
Preliminary actions taken before a set of Documents in this Collection are deleted.
Parameters:
Name | Type | Description |
---|---|---|
result |
Array.<object> | An Array of document IDs being deleted |
options |
object | Options which modified the deletion operation |
userId |
string | The ID of the User who triggered the operation |
_preUpdateDocuments(result, options, userId)
- Inherited From:
Preliminary actions taken before a set of Documents in this Collection are updated.
Parameters:
Name | Type | Description |
---|---|---|
result |
Array.<object> | An Array of incremental data objects |
options |
object | Options which modified the update operation |
userId |
string | The ID of the User who triggered the operation |
delete()
- Inherited From:
filter(condition) → {Array.<*>}
- Inherited From:
- 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.<*>
find(condition) → {*}
- Inherited From:
- 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 undefined
- Type
- *
forEach(fn)
- Inherited From:
- See:
-
- Array#forEach
Apply a function to each element of the collection
Example
let c = new Collection([["a", {active: false}], ["b", {active: false}], ["c", {active: false}]]);
c.forEach(e => e.active = true);
Parameters:
Name | Type | Description |
---|---|---|
fn |
function | The function to apply |
fromCompendium(document) → {Object}
- Overrides:
Apply data transformations when importing a Document from a Compendium pack
Parameters:
Name | Type | Description |
---|---|---|
document |
Document | object | The source Document, or a plain data object |
Returns:
The processed data ready for world Document creation
- Type
- Object
get(key, optionsopt) → {*|undefined}
- Inherited From:
Get an element from the Collection by its key.
Example
let c = new Collection([["a", "Alfred"], ["b", "Bob"], ["c", "Cynthia"]]);
c.get("a"); // "Alfred"
c.get("d"); // undefined
c.get("d", {strict: true}); // throws Error
Parameters:
Name | Type | Attributes | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
key |
string | The key of the entry to retrieve |
|||||||||||
options |
object |
<optional> |
Additional options that affect how entries are retrieved Properties
|
Returns:
The retrieved entry value, if the key exists, otherwise undefined
- Type
- * | undefined
getName(name, optionsopt) → {*}
- Inherited From:
Get an entry from the Collection by name. Use of this method assumes that the objects stored in the collection have a "name" attribute.
Example
let c = new Collection([["a", "Alfred"], ["b", "Bob"], ["c", "Cynthia"]]);
c.getName("Alfred"); // "Alfred"
c.getName("D"); // undefined
c.getName("D", {strict: true}); // throws Error
Parameters:
Name | Type | Attributes | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | The name of the entry to retrieve |
|||||||||||
options |
object |
<optional> |
Additional options that affect how entries are retrieved Properties
|
Returns:
The retrieved entry value, if one was found, otherwise undefined
- Type
- *
(async) importFromCompendium(pack, id, updateDataopt, optionsopt) → {Promise.<Document>}
- Inherited From:
Import a Document from a Compendium collection, adding it to the current World.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
pack |
CompendiumCollection | The CompendiumCollection instance from which to import |
|
id |
string | The ID of the compendium entry to import |
|
updateData |
Object |
<optional> |
Optional additional data used to modify the imported Document before it is created |
options |
Object |
<optional> |
Optional arguments passed to the Document.create method |
Returns:
The imported Document instance
- Type
- Promise.<Document>
map(transformer) → {Array.<*>}
- Inherited From:
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.<*>
prepareForImport(data) → {object}
- Inherited From:
Prepare a document from an outside source for import into this collection.
Parameters:
Name | Type | Description |
---|---|---|
data |
object | The data to be prepared. |
Returns:
The prepared data.
- Type
- object
reduce(evaluator, initial) → {any}
- Inherited From:
- 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
render()
- Inherited From:
Render any Applications associated with this DocumentCollection.
set()
- Inherited From:
some(condition) → {boolean}
- Inherited From:
- See:
-
- {Array#some}
Test whether a condition is met by some entry in the Collection
Parameters:
Name | Type | Description |
---|---|---|
condition |
function | A test condition to apply to each entry |
Returns:
Was the test condition passed by at least one entry?
- Type
- boolean
toJSON() → {Array.<object>}
- Inherited From:
Convert the Collection to a primitive array of its contents.
Returns:
An array of contained values
- Type
- Array.<object>
(async) updateAll(transformation, condition, optionsopt) → {Promise.<Array.<Document>>}
- Inherited From:
Update all objects in this DocumentCollection with a provided transformation. Conditionally filter to only apply to Entities which match a certain condition.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
transformation |
function | object | An object of data or function to apply to all matched objects |
||
condition |
function | null |
null
|
A function which tests whether to target each object |
|
options |
object |
<optional> |
Additional options passed to Entity.update |
Returns:
An array of updated data once the operation is complete
- Type
- Promise.<Array.<Document>>