addons/BalanceSheet.js
function BalanceSheet (options) {


// ## Public properties

	this.sheets = {};

	this.sheet = null;

	log = options.log || log;

/**
 * ### BalanceSheet.options
 *
 * Reference to current configuration
 *
 */
	this.options = options || {};

// ## BalanceSheet methods

/**
 * ### BalanceSheet.init
 *
 * Configures the BalanceSheet instance
 *
 * Takes the configuration as an input parameter or
 * recycles the settings in `this.options`.
 *
 * The configuration object is of the type
 *
 * 	var options = {
 * 		returnAt: 'first', // or 'last'
 * 		triggers: [ myFunc,
 * 					myFunc2
 * 		],
 * 	}
 *
 * @param {object} options Optional. Configuration object
 *
 */
BalanceSheet.prototype.init = function (options) {
	this.options = options || this.options;
	if (this.options.returnAt === BalanceSheet.first || this.options.returnAt === BalanceSheet.last) {
		this.returnAt = this.options.returnAt;
	}
	this.resetTriggers();
};

/**
 * ### BalanceSheet.addSheet
 *
 * Adds a new sheet and sets it as default
 *
 * @param {string} sheet The sheet name
 * @param {object} options. Optional. Configuration options for the sheet
 * @param {array} items. Optional. An initial set of items for the sheet
 * @return {boolean} TRUE, if the sheet is added successfully
 */
//BalanceSheet.prototype.addSheet = function (sheet, pl, options) {
//	if (!isValidSheet(sheet)) return false;
//	pl = pl || new PlayerList();
//
//	this.sheets[sheet] = pl;
//
//	if (!this.initSheet(sheet, options)) {
//		return false;
//	}
//
//	this.sheet = sheet;
//	return true;
//};

//BalanceSheet.prototype.initSheet = function (sheet, options) {
//	if  (!isValidSheet(sheet)) return false;
//	this.sheets[sheet].each(function(p){
//		if (!p.__balance) {
//			p.__balance = 0;
//		}
//	});
//};

BalanceSheet.prototype.updateBalance = function (player, amount) {
	if (!player || !amount) return;
	if (!this.sheet) {
		log('No balance sheet selected');
		return;
	}
	if (!this.sheet.player)
		return
	}
	this.sheet.players[player].__balance += amount;
}
function BalanceSheet (options) {


// ## Public properties

	this.sheets = {};

	this.sheet = null;

	log = options.log || log;

/**
 * ### BalanceSheet.options
 *
 * Reference to current configuration
 *
 */
	this.options = options || {};

// ## BalanceSheet methods

/**
 * ### BalanceSheet.init
 *
 * Configures the BalanceSheet instance
 *
 * Takes the configuration as an input parameter or
 * recycles the settings in `this.options`.
 *
 * The configuration object is of the type
 *
 * 	var options = {
 * 		returnAt: 'first', // or 'last'
 * 		triggers: [ myFunc,
 * 					myFunc2
 * 		],
 * 	}
 *
 * @param {object} options Optional. Configuration object
 *
 */
BalanceSheet.prototype.init = function (options) {
	this.options = options || this.options;
	if (this.options.returnAt === BalanceSheet.first || this.options.returnAt === BalanceSheet.last) {
		this.returnAt = this.options.returnAt;
	}
	this.resetTriggers();
};

/**
 * ### BalanceSheet.addSheet
 *
 * Adds a new sheet and sets it as default
 *
 * @param {string} sheet The sheet name
 * @param {object} options. Optional. Configuration options for the sheet
 * @param {array} items. Optional. An initial set of items for the sheet
 * @return {boolean} TRUE, if the sheet is added successfully
 */
//BalanceSheet.prototype.addSheet = function (sheet, pl, options) {
//	if (!isValidSheet(sheet)) return false;
//	pl = pl || new PlayerList();
//
//	this.sheets[sheet] = pl;
//
//	if (!this.initSheet(sheet, options)) {
//		return false;
//	}
//
//	this.sheet = sheet;
//	return true;
//};

//BalanceSheet.prototype.initSheet = function (sheet, options) {
//	if  (!isValidSheet(sheet)) return false;
//	this.sheets[sheet].each(function(p){
//		if (!p.__balance) {
//			p.__balance = 0;
//		}
//	});
//};

BalanceSheet.prototype.updateBalance = function (player, amount) {
	if (!player || !amount) return;
	if (!this.sheet) {
		log('No balance sheet selected');
		return;
	}
	if (!this.sheet.player)
		return
	}
	this.sheet.players[player].__balance += amount;
}
## BalanceSheet constructor

Creates a new instance of BalanceSheet