Bug 4661: Ensures that having more wins that required also counts as

overall winner. If more than one competitor reached the requires wins,
the one with more wins will be ranked better.
This commit is contained in:
Steffen Schaefer committed 2018-07-19 10:44:06 +02:00
1 parent 2580435a52
commit ea92ee34cb
1 file changed
+4 -12
@@ -270,19 +270,11 @@ public class LeaderboardTotalRankComparator implements Comparator<Competitor> {
*/
private int compareByMedalRacesWon(int numberOfMedalRacesWonO1, int numberOfMedalRacesWonO2) {
final int result;
if (numberOfMedalRacesWonO1 == numberOfMedalRacesWonO2) {
// If both competitors have an equal amount of wins it doesn't matter if they reached the target.
// In this case we just can't say who is better based on the number of wins.
result = 0;
final int targetAmount = scoringScheme.getTargetAmountOfMedalRaceWins();
if (numberOfMedalRacesWonO1 >= targetAmount || numberOfMedalRacesWonO2 >= targetAmount) {
result = Integer.compare(numberOfMedalRacesWonO2, numberOfMedalRacesWonO1);
} else {
final int targetAmount = scoringScheme.getTargetAmountOfMedalRaceWins();
if (numberOfMedalRacesWonO1 == targetAmount) {
result = -1;
} else if (numberOfMedalRacesWonO2 == targetAmount) {
result = 1;
} else {
result = 0;
}
result = 0;
}
return result;
}