Class

Storage

Storage(bridge, dispatcher, params)

Storage
Constructor

# new Storage(bridge, dispatcher, params)

Create a new storage handler.
Parameters:
Name Type Description
bridge string | Object the execution context bridge
dispatcher Object the custom event dispatcher
params Object
register boolean register handlers immediately or defer

View Source browser/lib/Storage.js, line 10

Classes

Storage

Members

string | Object

# bridge

bridge - the execution context bridge

View Source browser/lib/Storage.js, line 43

Object

# dispatcher

dispatcher - the custom game event dispatcher

View Source browser/lib/Storage.js, line 49

boolean

# gameInstanceAttached

Whether or not the game has been instantiated past the splash screen

View Source browser/lib/Storage.js, line 55

string

# localStorageSettingsKey

localStorageSettingsKey - the key for settings from localstorage in the web context

View Source browser/lib/Storage.js, line 27

Object

# settings

settings - the default game settings

View Source browser/lib/Storage.js, line 33

Methods

# configureFileStorage() → {void}

Configure file-based storage when running as a desktop app.

View Source browser/lib/Storage.js, line 150

void

# configureLocalStorage() → {void}

Configure local stroage when running through the browser.

View Source browser/lib/Storage.js, line 164

void

# loadGameSavesFromBridge() → {void}

Load save games from emitted IPC event when running as a desktop app

View Source browser/lib/Storage.js, line 207

void

# loadGameSavesFromLocalStorage(loader) → {void}

Load saved games from local storage when running through the browser
Parameters:
Name Type Description
loader HTMLElement element to append saved games list to load from

View Source browser/lib/Storage.js, line 227

void

# register() → {void}

Register storage handlers for various game mechanics.

View Source browser/lib/Storage.js, line 74

void

# saveFileSettings() → {void}

Save settings to file when running as a deskto app

View Source browser/lib/Storage.js, line 196

void

# saveGame(game) → {void}

Handle saving game to storage.
Parameters:
Name Type Description
game Object the managed game instance

View Source browser/lib/Storage.js, line 263

void

# saveLocalStorageSettings() → {void}

Save settings to local storage when running in the browser

View Source browser/lib/Storage.js, line 184

void

# setBridge(bridge) → {void}

Set the execution context bridg. If the game is runing through the browser on the web, then the bridge will simply be set to "web", otherwise it will contain the IPC event emitter for bi-directional communication between the browser and the node runtime.
Parameters:
Name Type Description
bridge string | Object the execution context bridge

View Source browser/lib/Storage.js, line 89

void

# setDifficultySettings(difficulty) → {void}

Store and set difficulty settings.
Parameters:
Name Type Description
difficulty string the difficulty setting "easy", "medium", or "hard"

View Source browser/lib/Storage.js, line 337

void

# setGameInstanceAttached(isCreated) → {void}

Set the flag to indicate that the game is instantiated.
Parameters:
Name Type Default Description
isCreated boolean false whether or not the game is insantiated

View Source browser/lib/Storage.js, line 100

void

# setGodModeSettings(godmode) → {void}

Store and set god-mode setting.
Parameters:
Name Type Description
godmode boolean whether or not god-mode is enabled

View Source browser/lib/Storage.js, line 348

void

# setSetting(key, value, persist) → {void}

Set an individual setting.
Parameters:
Name Type Default Description
key string the setting object key
value string | number | boolean the setting key value
persist boolean false whether or not to save the setting to storage

View Source browser/lib/Storage.js, line 133

void

# setSettings(settings, persist) → {void}

Set settings from storage.
Parameters:
Name Type Default Description
settings Object the settings object
persist boolean false whether or not to persist settings on load

View Source browser/lib/Storage.js, line 112

void

# setUIState(key) → {void}

Set the UI state depending on the value of stored settings, i.e volume sliders.
Parameters:
Name Type Description
key string the type of UI object to set

View Source browser/lib/Storage.js, line 359

void

# setVolumeSettings(volume) → {void}

Store and set volume settings.
Parameters:
Name Type Default Description
volume Object null the audio object to set

View Source browser/lib/Storage.js, line 301

void