Add rating to the client (#1498)

This commit is contained in:
Quercitron 2016-05-17 17:27:43 +03:00
parent 972d59aa37
commit c781728b97
16 changed files with 234 additions and 52 deletions

View file

@ -58,6 +58,7 @@ public class MatchView implements Serializable {
private Date endTime;
private boolean replayAvailable;
private final boolean isTournament;
private boolean rated;
public MatchView(Table table) {
this.tableId = table.getId();
@ -117,7 +118,7 @@ public class MatchView implements Serializable {
this.startTime = match.getStartTime();
this.endTime = match.getEndTime();
this.replayAvailable = match.isReplayAvailable();
this.rated = match.getOptions().isRated();
}
// used for tournaments
@ -153,6 +154,7 @@ public class MatchView implements Serializable {
this.startTime = table.getTournament().getStartTime();
this.endTime = table.getTournament().getEndTime();
this.replayAvailable = false;
this.rated = table.getTournament().getOptions().getMatchOptions().isRated();
}
public UUID getMatchId() {
@ -207,4 +209,7 @@ public class MatchView implements Serializable {
return tableId;
}
public boolean isRated() {
return rated;
}
}

View file

@ -45,6 +45,9 @@ public class SeatView implements Serializable {
private final String playerName;
private final String playerType;
private final String history;
private final int generalRating;
private final int constructedRating;
private final int limitedRating;
public SeatView(Seat seat) {
if (seat.getPlayer() != null) {
@ -53,15 +56,24 @@ public class SeatView implements Serializable {
if (seat.getPlayer().getUserData() == null) {
this.flagName = UserData.getDefaultFlagName();
this.history = "";
this.generalRating = 0;
this.constructedRating = 0;
this.limitedRating = 0;
} else {
this.flagName = seat.getPlayer().getUserData().getFlagName();
this.history = seat.getPlayer().getUserData().getHistory();
this.generalRating = seat.getPlayer().getUserData().getGeneralRating();
this.constructedRating = seat.getPlayer().getUserData().getConstructedRating();
this.limitedRating = seat.getPlayer().getUserData().getLimitedRating();
}
} else {
// Empty seat
this.playerName = "";
this.flagName = "";
this.history = "";
this.generalRating = 0;
this.constructedRating = 0;
this.limitedRating = 0;
}
this.playerType = seat.getPlayerType();
}
@ -86,4 +98,15 @@ public class SeatView implements Serializable {
return history;
}
public int getGeneralRating() {
return generalRating;
}
public int getConstructedRating() {
return constructedRating;
}
public int getLimitedRating() {
return limitedRating;
}
}

View file

@ -63,6 +63,8 @@ public class TableView implements Serializable {
private List<SeatView> seats = new ArrayList<>();
private List<UUID> games = new ArrayList<>();
private final String quitRatio;
private final boolean limited;
private final boolean rated;
public TableView(Table table) {
this.tableId = table.getId();
@ -132,6 +134,8 @@ public class TableView implements Serializable {
this.additionalInfo = addInfo.toString();
this.skillLevel = table.getMatch().getOptions().getSkillLevel();
this.quitRatio = Integer.toString(table.getMatch().getOptions().getQuitRatio());
this.limited = table.getMatch().getOptions().isLimited();
this.rated = table.getMatch().getOptions().isRated();
} else {
// TOURNAMENT
if (table.getTournament().getOptions().getNumberRounds() > 0) {
@ -179,6 +183,8 @@ public class TableView implements Serializable {
this.deckType = table.getDeckType() + " " + table.getTournament().getBoosterInfo() + (tableNameInfo != null ? tableNameInfo : "");
this.skillLevel = table.getTournament().getOptions().getMatchOptions().getSkillLevel();
this.quitRatio = Integer.toString(table.getTournament().getOptions().getQuitRatio());
this.limited = table.getTournament().getOptions().getMatchOptions().isLimited();
this.rated = table.getTournament().getOptions().getMatchOptions().isRated();
}
}
@ -236,4 +242,12 @@ public class TableView implements Serializable {
public String getQuitRatio() {
return quitRatio;
}
public boolean isLimited() {
return limited;
}
public boolean isRated() {
return rated;
}
}

View file

@ -45,9 +45,13 @@ public class UsersView implements Serializable {
private final int tourneyQuitRatio;
private final String infoGames;
private final String infoPing;
private final int generalRating;
private final int constructedRating;
private final int limitedRating;
public UsersView(String flagName, String userName, String matchHistory, int matchQuitRatio,
String tourneyHistory, int tourneyQuitRatio, String infoGames, String infoPing) {
String tourneyHistory, int tourneyQuitRatio, String infoGames, String infoPing,
int generalRating, int constructedRating, int limitedRating) {
this.flagName = flagName;
this.matchHistory = matchHistory;
this.matchQuitRatio = matchQuitRatio;
@ -56,6 +60,9 @@ public class UsersView implements Serializable {
this.userName = userName;
this.infoGames = infoGames;
this.infoPing = infoPing;
this.generalRating = generalRating;
this.constructedRating = constructedRating;
this.limitedRating = limitedRating;
}
public String getFlagName() {
@ -90,4 +97,15 @@ public class UsersView implements Serializable {
return infoPing;
}
public int getGeneralRating() {
return generalRating;
}
public int getConstructedRating() {
return constructedRating;
}
public int getLimitedRating() {
return limitedRating;
}
}