<commit_before>'use strict';

/**
 * @ngdoc function
 * @name chessmateApp.controller:NotationCtrl
 * @description
 * # NotationCtrl
 * Controller of the chessmateApp
 */
angular.module('chessmateApp')
  .controller('NotationCtrl', function ($scope,$rootScope) {
    $scope.buildGame = function(notation) {
      var game = {
        "boards": [$scope.buildInitialBoard()]
      };

      $rootScope.$broadcast('game-updated', game);
    };

    $scope.buildInitialBoard = function() {
      var board = {
        "turn": 0,
        "source": undefined,
        "destination": undefined,
        "position": {
          "A1": $scope.buildPiece('R', "white"),
          "B1": $scope.buildPiece('N', "white"),
          "C1": $scope.buildPiece('B', "white"),
          "D1": $scope.buildPiece('K', "white"),
          "E1": $scope.buildPiece('Q', "white"),
          "F1": $scope.buildPiece('B', "white"),
          "G1": $scope.buildPiece('N', "white"),
          "H1": $scope.buildPiece('R', "white"),
          "A3": $scope.buildPiece('B', "white"),
          "B3": $scope.buildPiece('B', "white"),
          "C3": $scope.buildPiece('B', "white"),
          "D3": $scope.buildPiece('B', "white"),
          "E3": $scope.buildPiece('B', "white"),
          "F3": $scope.buildPiece('B', "white"),
          "G3": $scope.buildPiece('B', "white"),
          "H3": $scope.buildPiece('B', "white"),
          "A6": $scope.buildPiece('B', "black"),
          "B6": $scope.buildPiece('B', "black"),
          "C6": $scope.buildPiece('B', "black"),
          "D6": $scope.buildPiece('B', "black"),
          "E6": $scope.buildPiece('B', "black"),
          "F6": $scope.buildPiece('B', "black"),
          "G6": $scope.buildPiece('B', "black"),
          "H6": $scope.buildPiece('B', "black"),
          "A8": $scope.buildPiece('R', "black"),
          "B8": $scope.buildPiece('N', "black"),
          "C8": $scope.buildPiece('B', "black"),
          "D8": $scope.buildPiece('K', "black"),
          "E8": $scope.buildPiece('Q', "black"),
          "F8": $scope.buildPiece('B', "black"),
          "G8": $scope.buildPiece('N', "black"),
          "H8": $scope.buildPiece('R', "black")
        }
      };

      return board;
    }

    $scope.buildBoard = function(currentBoard, move) {
      var board = currentBoard;

      return board;
    };

    $scope.buildPiece = function(char, color) {
      var piece = {
        type: $scope.getType(char),
        color: color
      };

      return piece;
    };

    $scope.getType = function(char) {
      var type;

      if (char == 'B') {
        type = "pawn";
      } else if (char == 'R') {<commit_msg>Implement buildBoard function<commit_after>'use strict';

/**
 * @ngdoc function
 * @name chessmateApp.controller:NotationCtrl
 * @description
 * # NotationCtrl
 * Controller of the chessmateApp
 */
angular.module('chessmateApp')
  .controller('NotationCtrl', function ($scope,$rootScope) {
    $scope.buildGame = function(notation) {
      var game = {
        "boards": [$scope.buildInitialBoard()]
      };

      game.boards.push($scope.buildBoard(game.boards[0], "RA1-A2", "white"));

      $rootScope.$broadcast('game-updated', game);
    };

    $scope.buildInitialBoard = function() {
      var board = {
        "turn": 0,
        "source": undefined,
        "destination": undefined,
        "position": {
          "A1": $scope.buildPiece('R', "white"),
          "B1": $scope.buildPiece('N', "white"),
          "C1": $scope.buildPiece('B', "white"),
          "D1": $scope.buildPiece('K', "white"),
          "E1": $scope.buildPiece('Q', "white"),
          "F1": $scope.buildPiece('B', "white"),
          "G1": $scope.buildPiece('N', "white"),
          "H1": $scope.buildPiece('R', "white"),
          "A3": $scope.buildPiece('B', "white"),
          "B3": $scope.buildPiece('B', "white"),
          "C3": $scope.buildPiece('B', "white"),
          "D3": $scope.buildPiece('B', "white"),
          "E3": $scope.buildPiece('B', "white"),
          "F3": $scope.buildPiece('B', "white"),
          "G3": $scope.buildPiece('B', "white"),
          "H3": $scope.buildPiece('B', "white"),
          "A6": $scope.buildPiece('B', "black"),
          "B6": $scope.buildPiece('B', "black"),
          "C6": $scope.buildPiece('B', "black"),
          "D6": $scope.buildPiece('B', "black"),
          "E6": $scope.buildPiece('B', "black"),
          "F6": $scope.buildPiece('B', "black"),
          "G6": $scope.buildPiece('B', "black"),
          "H6": $scope.buildPiece('B', "black"),
          "A8": $scope.buildPiece('R', "black"),
          "B8": $scope.buildPiece('N', "black"),
          "C8": $scope.buildPiece('B', "black"),
          "D8": $scope.buildPiece('K', "black"),
          "E8": $scope.buildPiece('Q', "black"),
          "F8": $scope.buildPiece('B', "black"),
          "G8": $scope.buildPiece('N', "black"),
          "H8": $scope.buildPiece('R', "black")
        }
      };

      return board;
    }

    $scope.buildBoard = function(currentBoard, move, color) {
      var board = angular.copy(currentBoard);
      var char = move.substring(0, 1);
      var source = move.substring(1, 3);
      var destination = move.substring(4, 6);

      board.turn = currentBoard.turn + 1;
      board.source = source;
      board.destination = destination;
      board.position[destination] = $scope.buildPiece(char, color);
      delete board.position[source];

      return board;
    };

    $scope.buildPiece = function(char, color) {
      var piece = {
        type: $scope.getType(char),
        color: color
      };

      return piece;
    };

    $scope.getType = function(char) {
      var type;

      if (char == 'B') {
        type = "pawn";
      } else if (char == 'R') {
{'fraction_non_alphanumeric': 0.21021542738012508, 'fraction_numerical': 0.01320361362056984, 'mean_word_length': 2.441123729826659, 'pattern_counts': {'":': 74, '<': 3, '<?xml version=': 0, '>': 3, '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': '1193538', 'n_tokens_mistral': 1956, 'n_tokens_neox': 1932, 'n_words': 360}