private void gamesCsv(Round round) {
    File gamesCSV = new File(names[2]);

    if (gamesCSV.isFile() && gamesCSV.canRead()) {
      gamesCSV.delete();
    }

    if (round.getSize() == 0) {
      return;
    }

    try {
      gamesCSV.createNewFile();

      FileWriter fw = new FileWriter(gamesCSV.getAbsoluteFile());
      BufferedWriter bw = new BufferedWriter(fw);

      bw.write(
          "gameId;gameName;status;gameSize;gameLength;lastTick;"
              + "weatherLocation;weatherDate;logUrl;brokerId;brokerBalance;"
              + separator);

      String tourneyUrl = properties.getProperty("tourneyUrl");
      String baseUrl = properties.getProperty("actionIndex.logUrl", "download?game=%d");
      for (Game game : round.getGameMap().values()) {
        String logUrl = "";
        if (game.isComplete()) {
          if (baseUrl.startsWith("http://")) {
            logUrl = String.format(baseUrl, game.getGameId());
          } else {
            logUrl = tourneyUrl + String.format(baseUrl, game.getGameId());
          }
        }

        String content =
            String.format(
                "%d;%s;%s;%d;%d;%d;%s;%s;%s;",
                game.getGameId(),
                game.getGameName(),
                game.getState(),
                game.getSize(),
                game.getGameLength(),
                game.getLastTick(),
                game.getLocation(),
                game.getSimStartTime(),
                logUrl);
        for (Agent agent : game.getAgentMap().values()) {
          content = String.format("%s%d;%f;", content, agent.getBrokerId(), agent.getBalance());
        }

        bw.write(content + separator);
      }

      bw.close();

      copyFile(gamesCSV, names[3]);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  public CSV(Tournament t, Round r) {
    properties = TournamentProperties.getProperties();
    separator = ";" + System.getProperty("line.separator");
    logLocation = properties.getProperty("logLocation");
    baseUrl = properties.getProperty("actionIndex.logUrl", "download?game=%d");
    baseUrl = baseUrl.substring(0, baseUrl.lastIndexOf("game"));

    if (t != null) {
      String name = "%stournament.%s.csv";
      String levels = "%srounds.%s.csv";
      names =
          new String[] {
            String.format(name, logLocation, t.getTournamentName().replaceAll(" ", "_")),
            String.format(name, logLocation, t.getTournamentId()),
            String.format(levels, logLocation, t.getTournamentName().replaceAll(" ", "_")),
            String.format(levels, logLocation, t.getTournamentId())
          };
    } else if (r != null) {
      String name = "%sround.%s.csv";
      String games = "%sgames.%s.csv";
      names =
          new String[] {
            String.format(name, logLocation, r.getRoundName().replaceAll(" ", "_")),
            String.format(name, logLocation, r.getRoundId()),
            String.format(games, logLocation, r.getRoundName().replaceAll(" ", "_")),
            String.format(games, logLocation, r.getRoundId())
          };
    }
  }