attribute-generator
v0.8.17
Published
A library for the decorator pattern on a json dataset with relative functional operators that will export to JSON.
Downloads
6
Readme
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