/* * CS 246 Final Project * File: map.h * Purpose: handles map functionality */ #ifndef __MAP_H__ #define __MAP_H__ #include #include #include "objects.h" #include "constants.h" #include "display.h" #include "position.h" #include "layer.h" #include "characters.h" class game_map final: public layer { public: game_map(int lvl = 0); // randomly generate one // initialize using stored data game_map(const std::string &map_data, int lvl); ~game_map(); // placeholder int get_level() const; position_list get_available_positions() const; // IMPORTANT: always print a map before anything else // prints using ncurses void print() const; // prints to a string void print(display &display) const; // This is implemented this way to do two things: // 1. avoid directly accessing heap memory (bonus points) // 2. make a level revisitable void apply_potion(character *who, const stat_name statn, const int amount); // just in case you want to retain the potion effects void enter_level(character *who); void leave_level(character *who); private: struct effect { character *who; stat_name statn; int amount; }; std::vector map; int level; // use this to remember every applied potion std::vector effects; }; const std::string default_map = "|-----------------------------------------------------------------------------|\ | |\ | |--------------------------| |-----------------------| |\ | |..........................| |.......................| |\ | |..........................+########+.......................|-------| |\ | |..........................| # |...............................|--| |\ | |..........................| # |..................................|--| |\ | |----------+---------------| # |----+----------------|...............| |\ | # ############# |...............| |\ | # # |-----+------| |...............| |\ | # # |............| |...............| |\ | ################### |............| ######+...............| |\ | # # |............| # |...............| |\ | # # |-----+------| # |--------+------| |\ | |---------+-----------| # # # # |\ | |.....................| # # # |----+------| |\ | |.....................| ######################## |...........| |\ | |.....................| # # |...........| |\ | |.....................| # |------+--------------------|...........| |\ | |.....................| # |.......................................| |\ | |.....................+##########+.......................................| |\ | |.....................| |.......................................| |\ | |---------------------| |---------------------------------------| |\ | |\ |-----------------------------------------------------------------------------|\ "; #endif