build/ludorum.js
/** Each turn all players play a piece, and the player who plays the greatest piece wins a 
	point.
	*/
Each turn all players play a piece, and the player who plays the greatest piece wins a
point.
Each turn all players play a piece and the player who plays the greatest piece wins a point .
function next(moves, haps, update) {
		var player0 = this.players[0],
			player1 = this.players[1];
		if (!this.pieces[player0] || !this.pieces[player1]) { 
			return this.__viewNext__(moves, haps, update);
		}
		var move0 = moves[player0],
			move1 = moves[player1],
			pieces = this.pieces;
		raiseIf(pieces[player0].indexOf(move0) < 0, "Invalid move ", JSON.stringify(move0),
			" for player ", player0, "! (moves= ", JSON.stringify(moves), ")");
		raiseIf(pieces[player1].indexOf(move1) < 0, "Invalid move ", JSON.stringify(move1),
			" for player ", player1, "! (moves= ", JSON.stringify(moves), ")");
		var moveResult = this.moveResult(move0, move1),
			nextPlayedPieces = this.playedPieces.concat([move0, move1]),
			nextPieces = obj(
				player0, pieces[player0].filter(function (p) { 
					return p !== move0; 
				}), 
				player1, pieces[player1].filter(function (p) { 
					return p !== move1;
				})
			),
			nextScores = obj(player0, this.__scores__[player0] + moveResult,
				player1, this.__scores__[player1] - moveResult);
		if (update) {
			this.playedPieces = nextPlayedPieces;
			this.pieces = nextPieces;
			this.__scores__ = nextScores;
			return this;
		} else {
			return new this.constructor({
				playedPieces: nextPlayedPieces,
				pieces: nextPieces,
				scores: nextScores
			});
		}
	}
function next ( moves , haps , update ) { var player0 = this . players [ 0 ] , player1 = this . players [ 1 ] ; if ( ! this . pieces [ player0 ] || ! this . pieces [ player1 ] ) { return this . __viewNext__ ( moves , haps , update ) ; } var move0 = moves [ player0 ] , move1 = moves [ player1 ] , pieces = this . pieces ; raiseIf ( pieces [ player0 ] . indexOf ( move0 ) < 0 , "Invalid move " , JSON . stringify ( move0 ) , " for player " , player0 , "! (moves= " , JSON . stringify ( moves ) , ")" ) ; raiseIf ( pieces [ player1 ] . indexOf ( move1 ) < 0 , "Invalid move " , JSON . stringify ( move1 ) , " for player " , player1 , "! (moves= " , JSON . stringify ( moves ) , ")" ) ; var moveResult = this . moveResult ( move0 , move1 ) , nextPlayedPieces = this . playedPieces . concat ( [ move0 , move1 ] ) , nextPieces = obj ( player0 , pieces [ player0 ] . filter ( function ( p ) { return p !== move0 ; } ) , player1 , pieces [ player1 ] . filter ( function ( p ) { return p !== move1 ; } ) ) , nextScores = obj ( player0 , this . __scores__ [ player0 ] + moveResult , player1 , this . __scores__ [ player1 ] - moveResult ) ; if ( update ) { this . playedPieces = nextPlayedPieces ; this . pieces = nextPieces ; this . __scores__ = nextScores ; return this ; } else { return new this . constructor ( { playedPieces : nextPlayedPieces , pieces : nextPieces , scores : nextScores } ) ; } }
Each turn all players play a piece, and the player who plays the greatest piece wins a
point.
Each turn all players play a piece and the player who plays the greatest piece wins a point .
// This state is a view.