binned-stacked-inventory

0.0.1 • Public • Published

binned-stacked-inventory

An interface for inventory, stacked and limited by type(slightly different than the standard unified storage)

Usage

var inventory = new Inventory({
    sizes : {
        <type name> : <max # of items per stack>
    }, stack : {
        <type name> : <total # of stacks for this type>
    }
});

You'll want to listen for events:

inventory.on('stack-change', function(e){ });
inventory.on('stack-add', function(e){ });
inventory.on('stack-drop', function(e){ });

Where e looks like:

{
    stack: {
        count : <number of items in this stack>,
        material : <the id of this particular item (unique within type)>
    },
    type : <the type of stack this is>
}

Then to add an item:

inventory.add(<type>, material);

It will fill items into stacks until there is no more room and begin dropping things.

Testing

Eventually it'll be:

mocha

Enjoy,

-Abbey Hawk Sparrow

Readme

Keywords

Package Sidebar

Install

npm i binned-stacked-inventory

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

4.24 kB

Total Files

3

Last publish

Collaborators

  • khrome