Line | Branch | Exec | Source |
---|---|---|---|
1 | #include "Map.hpp" | ||
2 | #include "../utils/GuiException.hpp" | ||
3 | |||
4 | 18 | std::vector<int> Map::getSize() | |
5 | { | ||
6 | 18 | if (this->map.size() == 0) { | |
7 | 3 | return {0, 0}; | |
8 | } | ||
9 | 15 | int x = static_cast<int>(this->map.size()); | |
10 | 15 | int y = static_cast<int>(this->map.at(0).size()); | |
11 | 15 | std::vector<int> size = {x, y}; | |
12 | |||
13 | return size; | ||
14 | } | ||
15 | |||
16 | 7 | void Map::updateTile(int x, int y, std::vector<int> values) | |
17 | { | ||
18 | 12 | if (x >= static_cast<int>(this->getSize()[0]) || y >= static_cast<int>(this->getSize()[1])) { | |
19 | 6 | throw guiException("Invalid tile position"); | |
20 | } | ||
21 | 4 | map[x][y].setRessources(values); | |
22 | 4 | } | |
23 | |||
24 | |||
25 | 10 | void Map::fillMap(int x, int y) | |
26 | { | ||
27 | 72 | for (; x > 0; x--) { | |
28 | 62 | std::vector<Tile> row; | |
29 | 516 | for (int i = 0;i < y; i++) { | |
30 | 908 | row.push_back(Tile(x, y)); | |
31 | } | ||
32 | 62 | this->map.push_back(row); | |
33 | 62 | } | |
34 | 10 | } | |
35 | |||
36 | ✗ | void Map::resetMap() | |
37 | { | ||
38 | ✗ | this->map.clear(); | |
39 | ✗ | } | |
40 |