Example #1
0
  public static void makeTournament(WizardOptions wizardOptions) {

    IATournament tournament =
        new IATournament(
            wizardOptions.getName(),
            wizardOptions.getPlayerList(),
            wizardOptions.getInitialSeedingEnum(),
            wizardOptions.isSingleElimination());

    CryodexController.registerTournament(tournament);

    tournament.startTournament();

    MenuBar.getInstance().resetMenuBar();

    CryodexController.saveData();
  }
  public static String appendRankings(IATournament tournament) {
    List<IAPlayer> playerList = new ArrayList<IAPlayer>();
    List<IAPlayer> activePlayers = tournament.getIAPlayers();

    playerList.addAll(tournament.getAllIAPlayers());
    Collections.sort(playerList, new IAComparator(tournament, IAComparator.rankingCompare));

    String content =
        "<table border=\"1\"><tr><td>Rank</td><td>Name</td><td>Score</td><td>SoS</td><td>Ext SoS</td></tr>";

    for (IAPlayer p : playerList) {

      String name = p.getName();

      if (activePlayers.contains(p) == false) {
        name = "(D#" + p.getRoundDropped(tournament) + ")" + name;
      }

      content +=
          "<tr><td>"
              + p.getRank(tournament)
              + "</td><td>"
              + name
              + "</td><td>"
              + p.getScore(tournament)
              + "</td><td>"
              + p.getAverageSoS(tournament)
              + "</td><td>"
              + p.getExtendedStrengthOfSchedule(tournament)
              + "</td></tr>";
    }

    content += "</table>";

    return content;
  }
  public static void exportTournamentReport(IATournament tournament) {
    String content = "";
    int roundNumber = 1;
    for (IARound r : tournament.getAllRounds()) {
      if (r.isSingleElimination()) {
        content += "<h3>Top " + (r.getMatches().size() * 2) + "</h3>";
      } else {
        content += "<h3>Round " + roundNumber + "</h3>";
      }
      content += appendMatches(tournament, r.getMatches());

      roundNumber++;
    }

    content += "<h3>Rankings</h3>";
    content += appendRankings(tournament);

    ExportUtils.displayHTML(content, "TournamentReport");
  }