summary refs log tree commit diff stats
path: root/src/map.h
blob: 0e11b9d2d95037f1b99a38284fb608f60406771a (plain) (blame)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#ifndef MAP_H_74055FC0
#define MAP_H_74055FC0

#include <vector>
#include <string>
#include <list>
#include <map>

class Map {
public:

  class Adjacent {
  public:

    enum class Type {
      wall,
      wrap,
      warp,
      reverse
    };

    Adjacent(
      Type type = Type::wall,
      int mapId = -1) :
        type_(type),
        mapId_(mapId)
    {
    }

    inline Type getType() const
    {
      return type_;
    }

    inline int getMapId() const
    {
      return mapId_;
    }

  private:

    Type type_;
    int mapId_;
  };

  class Object {
  public:

    Object(
      std::string type,
      double x,
      double y,
      size_t index,
      std::map<std::string, int> items) :
        type_(std::move(type)),
        x_(x),
        y_(y),
        index_(index),
        items_(std::move(items))
    {
    }

    inline const std::string& getType() const
    {
      return type_;
    }

    inline double getX() const
    {
      return x_;
    }

    inline double getY() const
    {
      return y_;
    }

    inline size_t getIndex() const
    {
      return index_;
    }

    inline const std::map<std::string, int>& getItems() const
    {
      return items_;
    }

  private:

    std::string type_;
    double x_;
    double y_;
    size_t index_;
    std::map<std::string, int> items_;
  };

  using object_storage_type = std::list<Object>;

  Map(
    int id,
    std::vector<int> tiles,
    std::string title,
    Adjacent leftAdjacent,
    Adjacent rightAdjacent,
    Adjacent upAdjacent,
    Adjacent downAdjacent,
    object_storage_type objects) :
      id_(id),
      tiles_(std::move(tiles)),
      title_(std::move(title)),
      leftAdjacent_(std::move(leftAdjacent)),
      rightAdjacent_(std::move(rightAdjacent)),
      upAdjacent_(std::move(upAdjacent)),
      downAdjacent_(std::move(downAdjacent)),
      objects_(std::move(objects))
  {
  }

  inline size_t getId() const
  {
    return id_;
  }

  inline const std::vector<int>& getTiles() const
  {
    return tiles_;
  }

  inline const std::string& getTitle() const
  {
    return title_;
  }

  inline const Adjacent& getLeftAdjacent() const
  {
    return leftAdjacent_;
  }

  inline const Adjacent& getRightAdjacent() const
  {
    return rightAdjacent_;
  }

  inline const Adjacent& getUpAdjacent() const
  {
    return upAdjacent_;
  }

  inline const Adjacent& getDownAdjacent() const
  {
    return downAdjacent_;
  }

  inline const object_storage_type& getObjects() const
  {
    return objects_;
  }

private:

  int id_;
  std::vector<int> tiles_;
  std::string title_;
  Adjacent leftAdjacent_;
  Adjacent rightAdjacent_;
  Adjacent upAdjacent_;
  Adjacent downAdjacent_;
  object_storage_type objects_;
};

#endif /* end of include guard: MAP_H_74055FC0 */