* Tournament - Show players of tournament sorted by their tournament points.

This commit is contained in:
LevelX2 2014-02-20 15:03:14 +01:00
parent e40b44ed79
commit 2b2594d993
4 changed files with 15 additions and 7 deletions

View file

@ -517,7 +517,7 @@ class TournamentMatchesTableModel extends AbstractTableModel {
private boolean watchingAllowed;
public void loadData(TournamentView tournament) {
List<TournamentGameView> views = new ArrayList<TournamentGameView>();
List<TournamentGameView> views = new ArrayList<>();
watchingAllowed = tournament.isWatchingAllowed();
for (RoundView round: tournament.getRounds()) {
for (TournamentGameView game: round.getGames()) {

View file

@ -36,7 +36,7 @@ import mage.game.tournament.TournamentPlayer;
*
* @author BetaSteward_at_googlemail.com
*/
public class TournamentPlayerView implements Serializable {
public class TournamentPlayerView implements Serializable, Comparable{
private static final long serialVersionUID = 1L;
private final String name;
@ -77,4 +77,9 @@ public class TournamentPlayerView implements Serializable {
return quit;
}
@Override
public int compareTo(Object t) {
return ((TournamentPlayerView) t).getPoints() - this.getPoints();
}
}

View file

@ -30,6 +30,7 @@ package mage.view;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import mage.game.tournament.Round;
@ -51,9 +52,10 @@ public class TournamentView implements Serializable {
private final boolean watchingAllowed;
private final List<RoundView> rounds = new ArrayList<RoundView>();
private final List<TournamentPlayerView> players = new ArrayList<TournamentPlayerView>();
private final List<RoundView> rounds = new ArrayList<>();
private final List<TournamentPlayerView> players = new ArrayList<>();
@SuppressWarnings("unchecked")
public TournamentView(Tournament tournament) {
tournamentName = tournament.getOptions().getName();
@ -65,6 +67,7 @@ public class TournamentView implements Serializable {
for (TournamentPlayer player: tournament.getPlayers()) {
players.add(new TournamentPlayerView(player));
}
Collections.sort(players);
for (Round round: tournament.getRounds()) {
rounds.add(new RoundView(round));
}

View file

@ -59,13 +59,13 @@ import org.apache.log4j.Logger;
public abstract class TournamentImpl implements Tournament {
protected UUID id = UUID.randomUUID();
protected List<Round> rounds = new CopyOnWriteArrayList<Round>();
protected Map<UUID, TournamentPlayer> players = new HashMap<UUID, TournamentPlayer>();
protected List<Round> rounds = new CopyOnWriteArrayList<>();
protected Map<UUID, TournamentPlayer> players = new HashMap<>();
protected static Random rnd = new Random();
protected String matchName;
protected TournamentOptions options;
protected TournamentType tournamentType;
protected List<ExpansionSet> sets = new ArrayList<ExpansionSet>();
protected List<ExpansionSet> sets = new ArrayList<>();
protected String setsInfoShort;
protected TableEventSource tableEventSource = new TableEventSource();