This package has been deprecated

Author message:

This is an old project...

properjs-gamestate

0.2.0 • Public • Published

GameState

Arbitrary game data management using localStorage.

Installation

npm install properjs-gamestate --save-dev

Usage

GameState will utilize localStorage. So, quest state is persisted and it will try to load from storage on initialization.

var GameState = require( "properjs-gamestate" );
var gameState = new GameState();

// Set initial game state
gameState.pushState({
    "level": 1,
    "hp": 100,
    "xp": 1000,
    "cash": 50,
    "stats": {
        "magic": 10,
        "power": 10
    }
});

// Set state as you go
gameState.setValue( "level", 2 );

// Set a deep state value
gameState.setValueDeep( "stats", "power", 20 );

// Also
gameState.getState();
gameState.getValue( id );
gameState.getValueDeep( id, prop );

// Manually save to localStorage
// GameState does this for you though as you go
gameState.setState();

Package Sidebar

Install

npm i properjs-gamestate

Weekly Downloads

0

Version

0.2.0

License

none

Last publish

Collaborators

  • kitajchuk