nsnake
Classic snake game for the terminal
BoardParser.hpp
1 #ifndef BOARDPARSER_H_DEFINED
2 #define BOARDPARSER_H_DEFINED
3 
4 #include <Game/Board.hpp>
5 
6 #include <exception>
7 #include <string>
8 
12 class BoardParserException : public std::exception
13 {
14 public:
15  BoardParserException(std::string message):
16  message(message)
17  { }
18  ~BoardParserException() throw()
19  { }
20 
21  std::string message;
22 };
23 
24 #define COMMENT_CHAR ';'
25 #define WALL_CHAR '#'
26 #define SNAKE_CHAR '@'
27 
32 {
33 public:
38  static std::string directory;
39 
47  static std::string extension;
48 
56  static Board* load(std::string filename);
57 
63  static Board* loadFile(std::string filename);
64 
66  static bool save(Board* board, std::string filename);
67 
73  static std::vector<std::string> listLevels();
74 };
75 
76 #endif //BOARDPARSER_H_DEFINED
77 
Opens, loads and parses a level file, returning a well-formed Board.
Definition: BoardParser.hpp:31
static std::string directory
Default directory where the level files are.
Definition: BoardParser.hpp:38
A level where the snake runs and eats fruits.
Definition: Board.hpp:32
static std::string extension
Default extension for nSnake level files.
Definition: BoardParser.hpp:47
Custom exception class to specify an error that occurred during a level loading.
Definition: BoardParser.hpp:12