-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame_Command.cpp
More file actions
80 lines (77 loc) · 1.75 KB
/
Game_Command.cpp
File metadata and controls
80 lines (77 loc) · 1.75 KB
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
#include "Game_Command.h"
//moves a miner or soldier
void Game_Command::move_function(Model& model)
{
int person_num;
Cart_Point moveto;
cin>> person_num>> moveto.x>> moveto.y;
if (person_num>4||person_num<0)
{
cout<< "ERROR: Please enter a valid command"<< endl;
}
else
{
(model.get_Person_ptr(person_num-1)->start_moving(moveto));
}
}
// lets soldiers attack others
void Game_Command::attack_function(Model& model)
{
int predator, prey;
cin>> predator>> prey;
if (predator>4||predator<0|| prey>4|| prey<0)
{
cout<< "ERROR: Please enter a valid command"<< endl;
}
else
{
model.get_Person_ptr(predator-1)->start_attack(model.get_Person_ptr(prey-1));
}
}
//lets miners work
void Game_Command::work_function(Model& model)
{
int gold_num, th_num, person_num;
cin>>person_num>> gold_num>> th_num;
if (person_num>4||person_num<0|| gold_num>2|| gold_num<0||th_num!=1)
{
cout<< "ERROR: Please enter a valid command"<< endl;
}
else
{
(model.get_Person_ptr(person_num-1))->start_mining(model.get_Gold_Mine_ptr(gold_num-1), model.get_Town_Hall_ptr(th_num-1));
}
}
//stops moving persons
void Game_Command::stop_function(Model& model)
{
int person_num;
cin>> person_num;
if (person_num>4||person_num<0)
{
cout<< "ERROR: Please enter a valid command"<< endl;
}
else
model.get_Person_ptr(person_num-1)->stop();
}
//updates time and makes things the board move 5 times
void Game_Command::run_function(Model& model)
{
int counter;
counter=1;
while ( (model.update()) & (counter<5))
{
counter++;
}
model.show_status();
}
//updates the entire board once
void Game_Command::go_function(Model& model)
{
model.update();
}
//makes show status
void Game_Command::list_function(Model& model)
{
model.show_status();
}