<commit_before>angular.module('mean.system')
.controller('GameController', ['$scope', 'game', 'dataFactory', '$timeout', '$location', '$modal', 'MakeAWishFactsService', function ($scope, game, dataFactory, $timeout, $location, $modal, MakeAWishFactsService) {
  $scope.hasPickedCards = false;
  $scope.winningCardPicked = false;
  $scope.showTable = false;
  $scope.modalShown = false;
  $scope.game = game;
  $scope.inviteList = [];
  $scope.pickedCards = [];
  var makeAWishFacts = MakeAWishFactsService.getMakeAWishFacts();
  $scope.makeAWishFact = makeAWishFacts.pop();

  $scope.pickCard = function(card) {
    if (!$scope.hasPickedCards) {
      if ($scope.pickedCards.indexOf(card.id) < 0) {
        $scope.pickedCards.push(card.id);
        if (game.curQuestion.numAnswers === 1) {
          $scope.sendPickedCards();
          $scope.hasPickedCards = true;
        } else if (game.curQuestion.numAnswers === 2 &&
          $scope.pickedCards.length === 2) {
          //delay and send
          $scope.hasPickedCards = true;
          $timeout($scope.sendPickedCards, 300);
        }
      } else {
        $scope.pickedCards.pop();
      }
    }
  };

  $scope.pointerCursorStyle = function() {
    if ($scope.isCzar() && $scope.game.state === 'waiting for czar to decide') {
        return {'cursor': 'pointer'};
      } else {
        return {};
      }
  };

  $scope.sendPickedCards = function() {
    game.pickCards($scope.pickedCards);
    $scope.showTable = true;
  };

  $scope.cardIsFirstSelected = function(card) {
    if (game.curQuestion.numAnswers > 1) {
        return card === $scope.pickedCards[0];
      } else {
        return false;
      }
  };

  $scope.cardIsSecondSelected = function(card) {
    if (game.curQuestion.numAnswers > 1) {
        return card === $scope.pickedCards[1];
      } else {
        return false;
      }
  };

  $scope.firstAnswer = function($index){
    if($index % 2 === 0 && game.curQuestion.numAnswers > 1){
        return true;
      } else{
        return false;
      }
  };

  $scope.secondAnswer = function($index){
    if($index % 2 === 1 && game.curQuestion.numAnswers > 1){
        return true;
      } else{
        return false;
      }
  };

  $scope.showFirst = function(card) {
    return game.curQuestion.numAnswers > 1 && $scope.pickedCards[0] === card.id;
  };

  $scope.showSecond = function(card) {
    return game.curQuestion.numAnswers > 1 && $scope.pickedCards[1] === card.id;
  };

  $scope.isCzar = function() {
    return game.czar === game.playerIndex;
  };

  $scope.isPlayer = function($index) {
    return $index === game.playerIndex;
  };

  $scope.isCustomGame = function() {
    return !(/^\d+$/).test(game.gameID) && game.state === 'awaiting players';
  };

  $scope.isPremium = function($index) {
    return game.players[$index].premium;
  };

  $scope.currentCzar = function($index) {
    return $index === game.czar;
  };

  $scope.winningColor = function($index) {
    if (game.winningCardPlayer !== -1 && $index === game.winningCard) {
        return $scope.colors[game.players[game.winningCardPlayer].color];
      } else {
        return '#f9f9f9';
      }
  };

  $scope.pickWinning = function(winningSet) {
    if ($scope.isCzar()) {
      game.pickWinning(winningSet.card[0]);
      $scope.winningCardPicked = true;
    }
  };

  $scope.winnerPicked = function() {
    return game.winningCard !== -1;
  };

  $scope.customCreator = function () {
    if (game.players[0] === undefined) {
      return false;
    } else if (window.user === null) {
      return false;
    }
    return game.players[0].id === window.user._id;
  };

  $scope.isUser = window.user;

  $scope.userEmail = $location.search().email;

  $scope.startGame = function () {
    if (game.players.length < game.playerMinLimit) {
      let message = `You need at least ${game.playerMinLimit} players to start the game`;
      let template = '/views/popup.html';
      showModal(message, template);
    } else if ($scope.isCustomGame()) {
      let message = 'You are about to start a game that will be saved';
      let template = '/views/save-game.html';
      showModal(message, template);
    } else {
      game.startGame();
    }
  };

  $scope.saveGame = function () {
    game.startGame();
    $scope.modalInstance.close();
    const gameId = $location.search().game;
    console.log(gameId);
    const link = `/api/games/${gameId}/start`;
    const data = {
      creator: game.players[0].id,
      friends: game.players
    }
    dataFactory.saveGameHistory(link, data)
    .success(function(response) {
      gameKey = response._id;
      $scope.model = 'Game Saved';
      return gameKey;
    })
    .error(function (response) {
      $scope.message = 'Could not save game';
    });
  };

  $scope.closeModal = function () {
    $scope.modalInstance.close();<commit_msg>refactor(games): remove console.log statement in the game controller<commit_after>angular.module('mean.system')
.controller('GameController', ['$scope', 'game', 'dataFactory', '$timeout', '$location', '$modal', 'MakeAWishFactsService', function ($scope, game, dataFactory, $timeout, $location, $modal, MakeAWishFactsService) {
  $scope.hasPickedCards = false;
  $scope.winningCardPicked = false;
  $scope.showTable = false;
  $scope.modalShown = false;
  $scope.game = game;
  $scope.inviteList = [];
  $scope.pickedCards = [];
  var makeAWishFacts = MakeAWishFactsService.getMakeAWishFacts();
  $scope.makeAWishFact = makeAWishFacts.pop();

  $scope.pickCard = function(card) {
    if (!$scope.hasPickedCards) {
      if ($scope.pickedCards.indexOf(card.id) < 0) {
        $scope.pickedCards.push(card.id);
        if (game.curQuestion.numAnswers === 1) {
          $scope.sendPickedCards();
          $scope.hasPickedCards = true;
        } else if (game.curQuestion.numAnswers === 2 &&
          $scope.pickedCards.length === 2) {
          //delay and send
          $scope.hasPickedCards = true;
          $timeout($scope.sendPickedCards, 300);
        }
      } else {
        $scope.pickedCards.pop();
      }
    }
  };

  $scope.pointerCursorStyle = function() {
    if ($scope.isCzar() && $scope.game.state === 'waiting for czar to decide') {
        return {'cursor': 'pointer'};
      } else {
        return {};
      }
  };

  $scope.sendPickedCards = function() {
    game.pickCards($scope.pickedCards);
    $scope.showTable = true;
  };

  $scope.cardIsFirstSelected = function(card) {
    if (game.curQuestion.numAnswers > 1) {
        return card === $scope.pickedCards[0];
      } else {
        return false;
      }
  };

  $scope.cardIsSecondSelected = function(card) {
    if (game.curQuestion.numAnswers > 1) {
        return card === $scope.pickedCards[1];
      } else {
        return false;
      }
  };

  $scope.firstAnswer = function($index){
    if($index % 2 === 0 && game.curQuestion.numAnswers > 1){
        return true;
      } else{
        return false;
      }
  };

  $scope.secondAnswer = function($index){
    if($index % 2 === 1 && game.curQuestion.numAnswers > 1){
        return true;
      } else{
        return false;
      }
  };

  $scope.showFirst = function(card) {
    return game.curQuestion.numAnswers > 1 && $scope.pickedCards[0] === card.id;
  };

  $scope.showSecond = function(card) {
    return game.curQuestion.numAnswers > 1 && $scope.pickedCards[1] === card.id;
  };

  $scope.isCzar = function() {
    return game.czar === game.playerIndex;
  };

  $scope.isPlayer = function($index) {
    return $index === game.playerIndex;
  };

  $scope.isCustomGame = function() {
    return !(/^\d+$/).test(game.gameID) && game.state === 'awaiting players';
  };

  $scope.isPremium = function($index) {
    return game.players[$index].premium;
  };

  $scope.currentCzar = function($index) {
    return $index === game.czar;
  };

  $scope.winningColor = function($index) {
    if (game.winningCardPlayer !== -1 && $index === game.winningCard) {
        return $scope.colors[game.players[game.winningCardPlayer].color];
      } else {
        return '#f9f9f9';
      }
  };

  $scope.pickWinning = function(winningSet) {
    if ($scope.isCzar()) {
      game.pickWinning(winningSet.card[0]);
      $scope.winningCardPicked = true;
    }
  };

  $scope.winnerPicked = function() {
    return game.winningCard !== -1;
  };

  $scope.customCreator = function () {
    if (game.players[0] === undefined) {
      return false;
    } else if (window.user === null) {
      return false;
    }
    return game.players[0].id === window.user._id;
  };

  $scope.isUser = window.user;

  $scope.userEmail = $location.search().email;

  $scope.startGame = function () {
    if (game.players.length < game.playerMinLimit) {
      let message = `You need at least ${game.playerMinLimit} players to start the game`;
      let template = '/views/popup.html';
      showModal(message, template);
    } else if ($scope.isCustomGame()) {
      let message = 'You are about to start a game that will be saved';
      let template = '/views/save-game.html';
      showModal(message, template);
    } else {
      game.startGame();
    }
  };

  $scope.saveGame = function () {
    game.startGame();
    $scope.modalInstance.close();
    const gameId = $location.search().game;
    const link = `/api/games/${gameId}/start`;
    const data = {
      creator: game.players[0].id,
      friends: game.players
    }
    dataFactory.saveGameHistory(link, data)
    .success(function(response) {
      gameKey = response._id;
      $scope.model = 'Game Saved';
      return gameKey;
    })
    .error(function (response) {
      $scope.message = 'Could not save game';
    });
  };

  $scope.closeModal = function () {
    $scope.modalInstance.close();
{'fraction_non_alphanumeric': 0.16012332990750258, 'fraction_numerical': 0.006166495375128468, 'mean_word_length': 2.7355086372360846, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '1757306', 'n_tokens_mistral': 3296, 'n_tokens_neox': 3186, 'n_words': 595}