build/ludorum.js
/** Tournaments gather information from the played matches using their
	`statistics` property (instance of `creatartis-base.Statistics`). The method
	`Tournament.account(match)` is called to accounts the results of each
	finished match for the players' score.

	The match results are gathered in the `results` key. The keys `victories`,
	`defeats` and `draws` count each result type. The length of each game is
	recorded under `length`. The move count at each ply is aggregated under
	`width`. All these numbers are open by game, role, player.
	*/
Tournaments gather information from the played matches using their
`statistics` property (instance of `creatartis-base.Statistics`). The method
`Tournament.account(match)` is called to accounts the results of each
finished match for the players' score.

The match results are gathered in the `results` key.
Tournaments gather information from the played matches using their ` statistics ` property ( instance of ` creatartis - base . Statistics ` ) . The method ` Tournament . account ( match ) ` is called to accounts the results of each finished match for the players ' score . The match results are gathered in the ` results ` key .
function account(match) {
		var game = this.game,
			results = match.result(),
			isDraw = false,
			stats = this.statistics;
		raiseIf(!results, "Match doesn't have results. Has it finished?");
		iterable(match.players).forEach(function (p) { 
			var role = p[0],
				player = p[1],
				playerResult = results[p[0]];
			stats.add({key:'results', game:game.name, role:role, player:player.name},
				playerResult);
			stats.add({key:(playerResult > 0 ? 'victories' : playerResult < 0 ? 'defeats' : 'draws'),
				game:game.name, role:role, player:player.name}, playerResult);
			stats.add({key:'length', game:game.name, role:role, player:player.name},
				match.ply()); 
			match.history.forEach(function (entry) {
				var game = entry.state;
				if (typeof game === 'function') {
					var moves = game.moves();
					if (moves && moves.hasOwnProperty(role) && moves[role].length > 0) {
						stats.add({ key: 'width', game: game.name, role: role, 
							player: player.name }, moves[role].length);
					}
				}
			});
		});
	}
function account ( match ) { var game = this . game , results = match . result ( ) , isDraw = false , stats = this . statistics ; raiseIf ( ! results , "Match doesn't have results. Has it finished?" ) ; iterable ( match . players ) . forEach ( function ( p ) { var role = p [ 0 ] , player = p [ 1 ] , playerResult = results [ p [ 0 ] ] ; stats . add ( { key : 'results' , game : game . name , role : role , player : player . name } , playerResult ) ; stats . add ( { key : ( playerResult > 0 ? 'victories' : playerResult < 0 ? 'defeats' : 'draws' ) , game : game . name , role : role , player : player . name } , playerResult ) ; stats . add ( { key : 'length' , game : game . name , role : role , player : player . name } , match . ply ( ) ) ; match . history . forEach ( function ( entry ) { var game = entry . state ; if ( typeof game === 'function' ) { var moves = game . moves ( ) ; if ( moves && moves . hasOwnProperty ( role ) && moves [ role ] . length > 0 ) { stats . add ( { key : 'width' , game : game . name , role : role , player : player . name } , moves [ role ] . length ) ; } } } ) ; } ) ; }
Tournaments gather information from the played matches using their
`statistics` property (instance of `creatartis-base.Statistics`).
Tournaments gather information from the played matches using their ` statistics ` property ( instance of ` creatartis - base . Statistics ` ) .
// Player statistics. //FIXME This may not be accurate if the game has random variables.