private void scoreGoal(int minute) {
    if (minuteForGoalIndex < scoredGoals - 1) {
      ++minuteForGoalIndex;
    } else {
      hasGoals = false;
    }
    List<Player> playersGroupToScore = getPlayerGroupScored();
    int scoredPlayerIndex = Randomization.RANDOM.nextInt(playersGroupToScore.size());
    Player whoScored = playersGroupToScore.get(scoredPlayerIndex);
    boolean fromPenalty = Randomization.RANDOM.nextInt(HUNDRED) < CHANCE_TO_GOAL_FROM_PENALTY;
    if (fromPenalty) {
      events.add(new Event(EventType.PENALTY, minute, whoScored, team));
      events.add(new Event(EventType.GOAL, minute, whoScored, team));
    } else {
      events.add(new Event(EventType.GOAL, minute, whoScored, team));
      Player assistent;
      if (Randomization.RANDOM.nextInt(HUNDRED) < CHANCE_TO_ASSIST) {
        do {
          List<Player> playersGroupToAssist = getPlayerGroupAssist();
          int assistPlayerIndex = Randomization.RANDOM.nextInt(playersGroupToAssist.size());
          assistent = playersGroupToAssist.get(assistPlayerIndex);
        } while (assistent == whoScored);

        events.add(new Event(EventType.ASSIST, minute, assistent, team));
      }
    }
  }
 private List<Player> getPlayerGroupScored() {
   int playersGroupChance = Randomization.RANDOM.nextInt(HUNDRED);
   List<Player> playersGroup;
   if (playersGroupChance < CHANCE_SCORE_GOAL_BY_FORWARD) {
     playersGroup = getPlayerGroup(startPlayers, GlobalPosition.FORWARD);
   } else if (playersGroupChance < CHANCE_TO_SCORE_GOAL_BY_MIDFIELDER) {
     playersGroup = getPlayerGroup(startPlayers, GlobalPosition.MIDFIELDER);
   } else {
     playersGroup = getPlayerGroup(startPlayers, GlobalPosition.DEFENDER);
   }
   return playersGroup;
 }
 private void init(Team teamForInit) {
   for (Player player : teamForInit.getStartPlayers()) {
     startPlayers.add(new PlayerWithCard(player));
   }
   for (Player player : teamForInit.getSubstitutes()) {
     reservePlayers.add(new PlayerWithCard(player));
   }
   minutesForGoal = new int[scoredGoals];
   for (int i = 0; i < scoredGoals; i++) {
     minutesForGoal[i] = Randomization.RANDOM.nextInt(MINUTES_PER_MATCH) + 1;
   }
   Arrays.sort(minutesForGoal);
 }
 private List<Player> getPlayerGroupAssist() {
   List<Player> playersGroup;
   int playersGroupChance = Randomization.RANDOM.nextInt(HUNDRED);
   if (playersGroupChance < CHANCE_TO_ASSIST_BY_GOALKEEPER) {
     playersGroup = getPlayerGroup(startPlayers, GlobalPosition.GOALKEEPER);
   } else if (playersGroupChance < CHANCE_TO_ASSIST_BY_DEFENDER) {
     playersGroup = getPlayerGroup(startPlayers, GlobalPosition.DEFENDER);
   } else if (playersGroupChance < CHANCE_TO_ASSIST_BY_MIDFIELDER) {
     playersGroup = getPlayerGroup(startPlayers, GlobalPosition.MIDFIELDER);
   } else {
     playersGroup = getPlayerGroup(startPlayers, GlobalPosition.FORWARD);
   }
   return playersGroup;
 }
 private List<Event> createEvents(int minute) {
   for (PlayerWithCard playerWithCard : startPlayers) {
     Player player = playerWithCard.player;
     player.addFatifue(Randomization.RANDOM.nextDouble());
     player.addExperience(DEFAULT_EXPERIENCE_VALUE * experienceCoeff);
   }
   int chance = Randomization.RANDOM.nextInt(THOUSAND);
   if (chance < YELLOW_CARD_CHANCE) {
     int playerIndex = Randomization.RANDOM.nextInt(startPlayers.size());
     PlayerWithCard playerWithCard = startPlayers.get(playerIndex);
     Player player = playerWithCard.player;
     player.addYellowCard();
     events.add(new Event(EventType.YELLOW_CARD, minute, player, team));
     if (playerWithCard.yellowCardsCount == 1) {
       removePlayer(minute, playerIndex);
     } else {
       ++playerWithCard.yellowCardsCount;
     }
   } else if (chance < RED_CARD_CHANCE) {
     int playerIndex = Randomization.RANDOM.nextInt(startPlayers.size());
     removePlayer(minute, playerIndex);
   } else if (chance < INJURE_CHANCE) {
     int playerIndex = Randomization.RANDOM.nextInt(startPlayers.size());
     PlayerWithCard injured = startPlayers.get(playerIndex);
     Player injuredPlayer = injured.player;
     events.add(new Event(EventType.INJURE, minute, injuredPlayer, team));
     injuredPlayer.setInjured(InjureType.getInjure(Randomization.RANDOM.nextInt(HUNDRED)));
     if (substitutesCount < MAX_SUBSTITUTIONS_COUNT) {
       changePlayer(minute, injured);
     }
   }
   if (minute > PREFERRED_TIME_TO_CHANGE_PLAYER) {
     if (chance < SUBSTITUTE_CHANCE && substitutesCount < MAX_SUBSTITUTIONS_COUNT) {
       PlayerWithCard mostTired = findMostTired(startPlayers);
       changePlayer(minute, mostTired);
     }
   }
   if (hasGoals && minutesForGoal[minuteForGoalIndex] == minute) {
     scoreGoal(minute);
   }
   return events;
 }