forked from External/mage
Add allowed quit ratio option to match option and tourney option.
This commit is contained in:
parent
ef3fbffe11
commit
284c36b756
16 changed files with 292 additions and 74 deletions
|
|
@ -530,10 +530,14 @@ public class User {
|
|||
userStats = UserStatsRepository.instance.getUser(this.userName);
|
||||
if (userStats != null) {
|
||||
userData.setMatchHistory(userStatsToMatchHistory(userStats.getProto()));
|
||||
userData.setMatchQuitRatio(userStatsToMatchQuitRatio(userStats.getProto()));
|
||||
userData.setTourneyHistory(userStatsToTourneyHistory(userStats.getProto()));
|
||||
userData.setTourneyQuitRatio(userStatsToTourneyQuitRatio(userStats.getProto()));
|
||||
} else {
|
||||
userData.setMatchHistory("0");
|
||||
userData.setMatchQuitRatio(0);
|
||||
userData.setTourneyHistory("0");
|
||||
userData.setTourneyQuitRatio(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -544,6 +548,13 @@ public class User {
|
|||
return "<not available>";
|
||||
}
|
||||
|
||||
public int getMatchQuitRatio() {
|
||||
if (userData != null) {
|
||||
return userData.getMatchQuitRatio();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String getTourneyHistory() {
|
||||
if (userData != null) {
|
||||
return userData.getTourneyHistory();
|
||||
|
|
@ -556,6 +567,13 @@ public class User {
|
|||
" Tourneys: " + userStatsToTourneyHistory(proto);
|
||||
}
|
||||
|
||||
public int getTourneyQuitRatio() {
|
||||
if (userData != null) {
|
||||
return userData.getTourneyQuitRatio();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static String userStatsToMatchHistory(ResultProtos.UserStatsProto proto) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(proto.getMatches());
|
||||
|
|
@ -577,6 +595,17 @@ public class User {
|
|||
return builder.toString();
|
||||
}
|
||||
|
||||
public static int userStatsToMatchQuitRatio(ResultProtos.UserStatsProto proto) {
|
||||
int matches = proto.getMatches();
|
||||
if (matches == 0) {
|
||||
return 0;
|
||||
}
|
||||
int quits = proto.getMatchesIdleTimeout() +
|
||||
proto.getMatchesTimerTimeout() +
|
||||
proto.getMatchesQuit();
|
||||
return 100 * quits / matches;
|
||||
}
|
||||
|
||||
public static String userStatsToTourneyHistory(ResultProtos.UserStatsProto proto) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(proto.getTourneys());
|
||||
|
|
@ -598,6 +627,17 @@ public class User {
|
|||
return builder.toString();
|
||||
}
|
||||
|
||||
public static int userStatsToTourneyQuitRatio(ResultProtos.UserStatsProto proto) {
|
||||
int tourneys = proto.getTourneys();
|
||||
if (tourneys == 0) {
|
||||
return 0;
|
||||
}
|
||||
int quits = proto.getTourneysQuitDuringDrafting() +
|
||||
proto.getTourneysQuitDuringConstruction() +
|
||||
proto.getTourneysQuitDuringRound();
|
||||
return 100 * quits / tourneys;
|
||||
}
|
||||
|
||||
private static void joinStrings(StringBuilder joined, List<String> strings, String separator) {
|
||||
for (int i = 0; i < strings.size(); ++i) {
|
||||
if (i > 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue