Skip to content

Commit

Permalink
Allow for a mass-start runner finishing before the runner in the prev…
Browse files Browse the repository at this point in the history
…ious leg.
  • Loading branch information
grahamkirby committed Feb 4, 2024
1 parent 844c163 commit 3fc2a71
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/main/java/lap_race/Results.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ private record IndividualLegStart(int bib_number, int leg_number, Duration start
// time recorded but were declared DNF due to missing checkpoints.
String dnf_legs_string;

String leg_times_swap_string;

Team[] entries;
RawResult[] raw_results;
OverallResult[] overall_results;
Expand Down Expand Up @@ -124,10 +126,11 @@ private void readProperties() {
working_directory_path = Paths.get(properties.getProperty("WORKING_DIRECTORY"));
number_of_legs = Integer.parseInt(properties.getProperty("NUMBER_OF_LEGS"));
dnf_legs_string = properties.getProperty("DNF_LEGS");
leg_times_swap_string = getPropertyWithDefault("LEG_TIME_SWAPS", null);
start_offset = parseTime(getPropertyWithDefault("START_OFFSET", ZERO_TIME_STRING));
}

private void configureHelpers() throws IOException {
private void configureHelpers() {

input = new Input(this);

Expand Down Expand Up @@ -281,6 +284,22 @@ private void fillLegFinishTimes() {
// However, it might still be set to DNF in fillDNFs() if the runner missed a checkpoint.
leg_results[leg_index].DNF = false;
}

if (leg_times_swap_string != null) {
for (final String leg_time_swap_string : leg_times_swap_string.split(",")) {

final String[] swap = leg_time_swap_string.split("/");
final int bib_number = Integer.parseInt(swap[0]);
final int leg_number = Integer.parseInt(swap[1]);
final int leg_index = leg_number - 1;

final OverallResult result = overall_results[findIndexOfTeamWithBibNumber(bib_number)];

LegResult temp = result.leg_results[leg_index - 1];
result.leg_results[leg_index - 1] = result.leg_results[leg_index];
result.leg_results[leg_index] = temp;
}
}
}

private void fillDNFs() {
Expand Down Expand Up @@ -413,7 +432,7 @@ int findIndexOfTeamWithBibNumber(final int bib_number) {

throw new RuntimeException("unregistered team: " + bib_number);
}
private void allocatePrizes() throws IOException {
private void allocatePrizes() {

prizes.allocatePrizes();
}
Expand Down

0 comments on commit 3fc2a71

Please sign in to comment.