-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap.h
72 lines (71 loc) · 2.61 KB
/
map.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef _MAP_H
#define _MAP_H
#include "mnode.h"
#include "map_config.h"
#include<map>
#include <utility>
#include<list>
#include <vector>
using std::map;
using std::list;
using std::pair;
using std::vector;
class Map
{
private:
int _mapRow = 20;
int _mapCol = 20;
int _nodeWidth = 4;
int _nodeHeight = 2;
int _maxMapIndex_Y = 0;
int _maxMapIndex_X = 0;
WINDOW* mapPtr = nullptr;
map<int, MNode> nodeMap;
bool isMapIndexValid(int my, int mx)const;
bool isNumValid(int num) const;
void filterNeightbor(pair<int, int> &npair, list<MNode> &nlist);
bool isReachable(const MNode& node) const;
void drawGrid(int _row, int _col);
void buildNodes(map<int, MNode>& nMap);
list<pair<int, int>> enumsNeighbors(const MNode&);
public:
Map() = default;
Map(int _row, int _col);
Map(const Map& orgin) = default;
Map(Map&&)noexcept;
Map& operator=(Map&&)noexcept;
~Map();
map<int, char> NumMap =
{
{0,'0'},{1,'1'},{2,'2'},{3,'3'},{4,'4'},{5,'5'},{6,'6'},{7,'7'},{8,'8'},{9,'9'},
};
void FindPath();
void DrawMap();
void GenTerrain(const map<ENodeType, list<pair<int, int>>> &TerrainMap);
void ClearMap();
void Draw(int num, int _mapIndex_Y, int _mapIndex_X);
void Draw(char ch, int _mapIndex_Y, int _mapIndex_X);
void Draw(const char*, int _mapIndex_Y, int _mapIndex_X);
void Draw(const MNode& node, EDrawType)const;
void Draw(const list<MNode> & dlist, EDrawType) const;
void ClearNode(const MNode& node);
int Size() const;
int GetCol(){return _mapCol;}
int GetRow(){return _mapRow;}
int GetMapCol(){return _maxMapIndex_X;};
int GetMapRow(){return _maxMapIndex_Y;};
MNode& GetNode(int _mapIndex_Y, int _mapIndex_X);
const int GetNodeNum(const MNode& node) const;
pair<int, int> ExchNumToMapIndex(int num) const;
pair<int, int> ExchMapIndexToPOS(int _mapIndex_Y, int _mapIndex_X) const;
int ExchMapIndexToNum(int _mapIndex_Y, int _mapIndex_X) const;
list<MNode> GetFilterNeighbors(const MNode& node);
list<MNode> GetNeighbors(const MNode& node);
bool NodeCheck(const MNode& node) const;
void DrawTerrain(const map<ENodeType, list<pair<int, int>>>& terMap);
void DrawOriginPath(const map<int, int> & oriMap, const MNode&, const MNode&);
void DrawFinalPath(const vector<int>& pathVec, const MNode&, const MNode&);
bool Reacheable(const MNode&) const;
int GetCost(const MNode&, const MNode&) const;
};
#endif