Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    properjs-gamestatepublic

    This package has been deprecated

    Author message:

    This is an old project...

    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();

    install

    npm i properjs-gamestate

    Downloadsweekly downloads

    5

    version

    0.2.0

    license

    none

    repository

    github.com

    last publish

    collaborators

    • avatar