npm.io
0.8.17 • Published 10 years ago

attribute-generator

Licence
MIT
Version
0.8.17
Deps
7
Vulns
8
Weekly
0

Synopsis

A simple program to apply modifiers to json (items)

Code Example

var AttributeGenerator = require('attribute-generator');

var ItemArray = AttributeGenerator.ItemArray;
var Modifier = AttributeGenerator.Modifier;
var Item = AttributeGenerator.Item;

var shield = new Item("Shield", {
    name : "Ceramic Shield",
    armor : 5,
    durability : 15
});

var crackedMod = new Modifier("Cracked", {
    name : Modifier.Ops.Prepend("Cracked "),
    armor : Modifier.Ops.Subtract(2),
    durability : Modifier.Ops.Subtract(3)
});

shield.Apply(crackedMod);

console.log(shield.ExportItemObject());
console.log(crackedMod.Serialize());

{ key: 'Shield:Cracked',
  item: { name: 'Cracked Ceramic Shield', armor: 3, durability: 12 } }
{ mods:
   [ { name: 'name', operation: 'Prepend', value: 'Cracked ' },
     { name: 'armor', operation: 'Subtract', value: 2 },
     { name: 'durability', operation: 'Subtract', value: 3 } ],
  name: 'Cracked' }

Motivation

Installation

npm install attribute-generator

API Reference

// Items are JSON objects that can have modifiers applied to them

Tests

None yet /:

Contributors

Alexander Dines /w Black Tower Entertainment

License

MIT