Search in sources :

Example 1 with MatchView

use of mage.view.MatchView in project mage by magefree.

the class UserNameSorter method update.

private void update() {
    List<Table> allTables = new ArrayList<>(tables.values());
    allTables.sort(new TableListSorter());
    List<MatchView> matchList = new ArrayList<>();
    List<TableView> tableList = new ArrayList<>();
    for (Table table : allTables) {
        if (table.getState() != TableState.FINISHED) {
            tableList.add(new TableView(table));
        } else if (matchList.size() < 50) {
            matchList.add(new MatchView(table));
        } else {
            // more since 50 matches finished since this match so removeUserFromAllTablesAndChat it
            if (table.isTournament()) {
                managerFactory.tournamentManager().removeTournament(table.getTournament().getId());
            }
            this.removeTable(table.getId());
        }
    }
    tableView = tableList;
    matchView = matchList;
    List<UsersView> users = new ArrayList<>();
    for (User user : managerFactory.userManager().getUsers()) {
        if (user.getUserState() != User.UserState.Offline && !user.getName().equals("Admin")) {
            try {
                users.add(new UsersView(user.getUserData().getFlagName(), user.getName(), user.getMatchHistory(), user.getMatchQuitRatio(), user.getTourneyHistory(), user.getTourneyQuitRatio(), user.getGameInfo(), user.getPingInfo(), user.getUserData().getGeneralRating(), user.getUserData().getConstructedRating(), user.getUserData().getLimitedRating()));
            } catch (Exception ex) {
                LOGGER.fatal("User update exception: " + user.getName() + " - " + ex.toString(), ex);
                users.add(new UsersView((user.getUserData() != null && user.getUserData().getFlagName() != null) ? user.getUserData().getFlagName() : "world", user.getName() != null ? user.getName() : "<no name>", user.getMatchHistory() != null ? user.getMatchHistory() : "<no match history>", user.getMatchQuitRatio(), user.getTourneyHistory() != null ? user.getTourneyHistory() : "<no tourney history>", user.getTourneyQuitRatio(), "[exception]", user.getPingInfo() != null ? user.getPingInfo() : "<no ping>", user.getUserData() != null ? user.getUserData().getGeneralRating() : 0, user.getUserData() != null ? user.getUserData().getConstructedRating() : 0, user.getUserData() != null ? user.getUserData().getLimitedRating() : 0));
            }
        }
    }
    users.sort((one, two) -> one.getUserName().compareToIgnoreCase(two.getUserName()));
    List<RoomUsersView> roomUserInfo = new ArrayList<>();
    roomUserInfo.add(new RoomUsersView(users, managerFactory.gameManager().getNumberActiveGames(), managerFactory.threadExecutor().getActiveThreads(managerFactory.threadExecutor().getGameExecutor()), managerFactory.configSettings().getMaxGameThreads()));
    roomUsersView = roomUserInfo;
}
Also used : Table(mage.game.Table) User(mage.server.User) MatchView(mage.view.MatchView) MageException(mage.MageException) GameException(mage.game.GameException) RoomUsersView(mage.view.RoomUsersView) UsersView(mage.view.UsersView) RoomUsersView(mage.view.RoomUsersView) TableView(mage.view.TableView)

Aggregations

MageException (mage.MageException)1 GameException (mage.game.GameException)1 Table (mage.game.Table)1 User (mage.server.User)1 MatchView (mage.view.MatchView)1 RoomUsersView (mage.view.RoomUsersView)1 TableView (mage.view.TableView)1 UsersView (mage.view.UsersView)1