<commit_before>const $ = require('jquery');
const board = require('./board');
const Piece = require('./piece');

function Game(players, board) {
    this.players = players;
    this.turn = 0;
    this.winner = null;
    this.over = false;
    this.board = board;
}

Game.prototype.start = function(){
    var square0 = this.board.squares[27];
    var square1 = this.board.squares[28];
    var square2 = this.board.squares[35];
    var square3 = this.board.squares[36];

    var squares = [square0, square1, ,square2, square3];

    squares.forEach(function(square,index){
        if (index % 2 == 0){
            square.piece = new Piece('white', square, square.context);
            square.createPiece();
        } else {
            square.piece = new Piece('black', square, square.context);
            square.createPiece();
        }
    });
    welcomePlayers(this.players);
};

function welcomePlayers(players) {
    $('#title').prepend(`<h1>Welcome ${players[0]} and ${players[1]}!</h1>`)
}

module.exports = Game;<commit_msg>Refactor placing of first four pieces<commit_after>const $ = require('jquery');
const board = require('./board');
const Piece = require('./piece');

function Game(players, board) {
    this.players = players;
    this.turn = 0;
    this.winner = null;
    this.over = false;
    this.board = board;
}

Game.prototype.start = function(){
    welcomePlayers(this.players);
    placeFirstFourPieces(this.board);
};

function placeFirstFourPieces(board) {
    var square0 = board.squares[27];
    var square1 = board.squares[28];
    var square2 = board.squares[35];
    var square3 = board.squares[36];

    var squares = [square0, square1, ,square2, square3];

    squares.forEach(function(square,index){
        if (index % 2 == 0){
            square.piece = new Piece('white', square, square.context);
            square.createPiece();
        } else {
            square.piece = new Piece('black', square, square.context);
            square.createPiece();
        }
    });
}

function welcomePlayers(players) {
    $('#title').prepend(`<h1>Welcome ${players[0]} and ${players[1]}!</h1>`)
}

module.exports = Game;
{'fraction_non_alphanumeric': 0.16, 'fraction_numerical': 0.021395348837209303, 'mean_word_length': 3.0356472795497185, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5949842', 'n_tokens_mistral': 715, 'n_tokens_neox': 681, 'n_words': 143}