Skip to content

Commit

Permalink
invited/extra markers for ranks and names on attempt+scoreboard;
Browse files Browse the repository at this point in the history
closes #993
  • Loading branch information
jflamy committed Aug 5, 2024
1 parent 838e54d commit df7cc15
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 66 deletions.
1 change: 0 additions & 1 deletion owlcms/src/main/java/app/owlcms/data/athlete/Athlete.java
Original file line number Diff line number Diff line change
Expand Up @@ -2734,7 +2734,6 @@ public int getSnatchPoints() {
}

public int getSnatchRank() {

int snatchRank;
if (getMainRankings() != null) {
snatchRank = getMainRankings().getSnatchRank();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,10 +644,10 @@ public static TopScore topScore(List<Athlete> sortedAthletes, int nbAthletes) {
private static void assignEligibleCategoryRanks(List<Athlete> absoluteOrderList, Ranking rankingType) {
MultiCategoryRankSetter rt = new MultiCategoryRankSetter();
for (Athlete curLifter : absoluteOrderList) {
if (curLifter.isEligibleForIndividualRanking()) {
//if (curLifter.isEligibleForIndividualRanking()) {
final double rankingValue = Ranking.getRankingValue(curLifter, rankingType);
rt.increment(curLifter, rankingType, rankingValue);
}
//}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ public void increment(Athlete a, Ranking r, double rankingValue) {
Category category = a.getCategory();
boolean eligible = a.isEligibleForIndividualRanking();
boolean zero = rankingValue <= 0;
// logger.debug("a {} v {} z {} e {}", a.getShortName(), rankingValue, zero,
// eligible);

int value = eligible ? (zero ? 0 : ++this.rank) : -1;
int rank = eligible ? (rankingValue == 0 ? 0 : ++this.rank) : -1;
logger.warn("a {} v {} z {} e {} rank={}", a.getShortName(), rankingValue, zero, eligible, rank);
switch (r) {
case SNATCH:
case CLEANJERK:
Expand All @@ -49,31 +48,31 @@ public void increment(Athlete a, Ranking r, double rankingValue) {
doCategoryBasedRankings(a, r, category, zero);
break;
case BW_SINCLAIR:
a.setSinclairRank(value);
a.setSinclairRank(rank);
break;
case CAT_SINCLAIR:
a.setCatSinclairRank(value);
a.setCatSinclairRank(rank);
break;
case SNATCH_CJ_TOTAL:
a.setCombinedRank(value);
a.setCombinedRank(rank);
break;
case ROBI:
a.setRobiRank(value);
a.setRobiRank(rank);
break;
case SMM:
a.setSmhfRank(value);
a.setSmhfRank(rank);
break;
case QPOINTS:
a.setqPointsRank(value);
a.setqPointsRank(rank);
break;
case QAGE:
a.setqAgeRank(value);
a.setqAgeRank(rank);
break;
case GAMX:
a.setGamxRank(value);
a.setGamxRank(rank);
break;
case AGEFACTORS:
a.setAgeAdjustedTotalRank(value);
a.setAgeAdjustedTotalRank(rank);
}
}

Expand All @@ -92,41 +91,38 @@ private void doCategoryBasedRankings(Athlete a, Ranking r, Category category, bo
Category curCat = p.getCategory();
switch (r) {
case SNATCH: {
if (!zero) {
CategoryRankingHolder curRankings = getCategoryRankings(curCat);
CategoryRankingHolder curRankings = getCategoryRankings(curCat);
if (!zero && a.isEligibleForIndividualRanking()) {
this.snatchRank = curRankings.getSnatchRank();
this.snatchRank = this.snatchRank + 1;
p.setSnatchRank(this.snatchRank);
curRankings.setSnatchRank(this.snatchRank);
// logger.debug("setting snatch rank {} {} {} {} {}", a, curCat, snatchRank,
// System.identityHashCode(p),
// System.identityHashCode(curRankings));
logger.warn("setting snatch rank {} {} {} {} {}", a, curCat, snatchRank, System.identityHashCode(p), System.identityHashCode(curRankings));
} else {
p.setSnatchRank(0);
// logger.debug("skipping snatch rank {} {} {}", a, curCat, 0);
p.setSnatchRank(a.isEligibleForIndividualRanking() ? 0 : -1);
logger.warn("skipping snatch rank {} {} {}", a, curCat, this.snatchRank);
}

}
break;
case CLEANJERK: {
if (!zero) {
CategoryRankingHolder curRankings = getCategoryRankings(curCat);
CategoryRankingHolder curRankings = getCategoryRankings(curCat);
if (!zero && a.isEligibleForIndividualRanking()) {
this.cjRank = curRankings.getCleanJerkRank();
this.cjRank = this.cjRank + 1;
p.setCleanJerkRank(this.cjRank);
curRankings.setCleanJerkRank(this.cjRank);
// logger.debug("setting clean&jerk rank {} {} {} {} {}", a, curCat, cjRank,
// System.identityHashCode(p), System.identityHashCode(curRankings));
} else {
p.setCleanJerkRank(0);
p.setCleanJerkRank(a.isEligibleForIndividualRanking() ? 0 : -1);
// logger.debug("skipping clean&jerk rank {} {} {}", a, curCat, 0);
}

}
break;
case TOTAL: {
if (!zero) {
CategoryRankingHolder curRankings = getCategoryRankings(curCat);
CategoryRankingHolder curRankings = getCategoryRankings(curCat);
if (!zero && a.isEligibleForIndividualRanking()) {
this.totalRank = curRankings.getTotalRank();
this.totalRank = this.totalRank + 1;
p.setTotalRank(this.totalRank);
Expand All @@ -135,14 +131,14 @@ private void doCategoryBasedRankings(Athlete a, Ranking r, Category category, bo
// System.identityHashCode(p),
// System.identityHashCode(curRankings));
} else {
p.setTotalRank(0);
p.setTotalRank(a.isEligibleForIndividualRanking() ? 0 : -1);
// logger.debug("skipping total rank {} {} {}", a, curCat, 0);
}
}
break;
case CUSTOM: {
if (!zero) {
CategoryRankingHolder curRankings = getCategoryRankings(curCat);
CategoryRankingHolder curRankings = getCategoryRankings(curCat);
if (!zero && a.isEligibleForIndividualRanking()) {
this.customRank = curRankings.getCustomRank();
this.customRank = this.customRank + 1;
p.setCustomRank(this.customRank);
Expand All @@ -151,7 +147,7 @@ private void doCategoryBasedRankings(Athlete a, Ranking r, Category category, bo
// System.identityHashCode(p),
// System.identityHashCode(curRankings));
} else {
p.setCustomRank(0);
p.setCustomRank(a.isEligibleForIndividualRanking() ? 0 : -1);
// logger.debug("skipping custom rank {} {} {}", a, curCat, 0);
}
break;
Expand Down
11 changes: 11 additions & 0 deletions owlcms/src/main/java/app/owlcms/data/athleteSort/Ranking.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,16 @@ public String getMWReportingName() {
public String getWReportingName() {
return "w" + this.reportingName;
}

public static String formatScoreboardRank(Integer total) {
if (total == null || total == 0) {
return "-";
} else if (total == -1) {
// invited lifter, not eligible.
return Translator.translate("Results.Extra/Invited");
} else {
return total.toString();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import app.owlcms.data.athlete.Athlete;
import app.owlcms.data.athleteSort.AthleteSorter;
import app.owlcms.utils.LoggerUtils;
import ch.qos.logback.classic.Logger;

/**
Expand Down Expand Up @@ -254,7 +255,9 @@ public void setCustomRank(int customRank) {

public void setSnatchRank(int snatchRank) {
this.snatchRank = snatchRank;
// logger.debug("snatchRank {}", long_dump());
if (snatchRank == 2) {
logger.warn("snatchRank {}", LoggerUtils.stackTrace());
}
}

public void setTeamCJRank(int teamCJRank) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ public static void doNotification(AbstractAttemptBoard attemptBoard, String text
}

/*
* The following 3 items need to be injected in the LitTemplate. Vaadin will create the slots and perform the
* injection based on the @Id annotation.
* The following 3 items need to be injected in the LitTemplate. Vaadin will create the slots and perform the injection based on the @Id annotation.
*/
@Id("athleteTimer")
protected AthleteTimerElement athleteTimer; // created by Flow during template instantiation
Expand Down Expand Up @@ -370,8 +369,8 @@ public void slaveDecisionReset(UIEvent.DecisionReset e) {
}

/**
* Multiple attempt boards and athlete-facing boards can co-exist. We need to show down on the slave devices -- the
* master device is the one where refereeing buttons are attached.
* Multiple attempt boards and athlete-facing boards can co-exist. We need to show down on the slave devices -- the master device is the one where
* refereeing buttons are attached.
*
* @param e
*/
Expand Down Expand Up @@ -466,8 +465,8 @@ public void slaveOrderUpdated(UIEvent.LiftingOrderUpdated e) {
}

/**
* Multiple attempt boards and athlete-facing boards can co-exist. We need to show decisions on the slave devices --
* the master device is the one where refereeing buttons are attached.
* Multiple attempt boards and athlete-facing boards can co-exist. We need to show decisions on the slave devices -- the master device is the one where
* refereeing buttons are attached.
*
* @param e
*/
Expand Down Expand Up @@ -581,14 +580,19 @@ protected void doAthleteUpdate(Athlete a, FieldOfPlay fop) {
}

String lastName = a.getLastName();
// logger.debug("setting lastName");

this.getElement().setProperty("lastName", lastName.toUpperCase());
this.getElement().setProperty("firstName", a.getFirstName());
if (lastName.length() > 18) {
this.getElement().setProperty("nameSizeOverride",
"font-size: 8vh; line-height: 8vh; text-wrap: balance; text-overflow: hidden");
"font-size: 8vh; line-height: 8vh; text-wrap: balance; text-overflow: hidden");
}

String lFirst = a.getFirstName();
// add the out-of-competition marker if defined in the translation file.
if (lFirst != null && !lFirst.isBlank()) {
lFirst = Translator.translate("Attempt.Extra/Invited", lFirst);
}
this.getElement().setProperty("firstName", lFirst);

this.getElement().setProperty("decisionVisible", false);
Category category2 = a.getCategory();
this.getElement().setProperty("category", category2 != null ? category2.getDisplayName() : "");
Expand All @@ -603,7 +607,7 @@ protected void doAthleteUpdate(Athlete a, FieldOfPlay fop) {
String teamFileName = URLUtils.sanitizeFilename(team);
if (this.teamFlags && !team.isBlank()) {
Arrays.stream(Team.getFlagExtensions())
.anyMatch(ext -> URLUtils.setImgProp("teamFlagImg", "flags/", teamFileName, ext, this));
.anyMatch(ext -> URLUtils.setImgProp("teamFlagImg", "flags/", teamFileName, ext, this));
}

String membership = a.getMembership();
Expand Down
22 changes: 14 additions & 8 deletions owlcms/src/main/java/app/owlcms/displays/scoreboard/Results.java
Original file line number Diff line number Diff line change
Expand Up @@ -726,23 +726,22 @@ protected void doUpdate(Athlete a, UIEvent e) {
updateDisplay(computeLiftType(fop.getCurAthlete()), fop);
}

protected String formatInt(Integer total) {
if (total == null || total == 0) {
protected String formatInt(Integer value) {
if (value == null || value == 0) {
return "-";
} else if (total == -1) {
return "inv.";// invited lifter, not eligible.
} else if (total < 0) {
return "(" + Math.abs(total) + ")";
} else if (value < 0) {
return "(" + Math.abs(value) + ")";
} else {
return total.toString();
return value.toString();
}
}

protected String formatRank(Integer total) {
if (total == null || total == 0) {
return "&nbsp;";
} else if (total == -1) {
return "inv.";// invited lifter, not eligible.
// invited lifter, not eligible.
return Translator.translate("Results.Extra/Invited");
} else {
return total.toString();
}
Expand All @@ -762,6 +761,9 @@ protected void getAthleteJson(Athlete a, JsonObject ja, Category curCat, int lif
} else {
fullName = a.getFullName() != null ? a.getFullName() : "";
}
if (!fullName.isBlank()) {
fullName = Translator.translate("Scoreboard.Extra/Invited",fullName);
}
ja.put("teamName", a.getTeam() != null ? a.getTeam() : "");
ja.put("yearOfBirth", a.getYearOfBirth() != null ? a.getYearOfBirth().toString() : "");
Integer startNumber = a.getStartNumber();
Expand Down Expand Up @@ -1102,13 +1104,17 @@ private String computedScore(Athlete a) {

private String computedScoreRank(Athlete a) {
Ranking ageGroupScoringSystem = a.getAgeGroup().getScoringSystem();
if (a.isEligibleForIndividualRanking()) {
if (ageGroupScoringSystem != null) {
Integer value = Ranking.getRanking(a, Ranking.CUSTOM);
return value != null && value > 0 ? "" + value : "-";
} else {
Integer value = Ranking.getRanking(a, Competition.getCurrent().getScoringSystem());
return value != null && value > 0 ? "" + value : "-";
}
} else {
return Translator.translate("Results.Extra/Invited");
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import app.owlcms.data.competition.Competition;
import app.owlcms.fieldofplay.FOPState;
import app.owlcms.fieldofplay.FieldOfPlay;
import app.owlcms.i18n.Translator;
import app.owlcms.init.OwlcmsFactory;
import app.owlcms.init.OwlcmsSession;
import ch.qos.logback.classic.Logger;
Expand Down Expand Up @@ -55,7 +56,8 @@ protected String formatRank(Integer total) {
} else if (total == 0) {
return "&ndash;";
} else if (total == -1) {
return "inv.";// invited lifter, not eligible.
// invited lifter, not eligible.
return Translator.translate("Results.Extra/Invited");
} else {
return total.toString();
}
Expand All @@ -77,12 +79,15 @@ protected JsonArray getAgeGroupNamesJson(LinkedHashMap<String, Participation> cu
protected void getAthleteJson(Athlete a, JsonObject ja, Category curCat, int liftOrderRank, FieldOfPlay fop) {
String category;
category = curCat != null ? curCat.getDisplayName() : "";
String fullName;
if (isAbbreviatedName()) {
ja.put("fullName", a.getAbbreviatedName() != null ? a.getAbbreviatedName() : "");
fullName = a.getAbbreviatedName() != null ? a.getAbbreviatedName() : "";
} else {
ja.put("fullName", a.getFullName() != null ? a.getFullName() : "");
fullName = a.getFullName() != null ? a.getFullName() : "";
}
if (!fullName.isBlank()) {
fullName = Translator.translate("Scoreboard.Extra/Invited",fullName);
}

ja.put("teamName", a.getTeam() != null ? a.getTeam() : "");
ja.put("yearOfBirth", a.getYearOfBirth() != null ? a.getYearOfBirth().toString() : "");
Integer startNumber = a.getStartNumber();
Expand Down Expand Up @@ -136,6 +141,9 @@ private String computedScore(Athlete a) {
}

private String computedScoreRank(Athlete a) {
if (!a.isEligibleForIndividualRanking()) {
return Translator.translate("Results.Extra/Invited");
}
Integer value = Ranking.getRanking(a, Competition.getCurrent().getScoringSystem());
return value != null && value > 0 ? "" + value : "-";
}
Expand Down
3 changes: 2 additions & 1 deletion owlcms/src/main/java/app/owlcms/monitors/EventForwarder.java
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,8 @@ private String formatInt(Integer total) {
if (total == null || total == 0) {
return "-";
} else if (total == -1) {
return "inv.";// invited lifter, not eligible.
// invited lifter, not eligible.
return Translator.translate("Results.Extra/Invited");
} else if (total < 0) {
return "(" + Math.abs(total) + ")";
} else {
Expand Down
Loading

0 comments on commit df7cc15

Please sign in to comment.