build/ludorum.js
/** If the active player holds, it earns the sum of the rolls made so in its turn. If the move 
	is roll, a die is rolled. A roll of 1 stops the this turn and the active player earns no 
	points. A roll of 2 or up, makes the turn continue.
	
	For this game mechanic, an [contingent game state](../Contingent.js.html) is used. If the move 
	is `roll`, an instance of this class is build and returned using the [dice shotcuts](
	../aleatories/dice.js.html) as random variables. This aleatoric game state will call the `next` 
	method again with the same moves and the values of the random variables, and then the match will
	continue.
	*/
If the active player holds, it earns the sum of the rolls made so in its turn. If the move
is roll, a die is rolled. A roll of 1 stops the this turn and the active player earns no
points. A roll of 2 or up, makes the turn continue.

For this game mechanic, an [contingent game state](../Contingent.js.html) is used. If the move
is `roll`, an instance of this class is build and returned using the [dice shotcuts](
/aleatories/dice.js.html) as random variables. This aleatoric game state will call the `next`
method again with the same moves and the values of the random variables, and then the match will
continue.
If the active player holds it earns the sum of the rolls made so in its turn . If the move is roll a die is rolled . A roll of 1 stops the this turn and the active player earns no points . A roll of 2 or up makes the turn continue . For this game mechanic an [ contingent game state ] ( .. / Contingent . js . html ) is used . If the move is ` roll ` an instance of this class is build and returned using the [ dice shotcuts ] ( / aleatories / dice . js . html ) as random variables . This aleatoric game state will call the ` next ` method again with the same moves and the values of the random variables and then the match will continue .
function next(moves, haps, update) {
		var activePlayer = this.activePlayer(),
			move = moves && moves[activePlayer];
		raiseIf(!move, 'No move for active player ', activePlayer, ' at ', this, '!');
		var nextPlayer = this.opponent(),
			nextScores = this.__scores__,
			nextRolls = [];
		if (move === 'hold' || move === 'roll') {
			if (move === 'hold') {
				nextScores = copy(nextScores);
				nextScores[activePlayer] += iterable(this.__rolls__).sum();
			} else { 
				var roll = (haps && haps.die)|0;
				if (!roll) { 
					return new Contingent(this, moves, { die: aleatories.dice.D6 }, update);
				} else if (roll > 1) { 
					nextPlayer = activePlayer;
					nextRolls = this.__rolls__.concat(roll);
					return new this.constructor(activePlayer,  this.goal, this.__scores__, this.__rolls__.concat(roll));
				}
			}
			if (update) {
				this.activatePlayers(nextPlayer);
				this.__scores__ = nextScores;
				this.__rolls__ = nextRolls;
				return this;
			} else {
				return new this.constructor(nextPlayer, this.goal, nextScores, nextRolls);
			}
		} else {
			raise("Invalid moves ", JSON.stringify(moves), " at ", this, "!");
		}
	}
function next ( moves , haps , update ) { var activePlayer = this . activePlayer ( ) , move = moves && moves [ activePlayer ] ; raiseIf ( ! move , 'No move for active player ' , activePlayer , ' at ' , this , '!' ) ; var nextPlayer = this . opponent ( ) , nextScores = this . __scores__ , nextRolls = [ ] ; if ( move === 'hold' || move === 'roll' ) { if ( move === 'hold' ) { nextScores = copy ( nextScores ) ; nextScores [ activePlayer ] += iterable ( this . __rolls__ ) . sum ( ) ; } else { var roll = ( haps && haps . die ) | 0 ; if ( ! roll ) { return new Contingent ( this , moves , { die : aleatories . dice . D6 } , update ) ; } else if ( roll > 1 ) { nextPlayer = activePlayer ; nextRolls = this . __rolls__ . concat ( roll ) ; return new this . constructor ( activePlayer , this . goal , this . __scores__ , this . __rolls__ . concat ( roll ) ) ; } } if ( update ) { this . activatePlayers ( nextPlayer ) ; this . __scores__ = nextScores ; this . __rolls__ = nextRolls ; return this ; } else { return new this . constructor ( nextPlayer , this . goal , nextScores , nextRolls ) ; } } else { raise ( "Invalid moves " , JSON . stringify ( moves ) , " at " , this , "!" ) ; } }
If the active player holds, it earns the sum of the rolls made so in its turn.
If the active player holds it earns the sum of the rolls made so in its turn .
// if (move === 'roll') { // Dice has not been rolled. // Dice has been rolled.