<commit_before>var MarshallPGN = MarshallPGN || {};
/**
 * @classdesc   This is the controller for the game. It sets up the board,
 * pulls in the data, and starts everything off.
 *
 * @constructor
 * @param   {object} pgn The pgn data
 *
 * @property {object}	pgn				- The pgn data object
 * @property {array}	vBoard			- Virtual Board
 * @property {array}	initialBoard	- Staring board
 * @property {boolean}	whiteToMove		- boolean flag
 * @property {integer}	startMoveNum	- starting move number
 *
 * @version 1.0.0
 * @author <NAME>
 * @author <NAME>
 * @copyright 2008 <NAME>
 * @copyright 2012 <NAME> (some portions)
 * @license http://www.apache.org/licenses/LICENSE-2.0
 **/
MarshallPGN.Game = function (sourceDiv, options) {
	"use strict";
	var property,
        givenOptions = options || {};

    this.sourceDiv = document.getElementById(sourceDiv);
	this.pgn = new MarshallPGN.Pgn(this.sourceDiv.getAttribute("data-pgn") ||
	    this.sourceDiv.firstChild.nodeValue);
	this.vBoard = new MarshallPGN.VBoard(this.pgn.props.FEN);
	this.initialBoard = new MarshallPGN.VBoard(this.pgn.props.FEN);
	this.convert();

	this.opts = this.setDefaultOptions();
	for (property in givenOptions) {
	    if (givenOptions.hasOwnProperty(property) &&
	            this.opts.hasOwnProperty(property)) {
	        this.opts[property] = givenOptions[property];
	    }
	}

    this.board = new MarshallPGN.Board(this, this.pgn,
        sourceDiv + (this.sourceDiv.hasAttribute("data-pgn") ? "" : "_board"),
        this.opts);
    this.board.init();
};
MarshallPGN.Game.prototype = {
    sourceDiv:          null,
    pgn:                null,
	whiteToMove:		true,
	startMoveNum:		1,
	displayStart:       null,
    /**
     *	This sets up the default option list
     *
     * @return  {object}    All of the options, set to default values
     */
    setDefaultOptions:  function () {
        "use strict";
        var options = {
                flipped:		false,
                showMovesPane:	true,
                showComments:	true,
                gameTitle:      null,
                diagramTitle:   null,
                showDiagramTitle:   true,
                showGameInfo:   true,
                altRewind:		"Rewind to the beginning",
                altBack:		"One move back",
                altFlip:		"Flip the board",
                altShowMoves:	"Show moves pane",
                altComments:	"Show comments",
                altPlayMove:	"Play one move",
                altFastForward:	"Fast-forward to the end",
                altUp:			"Go up one variation",
                altDown:		"Go down into variation",
                downloadURL:	"http://www.chesspastebin.com/asPgn.php?PGN=",
                skipToMove:		null
            };
        return options;
    },
	/**
	 * Convert the identified file
	 **/
    convert:	function () {
        "use strict";
        var move = this.pgn.moveTree.next;

        this.pgn.moveTree.position = this.vBoard.getFEN();
        this.convertLine(this.vBoard, move);
    },
    convertLine:        function (board, move) {
        "use strict";
        var variation;
        while (move !== null) {
            this.convertMove(board, move);
            if (move.down !== null) {
                if (move.previous) {
                    variation = new MarshallPGN.VBoard(move.previous.position);
                } else {
                    if (move.up) {
                        variation = new MarshallPGN.VBoard(move.goTop().
                            previous.position);
                    }
                }
                this.convertLine(variation, move.down);
            }
            move = move.next;
        }
    },

    /*
        EOF Result Iterator
    */

    getStartPos:	function () {
        "use strict";
        return this.initialBoard;
    },

        /*
            Convert a move.
        */
    convertMove:	function (board, move) {
        "use strict";
        var from,
            parsed,
            thePiece,
            theMove,
            theSource,
            isCapture = false,
            theDestination,
            promotedTo,
            theNotes,
            newPiece;

        parsed = move.text.match(<commit_msg>Documentation Update<commit_after>var MarshallPGN = MarshallPGN || {};
/**
 * @classdesc   This is the controller for the game. It sets up the board,
 * pulls in the data, and starts everything off.
 *
 * @constructor
 * @param   {object} pgn The pgn data
 *
 * @property {object}	pgn				- The pgn data object
 * @property {array}	vBoard			- Virtual Board
 * @property {array}	initialBoard	- Staring board
 * @property {boolean}	whiteToMove		- boolean flag
 * @property {integer}	startMoveNum	- starting move number
 *
 * @version 1.0.0
 * @author <NAME>
 * @author <NAME>
 * @copyright 2008 <NAME>
 * @copyright 2012 <NAME> (some portions)
 * @license http://www.apache.org/licenses/LICENSE-2.0
 **/
MarshallPGN.Game = function (sourceDiv, options) {
	"use strict";
	var property,
        givenOptions = options || {};

    this.sourceDiv = document.getElementById(sourceDiv);
	this.pgn = new MarshallPGN.Pgn(this.sourceDiv.getAttribute("data-pgn") ||
	    this.sourceDiv.firstChild.nodeValue);
	this.vBoard = new MarshallPGN.VBoard(this.pgn.props.FEN);
	this.initialBoard = new MarshallPGN.VBoard(this.pgn.props.FEN);
	this.convert();

	this.opts = this.setDefaultOptions();
	for (property in givenOptions) {
	    if (givenOptions.hasOwnProperty(property) &&
	            this.opts.hasOwnProperty(property)) {
	        this.opts[property] = givenOptions[property];
	    }
	}

    this.board = new MarshallPGN.Board(this, this.pgn,
        sourceDiv + (this.sourceDiv.hasAttribute("data-pgn") ? "" : "_board"),
        this.opts);
    this.board.init();
};
MarshallPGN.Game.prototype = {
    sourceDiv:          null,
    pgn:                null,
	whiteToMove:		true,
	startMoveNum:		1,
	displayStart:       null,
    /**
     *	This sets up the default option list
     *
     * @return  {object}    All of the options, set to default values
     */
    setDefaultOptions:  function () {
        "use strict";
        var options = {
                flipped:		false,
                showMovesPane:	true,
                showComments:	true,
                gameTitle:      null,
                diagramTitle:   null,
                showDiagramTitle:   true,
                showGameInfo:   true,
                altRewind:		"Rewind to the beginning",
                altBack:		"One move back",
                altFlip:		"Flip the board",
                altShowMoves:	"Show moves pane",
                altComments:	"Show comments",
                altPlayMove:	"Play one move",
                altFastForward:	"Fast-forward to the end",
                altUp:			"Go up one variation",
                altDown:		"Go down into variation",
                downloadURL:	"http://www.chesspastebin.com/asPgn.php?PGN=",
                skipToMove:		null
            };
        return options;
    },
	/**
	 * Adds enough information to the existing move tree so that it can
	 * be used to walk through a game forwards or back.
	 **/
    convert:	function () {
        "use strict";
        var move = this.pgn.moveTree.next;

        this.pgn.moveTree.position = this.vBoard.getFEN();
        this.convertLine(this.vBoard, move);
    },
    /**
     *  Sets a line up to be replayed. This is called recursively whenever a
     *  new variation is encountered.
     *
     * @param   {Object}    board   The Virtual Board with current position
     * @param   {Object}    move    The move object that starts the variation
     */
    convertLine:        function (board, move) {
        "use strict";
        var variation;
        while (move !== null) {
            this.convertMove(board, move);
            if (move.down !== null) {
                if (move.previous) {
                    variation = new MarshallPGN.VBoard(move.previous.position);
                } else {
                    if (move.up) {
                        variation = new MarshallPGN.VBoard(move.goTop().
                            previous.position);
                    }
                }
                this.convertLine(variation, move.down);
            }
            move = move.next;
        }
    },
    /**
     * Gets the starting position for the game or game fragment
     *
     * @return  {Object}    The starting Virtual Board
     */
    getStartPos:	function () {
        "use strict";
        return this.initialBoard;
    },
    /**
     *  Analyzes and completes the information necessary to recreate a position
     *
     * @param   {Object}    board   The Virtual Board with the current position
     * @param   {Object}    move    The move object from the move tree
     */
    convertMove:	function (board, move) {
        "use strict";
        var from,
            parsed,
            thePiece,
            theMove,
            theSource,
            isCapture = false,
            theDestination,
            promotedTo,
            theNotes,
            newPiece;

        parsed = move.text.match(
{'fraction_non_alphanumeric': 0.10664182376150812, 'fraction_numerical': 0.003068829460762823, 'mean_word_length': 1.768507281553398, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3340339', 'n_tokens_mistral': 2718, 'n_tokens_neox': 2608, 'n_words': 674}