nsnake
Classic snake game for the terminal
Loading...
Searching...
No Matches
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
12class BoardParserException : public std::exception
13{
14public:
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{
33public:
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
Custom exception class to specify an error that occurred during a level loading.
Opens, loads and parses a level file, returning a well-formed Board.
static Board * loadFile(std::string filename)
Loads and parses the level at filename.
static std::string directory
Default directory where the level files are.
static std::vector< std::string > listLevels()
Lists all levels found by the game.
static Board * load(std::string filename)
Loads and parses level with name.
static bool save(Board *board, std::string filename)
TODO.
static std::string extension
Default extension for nSnake level files.
A level where the snake runs and eats fruits.
Definition Board.hpp:33