Constructor
new Scenes()
- See:
-
- Scene The Scene document
- SceneDirectory The SceneDirectory sidebar directory
Extends
Members
active
Return a reference to the Scene which is currently active
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.<*>
current
Return the current Scene target. This is the viewed scene if the canvas is active, otherwise it is the currently active scene.
directory :SidebarDirectory
- Inherited From:
Return a reference to the SidebarDirectory application for this WorldCollection.
Type:
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
viewed
Return a reference to the Scene which is currently viewed
Methods
(static) _activateSocketListeners()
(protected) _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 |
(protected) _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.<string> | 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 |
(protected) _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 |
(protected) _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 |
(protected) _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.<string> | 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 |
(protected) _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, optionsopt) → {object}
- Overrides:
Apply data transformations when importing a Document from a Compendium pack
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
document |
Document | object | The source Document, or a plain data object |
||||||||||||||||||||||||||
options |
object |
<optional> |
Additional options which modify how the document is imported Properties
|
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 WorldCollection#fromCompendium and Document.create methods |
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.<*>
(async) preload(sceneId, push)
Handle pre-loading the art assets for a Scene
Parameters:
Name | Type | Default | Description |
---|---|---|---|
sceneId |
string | The Scene id to begin loading |
|
push |
boolean |
false
|
Trigger other connected clients to also pre-load Scene resources |
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 Document.update |
Returns:
An array of updated data once the operation is complete
- Type
- Promise.<Array.<Document>>