-
Notifications
You must be signed in to change notification settings - Fork 0
/
planet.cpp
52 lines (45 loc) · 1.45 KB
/
planet.cpp
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
#include "planet.h"
#define N 25
namespace planet{
std::vector<vectorItems> Planet::genGround(size_t high, size_t width){
vectorItems tmp = vectorItems(high * width);
std::vector<vectorItems> result;
for(size_t i = 0; i < high; ++i){
result.push_back(vectorItems(size_t(0)));
for(size_t j = 0; j < width; ++j)
result[i].push_back(tmp[i * width + j]);
}
return result;
}
Planet::Planet() : ground(genGround(N, N)),
server(N, N),
collectors(ground, server),
sappers(ground, server){}
Planet::operator bool(){
return server && status;
}
void Planet::menu(void){
if(server.Key() == graphics::Keys::U){
server.readCmd("Input \'collector\' or \'sapper\'");
if(server.cmd() == "collector")
collectors.cmd("\'auto\'|\'scan\'|\'switch\'|\'add\'");
else if(server.cmd() == "sapper")
sappers.cmd("\'add\'|\'change mode\'");
}
}
void Planet::takeRobotsStep(void){
collectors.refresh();
sappers.refresh();
}
void Planet::getCommand(void){
server.getKey();
if(server.Key() == graphics::Keys::Esc){
status = false;
return;
}
collectors.man("");
menu();
takeRobotsStep();
server.mapViewUpdate();
}
}