mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-14 22:43:57 +00:00
Merge remote-tracking branch 'server/bug4661' into bug4661
Change-Id: I7fbe862ff06838275bb2003f1a0f087923f0e3f1
This commit is contained in:
commit
2d7572cb1c
7 files changed
+42
-26
No files matched your search
+1
-8
@@ -209,15 +209,8 @@ public class RaceResultOfCompetitorWithContext implements HasRaceResultOfCompeti
|
||||
|
||||
@Override
|
||||
public Boolean isWin() {
|
||||
Leaderboard leaderboard = getLeaderboard();
|
||||
final TimePoint now = MillisecondsTimePoint.now();
|
||||
double points = leaderboard.getTotalPoints(competitor, raceColumn, now);
|
||||
if (leaderboard.getScoringScheme().isHigherBetter()) {
|
||||
double competitorCount = Util.size(leaderboard.getCompetitors());
|
||||
return points >= (competitorCount - 0.05);
|
||||
} else {
|
||||
return points <= 1.05;
|
||||
}
|
||||
return getLeaderboard().isWin(competitor, raceColumn, now);
|
||||
}
|
||||
|
||||
}
|
||||
+18
-1
@@ -604,4 +604,21 @@ public interface Leaderboard extends LeaderboardBase, HasRaceColumns {
|
||||
* leaderboard.
|
||||
*/
|
||||
boolean hasScores(Competitor competitor, TimePoint timePoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a racecolumn evaluates to be a win for the given competitor at the given timepoint.
|
||||
* If the competitor is not scored for this race, false is returned
|
||||
*/
|
||||
default boolean isWin(Competitor competitor, RaceColumn raceColumn, TimePoint timePoint) {
|
||||
Double points = getTotalPoints(competitor, raceColumn, timePoint);
|
||||
if(points == null) {
|
||||
return false;
|
||||
}
|
||||
if (getScoringScheme().isHigherBetter()) {
|
||||
double competitorCount = Util.size(getCompetitors());
|
||||
return points >= (competitorCount - 0.05);
|
||||
} else {
|
||||
return points <= 1.05;
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -151,14 +151,14 @@ public interface ScoringScheme extends Serializable {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If isMedalWinAmountCriteria returns true, this will be the amount of races that must be won, in order to win the
|
||||
* medal series instantly
|
||||
*/
|
||||
default int getTargetAmountOfMedalRaceWins() {
|
||||
throw new IllegalStateException("This call is not valid for this scoringSheme");
|
||||
}
|
||||
|
||||
default boolean doesCountAsWinInMedalRace(Double o1Score, RaceColumn raceColumn) {
|
||||
throw new IllegalStateException("This call is not valid for this scoringSheme");
|
||||
}
|
||||
|
||||
/**
|
||||
* Usually, the scores in each leaderboard column count as they are for the overall score. However, if a column is a
|
||||
* medal race column it usually counts double. Under certain circumstances, columns may also count with factors
|
||||
|
||||
java/com.sap.sailing.domain/src/com/sap/sailing/domain/leaderboard/impl/AbstractLeaderboardImpl.java
Executable → Regular
+1
-1
@@ -281,5 +281,5 @@ public abstract class AbstractLeaderboardImpl extends AbstractSimpleLeaderboardI
|
||||
RegattaLogBoatDeregistrator<RegattaLog, RegattaLogEvent, RegattaLogEventVisitor> deregisterer = new RegattaLogBoatDeregistrator<>(regattaLog, boats, regattaLogEventAuthorForAbstractLeaderboard);
|
||||
deregisterer.deregister(deregisterer.analyze());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+2
@@ -959,5 +959,7 @@ public abstract class AbstractSimpleLeaderboardImpl extends AbstractLeaderboardW
|
||||
return Util.getDominantObject(StreamSupport.stream(allBoats.spliterator(), /* parallel */ false)
|
||||
.map(b -> b.getBoatClass()).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+11
-2
@@ -196,8 +196,8 @@ public class LeaderboardTotalRankComparator implements Comparator<Competitor> {
|
||||
// (tracked or manual) is sufficient
|
||||
preemptiveColumnResult = compareByMedalRaceParticipation(o1Score, o2Score);
|
||||
if (scoringScheme.isMedalWinAmountCriteria()) {
|
||||
numberOfMedalRacesWonO1 += scoringScheme.doesCountAsWinInMedalRace(o1Score, raceColumn) ? 1 : 0;
|
||||
numberOfMedalRacesWonO2 += scoringScheme.doesCountAsWinInMedalRace(o2Score, raceColumn) ? 1 : 0;
|
||||
numberOfMedalRacesWonO1 += leaderboard.isWin(o1, raceColumn, timePoint) ? 1 : 0;
|
||||
numberOfMedalRacesWonO2 += leaderboard.isWin(o2, raceColumn, timePoint) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
if (preemptiveColumnResult == 0 && raceColumn.isTotalOrderDefinedByFleet()) {
|
||||
@@ -261,6 +261,11 @@ public class LeaderboardTotalRankComparator implements Comparator<Competitor> {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares by the number of races won in the medal series. If one of the competitors reached the target of won
|
||||
* races (defined by {@link ScoringScheme#getTargetAmountOfMedalRaceWins()} he is ranked better than the other. If
|
||||
* none of the competitors reached the target, they are ranked equally even if one has more wins.
|
||||
*/
|
||||
private int compareByMedalRacesWon(int numberOfMedalRacesWonO1, int numberOfMedalRacesWonO2) {
|
||||
int targetAmount = scoringScheme.getTargetAmountOfMedalRaceWins();
|
||||
// if one reaches the targetamount, this has priority, else proceed with normal low points scoring (eg. not
|
||||
@@ -274,6 +279,10 @@ public class LeaderboardTotalRankComparator implements Comparator<Competitor> {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares by the scores of a single race column. If only one of the competitors has a result this competitor is
|
||||
* ranked better than the other one.
|
||||
*/
|
||||
private int compareBySingleRaceColumnScore(Double o1CarryForwardInMedals, Double o2CarryForwardInMedals) {
|
||||
if (o1CarryForwardInMedals == null && o2CarryForwardInMedals == null) {
|
||||
return 0;
|
||||
|
||||
+5
-10
@@ -3,6 +3,11 @@ package com.sap.sailing.domain.leaderboard.impl;
|
||||
import com.sap.sailing.domain.base.RaceColumn;
|
||||
import com.sap.sailing.domain.common.ScoringSchemeType;
|
||||
|
||||
/**
|
||||
* This class is a derivation of the LowPointScoring scheme. The first participant in the medal series, that wins two
|
||||
* races is ranked as the first. The participant that has the score 1 in the preSeries carry column only must reach one
|
||||
* additional victory. This Scheme will change the default scoring factor for medal races to 1, usually 2 is used
|
||||
*/
|
||||
public class LowPointFirstToWinTwoRaces extends LowPoint {
|
||||
private static final long serialVersionUID = 7072175334160798617L;
|
||||
|
||||
@@ -31,16 +36,6 @@ public class LowPointFirstToWinTwoRaces extends LowPoint {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesCountAsWinInMedalRace(Double score, RaceColumn raceColumn) {
|
||||
if(score != null) {
|
||||
double minScore = 1 * getScoreFactor(raceColumn);
|
||||
return score == minScore;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getScoreFactor(RaceColumn a) {
|
||||
Double factor = a.getExplicitFactor();
|
||||
|
||||
Reference in new issue
Block a user