diff --git a/source/code/puzzlehandler.cpp b/source/code/puzzlehandler.cpp index 90a2fff..0550453 100644 --- a/source/code/puzzlehandler.cpp +++ b/source/code/puzzlehandler.cpp @@ -123,3 +123,21 @@ int LoadPuzzleStages( ) { LoadClearData(); return 0; } + +int SavePuzzleStages() { + if (puzzleName.length() == 0) { + std::cerr << "Error: No puzzle name set. Cannot save.\n"; + return -1; + } + std::string fileContent = std::to_string(nrOfPuzzles) + "\n"; + for (int k=0; k=0; i--) + for (int j=0; j<6; j++) { + fileContent += std::to_string(puzzleLevels[k][j][i]) + " "; + } + fileContent += "\n"; + } + sago::WriteFileContent(((std::string)("puzzles/"+puzzleName)).c_str(), fileContent); + return 0; +} \ No newline at end of file diff --git a/source/code/puzzlehandler.hpp b/source/code/puzzlehandler.hpp index 5048b41..a557c6d 100644 --- a/source/code/puzzlehandler.hpp +++ b/source/code/puzzlehandler.hpp @@ -31,6 +31,7 @@ int PuzzleNumberOfMovesAllowed(int level); int PuzzleGetBrick(int level, int x, int y); bool PuzzleIsCleared(int level); int LoadPuzzleStages(); +int SavePuzzleStages(); int PuzzleGetNumberOfPuzzles(); void PuzzleSetClear(int level); const std::string& PuzzleGetName();