/** * Writes the passed level data into the passed file. * * @param level the level to be saved * @param PrintWriter the file to write to */ private final void writeLevelToFile(Level level, PrintWriter file) { // Stores the board data of the level. List<String> boardData; file.println(); file.println(); file.println(level.getTitle()); file.println(); // Get the board data of the level. boardData = level.getBoardData(); // Write the board to the file. for (String boardRow : boardData) { file.println(boardRow); } // Empty line between board and transformation data. file.println(); // Save the transformation. if (!Transformation.getTransformationAsString().isEmpty()) { // Write the transformation string. file.write(Transformation.getTransformationAsString()); // Write empty lines. file.println(); file.println(); } // Write the additional level data. if (level.getComment().length() > 0) { file.println(level.getComment()); } Author author = level.getAuthor(); if (!author.getName().equals(Texts.getText("unknown"))) { file.println("Author: " + author.getName()); } if (author.getEmail().length() > 0) { file.println("Email: " + author.getEmail()); } if (author.getWebsiteURL().length() > 0) { file.println("Homepage: " + author.getWebsiteURL()); } if (author.getComment().length() > 0) { file.println("Author comment: " + author.getComment()); } if (level.getDifficulty().length() > 0) { file.println("Difficulty: " + level.getDifficulty()); } // Save the solution information. SolutionsManager solutions = level.getSolutionsManager(); for (int solutionNo = 0; solutionNo < solutions.getSolutionCount(); solutionNo++) { Solution solution = solutions.getSolution(solutionNo); file.println(); file.println("Solution " + solution.movesCount + "/" + solution.pushesCount); // FFS/hm: also write minor metrics? file.println(solution.lurd); if (solution.name.length() > 0) { file.println("Solution name: " + solution.name); } if (solution.isOwnSolution) { file.println("Own solution: yes"); } if (solution.comment.length() > 0) { file.println("Solution comment: " + solution.comment); file.println("Solution comment end:"); } } // Get the LURD-representation of the history. String historyLURD = level.getHistory().getHistoryAsSaveGame(); // Save the history string if there is any if (!historyLURD.isEmpty()) { file.println(); file.println("Savegame:"); file.println(historyLURD); } }