game.js
function nextTurn(game, player) {
    if (player.has_turn === false) {  // we assume that player has the turn
        return;
    }
    player.has_turn = false;

    // give next player the turn
    var _players = Object.keys(game.players);
    var next_idx = (_players.indexOf(player.name) + 1) %
        _players.length;
    var next = game.players[_players[next_idx]];
    next.has_turn = true;
    // next player draws new pieces
    next.pieces = next.pieces.concat(game.drawPieces(
        6 - next.pieces.length));
}
function nextTurn(game, player) {
    if (player.has_turn === false) {  // we assume that player has the turn
        return;
    }
    player.has_turn = false;

    // give next player the turn
    var _players = Object.keys(game.players);
    var next_idx = (_players.indexOf(player.name) + 1) %
        _players.length;
    var next = game.players[_players[next_idx]];
    next.has_turn = true;
    // next player draws new pieces
    next.pieces = next.pieces.concat(game.drawPieces(
        6 - next.pieces.length));
}
function nextTurn ( game , player ) { if ( player . has_turn === false ) { // we assume that player has the turn return ; } player . has_turn = false ; // give next player the turn var _players = Object . keys ( game . players ) ; var next_idx = ( _players . indexOf ( player . name ) + 1 ) % _players . length ; var next = game . players [ _players [ next_idx ] ] ; next . has_turn = true ; // next player draws new pieces next . pieces = next . pieces . concat ( game . drawPieces ( 6 - next . pieces . length ) ) ; }
Pass the turn to the next player,
@param game: {obj} game object
@param player: {obj} player object
Pass the turn to the next player