<commit_before>'use strict';

angular
  .module('app.players')
  /**
   * @ngdoc controller
   * @name app.players.controller:PlayersController
   * @description
   * The controller for the players list.
   */
  .controller('PlayersController', [
    'PlayersAdapter',
    'PlayerFactory',
    function(PlayersAdapter, PlayerFactory) {
      var vm = this;

      // Exposes public methods
      vm.addNewPlayer = addNewPlayer;
      vm.areSelectedPlayersEnough = areSelectedPlayersEnough;
      vm.deselectPlayer = deselectPlayer;
      vm.isPlayerSelected = isPlayerSelected;
      vm.selectPlayer = selectPlayer;
      vm.togglePlayer = togglePlayer;

      /**
       * @ngdoc property
       * @name PlayersController#adapter
       * @type {Object}
       * @propertyOf app.players.controller:PlayersController
       */
      vm.adapter = PlayersAdapter;

      /**
       * @ngdoc method
       * @name PlayersController#isPlayerSelected
       * @kind function
       * @methodOf app.players.controller:PlayersController
       * @param {Object} player The given player
       * @return {boolean} True if the given player has been already selected.
       * @description
       * Determines if the give player has been already selected or not.
       */
      function isPlayerSelected(player) {
        return vm.adapter.getSelectedPlayers().indexOf(player) >= 0;
      }

      /**
       * @ngdoc method
       * @name PlayersController#togglePlayer<commit_msg>fixed #36 isPlayerSelected does not work as expected<commit_after>'use strict';

angular
  .module('app.players')
  /**
   * @ngdoc controller
   * @name app.players.controller:PlayersController
   * @description
   * The controller for the players list.
   */
  .controller('PlayersController', [
    'PlayersAdapter',
    'PlayerFactory',
    function(PlayersAdapter, PlayerFactory) {
      var vm = this;

      // Exposes public methods
      vm.addNewPlayer = addNewPlayer;
      vm.areSelectedPlayersEnough = areSelectedPlayersEnough;
      vm.deselectPlayer = deselectPlayer;
      vm.isPlayerSelected = isPlayerSelected;
      vm.selectPlayer = selectPlayer;
      vm.togglePlayer = togglePlayer;

      /**
       * @ngdoc property
       * @name PlayersController#adapter
       * @type {Object}
       * @propertyOf app.players.controller:PlayersController
       */
      vm.adapter = PlayersAdapter;

      /**
       * @ngdoc method
       * @name PlayersController#isPlayerSelected
       * @kind function
       * @methodOf app.players.controller:PlayersController
       * @param {Object} player The given player
       * @return {boolean} True if the given player has been already selected.
       * @description
       * Determines if the give player has been already selected or not.
       */
      function isPlayerSelected(player) {
        var isPlayerSelected = false;
        angular.forEach(vm.adapter.getSelectedPlayers(), function(selectedPlayer) {
          if (selectedPlayer.id === player.id) {
            isPlayerSelected = true;
          }
        });
        return isPlayerSelected;
      }

      /**
       * @ngdoc method
       * @name PlayersController#togglePlayer
{'fraction_non_alphanumeric': 0.09368123231688148, 'fraction_numerical': 0.0009430996541967935, 'mean_word_length': 2.5712682379349046, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '6879521', 'n_tokens_mistral': 857, 'n_tokens_neox': 826, 'n_words': 203}