new EventContainer(obj)
Manages interface for event storage.
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | List of IDs to load. |
- Source:
Members
-
<static, readonly> eventDir
-
Directory where all event data is stored.
- Source:
-
<static, readonly> types
-
Current types of events that this object stores.
- Source:
-
<private, constant> _arena :object.<HungryGames~ArenaEvent>
-
Cached arena events.
Type:
- object.<HungryGames~ArenaEvent>
- Default Value:
-
- {}
- Source:
-
<private, constant> _arenaIds :Array.<string>
-
All arena event IDs that should be loaded.
Type:
- Array.<string>
- Default Value:
-
- []
- Source:
-
<private, constant> _bloodbath :object.<HungryGames~NormalEvent>
-
Cached bloodbath events.
Type:
- object.<HungryGames~NormalEvent>
- Default Value:
-
- {}
- Source:
-
<private, constant> _bloodbathIds :Array.<string>
-
All bloodbath event IDs that should be loaded.
Type:
- Array.<string>
- Default Value:
-
- []
- Source:
-
<private, constant> _callbacks :Array.<function()>
-
List of callbacks to fire once loading is completed.
Type:
- Array.<function()>
- Default Value:
-
- []
- Source:
-
<private> _loading :number
-
Number of currently loading requets that have not completed.
Type:
- number
- Source:
- See:
-
- HungryGames~EventContainer.loading
-
<private, constant> _player :object.<HungryGames~NormalEvent>
-
Cached player events.
Type:
- object.<HungryGames~NormalEvent>
- Default Value:
-
- {}
- Source:
-
<private, constant> _playerIds :Array.<string>
-
All player event IDs that should be loaded.
Type:
- Array.<string>
- Default Value:
-
- []
- Source:
-
<private, constant> _weapon :object.<HungryGames~WeaponEvent>
-
Cached weapon events.
Type:
- object.<HungryGames~WeaponEvent>
- Default Value:
-
- {}
- Source:
-
<private, constant> _weaponIds :Array.<string>
-
All weapon IDs that should be loaded.
Type:
- Array.<string>
- Default Value:
-
- []
- Source:
-
<readonly> loading
-
True if data is currently being updated, and should not be trusted as complete or up to date.
- Source:
-
serializable
-
Get serializable version of this object for saving to file.
- Source:
Methods
-
<static> from(obj)
-
Create based of serializable data that was saved to file.
Parameters:
Name Type Description obj
object Parsed save data. - Source:
Returns:
Created object. -
<private> _fetchFromUrl(id, type, cb)
-
Fetch an event into the cache. Always updates from file, even if already cached. This fetches exclusively from the master server URL. This is called from fetch.
Parameters:
Name Type Argument Description id
string The event ID to fetch. type
string <nullable>
The category to add this event to. If null, event will not be stored in category, nor cached. cb
basicCB Callback once completed. First argument is optional error string, second is otherwise the event object. - Source:
-
<private> _parseFetched(data, id, type, done)
-
Parse fetched data.
Parameters:
Name Type Description data
string | Buffer Data to parse. id
string The ID of the event we're parsing. type
string The event type we're parsing. done
function Callback. - Source:
-
fetch(id, type, cb)
-
Fetch an event into the cache. Always updates from file, even if already cached.
Parameters:
Name Type Argument Description id
string The event ID to fetch. type
string <nullable>
The category to add this event to. If null, event will not be stored in category, nor cached. cb
basicCB Callback once completed. First argument is optional error string, second is otherwise the event object. - Source:
-
fetchAll(cb)
-
Fetch all events from file into the cache. Always fetches from file, even if event exists in cache already.
Parameters:
Name Type Description cb
function Callback once completed. No arguments. - Source:
-
get(type)
-
Get the object reference storing events of a certain type, mapped by the event IDs.
Parameters:
Name Type Description type
string The type to fetch. - Source:
Returns:
The object of requested event types. -
getArray(type)
-
Get the object reference storing events of a certain type after passed through `Object.values()`.
Parameters:
Name Type Description type
string The type to fetch. - Source:
Returns:
The object of requested event types. -
ids(type)
-
Fetch list of IDs for specific type.
Parameters:
Name Type Description type
string Event type to fetch IDs for. - Source:
Returns:
List of IDs.- Type
- Array.<string>
-
remove(id, type)
-
Remove an event from a type. Purges from cache immediately.
Parameters:
Name Type Description id
string ID of the event to remove. type
string The category to remove the event from. - Source:
Returns:
True if success, false otherwise.- Type
- boolean
-
updateAndFetchAll(obj, cb)
-
Update list of IDs, and cache all.
Parameters:
Name Type Description obj
Object List of IDs to load. cb
function Fires once all events have been cached. - Source:
-
waitForReady(cb)
-
Fires callback once not loading anymore, or immediately if not currently loading.
Parameters:
Name Type Description cb
function Callback to fire. - Source: