float point exception, waiting for debugging
This commit is contained in:
87
src/map.h
Normal file
87
src/map.h
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* CS 246 Final Project
|
||||
* File: map.h
|
||||
* Purpose: handles map functionality
|
||||
*/
|
||||
|
||||
#ifndef __MAP_H__
|
||||
#define __MAP_H__
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#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<std::string> map;
|
||||
int level;
|
||||
|
||||
// use this to remember every applied potion
|
||||
std::vector<effect> effects;
|
||||
};
|
||||
|
||||
const std::string default_map =
|
||||
"|-----------------------------------------------------------------------------|\
|
||||
| |\
|
||||
| |--------------------------| |-----------------------| |\
|
||||
| |..........................| |.......................| |\
|
||||
| |..........................+########+.......................|-------| |\
|
||||
| |..........................| # |...............................|--| |\
|
||||
| |..........................| # |..................................|--| |\
|
||||
| |----------+---------------| # |----+----------------|...............| |\
|
||||
| # ############# |...............| |\
|
||||
| # # |-----+------| |...............| |\
|
||||
| # # |............| |...............| |\
|
||||
| ################### |............| ######+...............| |\
|
||||
| # # |............| # |...............| |\
|
||||
| # # |-----+------| # |--------+------| |\
|
||||
| |---------+-----------| # # # # |\
|
||||
| |.....................| # # # |----+------| |\
|
||||
| |.....................| ######################## |...........| |\
|
||||
| |.....................| # # |...........| |\
|
||||
| |.....................| # |------+--------------------|...........| |\
|
||||
| |.....................| # |.......................................| |\
|
||||
| |.....................+##########+.......................................| |\
|
||||
| |.....................| |.......................................| |\
|
||||
| |---------------------| |---------------------------------------| |\
|
||||
| |\
|
||||
|-----------------------------------------------------------------------------|\
|
||||
";
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user