예제 #1
0
 private List<Club> getNextMatchesClubs(int numberOfMatches) {
   List<MatchDetails> nextMatches = calendarNavigator.getNextMatchesDetails(numberOfMatches);
   List<Club> opponents = new ArrayList<>();
   for (MatchDetails matchDetails : nextMatches) {
     if (matchDetails.isWeAreHostingMatch()) {
       opponents.add(clubNavigator.getClubDetails(matchDetails.getAwayClub()));
     } else {
       opponents.add(clubNavigator.getClubDetails(matchDetails.getHomeClub()));
     }
   }
   for (Club club : opponents) {
     clubNavigator.loadClubPlayers(club);
     refreshClubPlayers(club);
   }
   return opponents;
 }
예제 #2
0
  private void refreshClubPlayers(Club club) {
    playerNavigator.refreshPlayers(club.getSeniorPlayers());
    playerNavigator.refreshPlayers(club.getYouthPlayers());

    // there may be players that are youth but trained in senior squad.
    List<Player> youthPlayersOnSeniorSquad = new ArrayList<>();
    for (Player player : club.getSeniorPlayers()) {
      if (player.getAge() <= 18) {
        youthPlayersOnSeniorSquad.add(player);
      }
    }
    club.getSeniorPlayers().removeAll(youthPlayersOnSeniorSquad);
    club.getYouthPlayers().addAll(youthPlayersOnSeniorSquad);

    Collections.sort(club.getSeniorPlayers(), DugoutUtils.PLAYER_SKILL_COMPARATOR);
    Collections.sort(club.getYouthPlayers(), DugoutUtils.PLAYER_SKILL_COMPARATOR);
  }