#ifndef MAZEREADER_H #define MAZEREADER_H #include #include #include #include using namespace std; #include #include "../logic/Maze.h" #include "../logic/PlayerCar.h" #include "../logic/EnemyCar.h" #include "../logic/Checkpoint.h" #include "../logic/Rock.h" /** * @brief An exception that is thrown if the file selected for opening does not exist. * * This should never be thrown, since the Allegro native file dialog is being used to select * this file, and it only allows one to select existing files. * * @author Justin Wernick * @author David Schneider */ class FileOpenError{}; /** * @brief Reads the game objects from a text file and calls relevant constructors. * * @author Justin Wernick * @author David Schneider */ class LevelReader { public: /** * @brief Constructor that stores the path of the file containing the level to be read with the readLevel function. * * @param [in] filename The path of the file containing the level. */ LevelReader(string filename); //Assignment and copy operations are handled by the compiler generated versions /** * @brief Function to read the chosen file into the data structures used in the game. * * Each character in the file is iterated through, and added to the appropriate data structure if it matches * one of the defined constants. Lists should be cleared prior to calling this function. * * @param [out] maze Object representing the walls, populated with a vector of x,y pairs. * @param [out] players List representing the player(s) in the game. * @param [out] enemies List representing the enemies in the game. * @param [out] checkpoints List representing the checkpoints in the game. * @param [out] rocks List representing the rocks in the game. */ void readLevel(Maze& maze, list& players, list& enemies, list& checkpoints, list& rocks); private: static const char PLAYER_CHAR = '@'; ///< Character represented a PlayerCar in the level file. static const char ENEMY_CHAR = 'X'; ///< Character represented an EnemyCar in the level file. static const char CHECKPOINT_CHAR = 'P'; ///< Character represented a Checkpoint in the level file. static const char ROCK_CHAR = 'O'; ///< Character represented a Rock in the level file. static const char WALL_CHAR = '#'; ///< Character represented a solid part of the maze in the level file. string _filename; ///< Path of the file containing the level. }; #endif // MAZEREADER_H