Namespace: StorageManager

StorageManager

The static class that manages storage for saving game data.

Methods

StorageManager.exists(saveName)booleanstatic

Checks if a save file of the given name exists
NameTypeDescription
saveNamestringName of the save file
Returns:
TypeDescription
booleanTrue if file exists, otherwise false

StorageManager.fileDirectoryPath()stringstatic

Gets the path to the save file directory
Returns:
TypeDescription
stringThe path to the save file directory

StorageManager.filePath(saveName)stringstatic

Gets the path to the save file of the given name
NameTypeDescription
saveNamestringThe name of the save file
Returns:
TypeDescription
stringThe path to the save file

StorageManager.forageExists(saveName)booleanstatic

Checks if a save key exists in browser storage
NameTypeDescription
saveNamestringName of the save key
Returns:
TypeDescription
booleanTrue if key exists, else false

StorageManager.forageKey(saveName)stringstatic

Gets the path to the save data of the given name
NameTypeDescription
saveNamestringThe name of the save key
Returns:
TypeDescription
stringThe forage key for the given save name

StorageManager.forageKeysUpdated()booleanstatic

Checks if localforage keys have been updated
Returns:
TypeDescription
booleanTrue if keys are updated

StorageManager.forageTestKey()stringstatic

A test key for localforage
Returns:
TypeDescription
stringThe forage key for the test data

StorageManager.fsMkdir(path)static

Makes a directory (synchronously)
NameTypeDescription
pathstringThe path to make the directory

StorageManager.fsReadFile(path)stringstatic

Reads a file (synchronously)
NameTypeDescription
pathstringThe path to the file
Returns:
TypeDescription
stringThe contents of the file

StorageManager.fsRename(oldPath, newPath)static

Renames a file (synchronously)
NameTypeDescription
oldPathstringThe old path where the file existed
newPathstringThe new path to change the file to
Deletes a file (synchronously)
NameTypeDescription
pathstringThe path to the file

StorageManager.fsWriteFile(path, data)static

Writes a file (synchronously)
NameTypeDescription
pathstringThe path to the file
datastringThe data to write

StorageManager.isLocalMode()booleanstatic

Check if the game is running locally (Nwjs)
Returns:
TypeDescription
booleanIf game is running locally (mostly means not mobile/web)

StorageManager.jsonToObject(json)Promisestatic

Converts given JSON to object via parsing
NameTypeDescription
jsonstringJSON string to convert to object
Returns:
TypeDescription
PromisePromise object of the converted object

StorageManager.jsonToZip(json)Promisestatic

Converts given JSON to zip
NameTypeDescription
jsonstringJSON string to convert
Returns:
TypeDescription
PromisePromise object of the converted zip

StorageManager.loadFromForage(saveName)Promisestatic

Loads data from browser storage
NameTypeDescription
saveNamestringName of the save key
Returns:
TypeDescription
PromisePromise object for loading data

StorageManager.loadFromLocalFile(saveName)Promisestatic

Loads a file from the local environment
NameTypeDescription
saveNamestringName of the save file
Returns:
TypeDescription
PromisePromise object for the data in the file

StorageManager.loadObject(saveName)static

Load a saved object
NameTypeDescription
saveNamestringName of the save file to load

StorageManager.loadZip(saveName)Promisestatic

Loads a zip formatted string
NameTypeDescription
saveNamestringName of the save file
Returns:
TypeDescription
PromisePromise object for loading data

StorageManager.localFileExists(saveName)booleanstatic

Checks if a save file of the given name exists locally
NameTypeDescription
saveNamestringName of the save file
Returns:
TypeDescription
booleanTrue if file exists, otherwise false

StorageManager.objectToJson(object)Promisestatic

Converts given object to JSON via stringify
NameTypeDescription
objectObjectObject to convert to JSON string
Returns:
TypeDescription
PromisePromise object of the converted JSON

StorageManager.remove(saveName)Promisestatic

Removes a given save file
NameTypeDescription
saveNamestringName of the save file
Returns:
TypeDescription
PromisePromise object for removing a save file

StorageManager.removeForage(saveName)static

Removes save data from browser storage
NameTypeDescription
saveNamestringName of the save key

StorageManager.removeLocalFile(saveName)static

Removes a local save file
NameTypeDescription
saveNamestringName of the save file

StorageManager.saveObject(saveName, object)static

Save an object
NameTypeDescription
saveNamestringName of the save file
objectObjectThe object to save

StorageManager.saveToForage(saveName, zip)Promisestatic

Saves data to browser storage
NameTypeDescription
saveNamestringName of the save key
zipstringZip string to save
Returns:
TypeDescription
PromisePromise object for saving

StorageManager.saveToLocalFile(saveName, zip)Promisestatic

Saves a file to the local environment
NameTypeDescription
saveNamestringName of the save file
zipstringZip string to save
Returns:
TypeDescription
PromisePromise object for saving the file

StorageManager.saveZip(saveName, zip)Promisestatic

Saves a zip formatted string
NameTypeDescription
saveNamestringName of the save file
zipstringZIP string to save
Returns:
TypeDescription
PromisePromise object for saving data

StorageManager.updateForageKeys()static

Update localforage save keys for browser storage

StorageManager.zipToJson(zip)Promisestatic

Converts given zip to JSON
NameTypeDescription
zipstringZIP string to convert
Returns:
TypeDescription
PromisePromise object of the converted JSON