Skip to content

Commit

Permalink
Merge pull request #454 from softwaremagico/452-add-score-time-on-wor…
Browse files Browse the repository at this point in the history
…dpress-code

452 add score time on wordpress code
  • Loading branch information
softwaremagico authored May 26, 2024
2 parents b344149 + 7cbdf65 commit 09c6255
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![GitHub commit activity](https://img.shields.io/github/commit-activity/y/softwaremagico/KendoTournamentManager)](https://github.com/softwaremagico/KendoTournamentManager)
[![GitHub last commit](https://img.shields.io/github/last-commit/softwaremagico/KendoTournamentManager)](https://github.com/softwaremagico/KendoTournamentManager)
[![CircleCI](https://circleci.com/gh/softwaremagico/KendoTournamentManager.svg?style=shield)](https://circleci.com/gh/softwaremagico/KendoTournamentManager)
[![Time](https://img.shields.io/badge/development-622.5h-blueviolet.svg)]()
[![Time](https://img.shields.io/badge/development-623h-blueviolet.svg)]()

[![Powered by](https://img.shields.io/badge/powered%20by%20java-orange.svg?logo=OpenJDK&logoColor=white)]()
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=kendo-tournament-backend&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=kendo-tournament-backend)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ private void addScoreTables(StringBuilder stringBuilder, TournamentDTO tournamen
String name;
name = NameUtils.getLastnameName(competitor);
columns.add(name);
columns.add(getFaults(fight, teamMember, true));
columns.add(getScore(fight, teamMember, 1, true));
columns.add(getScore(fight, teamMember, 0, true));
columns.add(getFaultsDiv(fight, teamMember, true));
columns.add(getScoreDiv(fight, teamMember, 1, true));
columns.add(getScoreDiv(fight, teamMember, 0, true));
columns.add(getDrawFight(fight, teamMember));
columns.add(getScore(fight, teamMember, 0, false));
columns.add(getScore(fight, teamMember, 1, false));
columns.add(getFaults(fight, teamMember, false));
columns.add(getScoreDiv(fight, teamMember, 0, false));
columns.add(getScoreDiv(fight, teamMember, 1, false));
columns.add(getFaultsDiv(fight, teamMember, false));

// Team 2
competitor = fight.getTeam2().getMembers().get(teamMember);
Expand Down Expand Up @@ -257,38 +257,67 @@ private String getDrawFight(FightDTO fightDTO, int duel) {
// Draw Fights
final String draw;
if (fightDTO.getDuels().get(duel).getWinner() == 0 && fightDTO.isOver()) {
draw = String.valueOf(Score.DRAW.getPdfAbbreviation());
return "<div style=\"text-align: center;\">"
+ Score.DRAW.getPdfAbbreviation()
+ "</div>";
} else {
draw = String.valueOf(Score.EMPTY.getPdfAbbreviation());
return String.valueOf(Score.EMPTY.getPdfAbbreviation());
}
return draw;
}

private String getFaults(FightDTO fightDTO, int duel, boolean leftTeam) {
final String faultSymbol;
private String getFaultsDiv(FightDTO fightDTO, int duel, boolean leftTeam) {
final boolean fault = getFaults(fightDTO, duel, leftTeam);
if (!fault) {
return "";
}
return "<div style=\"width: 0;height: 0;border-left: 5px solid transparent;border-right: 5px solid transparent;border-bottom: 10px solid black;\">"
+ "</div>";
}

private boolean getFaults(FightDTO fightDTO, int duel, boolean leftTeam) {
final boolean faults;
if (leftTeam) {
faults = fightDTO.getDuels().get(duel).getCompetitor1Fault();
return fightDTO.getDuels().get(duel).getCompetitor1Fault();
} else {
faults = fightDTO.getDuels().get(duel).getCompetitor2Fault();
return fightDTO.getDuels().get(duel).getCompetitor2Fault();
}
if (faults) {
faultSymbol = String.valueOf(Score.FAULT.getPdfAbbreviation());
} else {
faultSymbol = String.valueOf(Score.EMPTY.getPdfAbbreviation());
}

private String getScoreDiv(FightDTO fightDTO, int duel, int score, boolean leftTeam) {
final Score scoreText = getScore(fightDTO, duel, score, leftTeam);
if (scoreText == null || scoreText == Score.EMPTY) {
return "";
}
return faultSymbol;
final int scoreTime = getScoreTime(fightDTO, duel, score, leftTeam);
return "<div style=\"border-radius: 50%;border: 1px solid black; text-align: center;height=100%\""
+ (scoreTime > 0 ? " title=\"" + scoreTime + "&quot;\">" : ">")
+ String.valueOf(scoreText.getPdfAbbreviation()).replace(" ", "&nbsp;")
+ "</div>";
}

private String getScore(FightDTO fightDTO, int duel, int score, boolean leftTeam) {
private int getScoreTime(FightDTO fightDTO, int duel, int score, boolean leftTeam) {
final int time;
try {
if (leftTeam) {
return String.valueOf(fightDTO.getDuels().get(duel).getCompetitor1Score().get(score).getPdfAbbreviation());
time = fightDTO.getDuels().get(duel).getCompetitor1ScoreTime().get(score);
} else {
return String.valueOf(fightDTO.getDuels().get(duel).getCompetitor2Score().get(score).getPdfAbbreviation());
time = fightDTO.getDuels().get(duel).getCompetitor2ScoreTime().get(score);
}
return time;
} catch (Exception ignored) {
}
return -1;
}

private Score getScore(FightDTO fightDTO, int duel, int score, boolean leftTeam) {
try {
if (leftTeam) {
return fightDTO.getDuels().get(duel).getCompetitor1Score().get(score);
} else {
return fightDTO.getDuels().get(duel).getCompetitor2Score().get(score);
}
} catch (IndexOutOfBoundsException | NullPointerException e) {
return "";
return null;
}
}
}

0 comments on commit 09c6255

Please sign in to comment.