Skip to content

Commit

Permalink
Cleaned up code
Browse files Browse the repository at this point in the history
  • Loading branch information
Foulest committed Dec 6, 2024
1 parent 4ea021e commit e45344d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/main/java/net/foulest/swiss/Swiss.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ public static void main(String[] args) {
// You can also display the winner of a match based on win probability
// instead of simulating the entire bracket (these are just examples).
if (bracketNumber == 0) {
Match.displayWinnerFromProbability(theMongolZ, heroic, false);
Match.displayWinnerFromProbability(theMongolZ, mibr, true);
Match.displayWinnerFromProbability(wildcard, gamerLegion, true);
return;
}

Expand All @@ -123,22 +122,23 @@ public static void main(String[] args) {

// Get the amount of brackets to simulate based on user input
int bracketsToSimulate = scanner.nextInt();
int teamsSize = teams.size();

// Validates team size for Standard brackets
if (standardBracket && teams.size() != 16) {
if (standardBracket && teamsSize != 16) {
System.out.println();
System.out.println("Invalid team count. Please make sure there are 16 teams in the list.");
return;
}

// Validates team size for Champions brackets
if (!standardBracket && teams.size() != 8) {
if (teams.size() >= 8) {
System.out.println();
if (!standardBracket && teamsSize != 8) {
System.out.println();

if (teamsSize >= 8) {
System.out.println("Invalid team count; trimming the list to the first 8 teams.");
teams.subList(8, teams.size()).clear();
teams.subList(8, teamsSize).clear();
} else {
System.out.println();
System.out.println("Invalid team count. Please make sure there are 8 teams in the list.");
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,9 @@ private static void printRatingChange(@NotNull Map<Team, Double> initialRatings,
double finalRating = team.getAvgPlayerRating();
double ratingChange = finalRating - initialRating;
String teamName = team.getName();
int[] teamRecords = records.get(team);

System.out.println(teamName + " (" + records.get(team)[0] + "-" + records.get(team)[1] + ")"
System.out.println(teamName + " (" + teamRecords[0] + "-" + teamRecords[1] + ")"
+ " started with a rating of " + initialRating
+ " and ended with a rating of " + finalRating + " (" + ratingChange + ")");
}
Expand Down Expand Up @@ -211,7 +212,9 @@ private static void printResults(@NotNull Map<Team, Map<String, Integer>> result
Bracket.appendProbability(resultString, "0-1", recordCounts, numSimulations);

// Print the team's result
System.out.println(resultString.toString().trim());
String result = resultString.toString();
String trimmed = result.trim();
System.out.println(trimmed);
}
}
}

0 comments on commit e45344d

Please sign in to comment.