-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameCommand.cpp
More file actions
108 lines (99 loc) · 2.56 KB
/
Copy pathGameCommand.cpp
File metadata and controls
108 lines (99 loc) · 2.56 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
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
#include "GameCommand.h"
void DoMoveCommand(Model& model, int student_id, Point2D p1)
{
if (model.GetStudentPtr(student_id) != nullptr)
{
Student* student = model.GetStudentPtr(student_id);
cout << student->GetName() << " to " << p1 << endl;
student->StartMoving(p1);
}
else
{
throw Invalid_Input("Enter a valid command");
}
}
void DoMoveToDoctorCommand(Model& model, int student_id, int office_id)
{
if (model.GetStudentPtr(student_id) != nullptr && model.GetDoctorsOfficePtr(office_id)!=nullptr)
{
Student* student = model.GetStudentPtr(student_id);
cout << student->GetName() << " to doctors office " << office_id << endl;
student->StartMovingToDoctor(model.GetDoctorsOfficePtr(office_id));
}
else
{
throw Invalid_Input("Enter a valid command");
}
}
void DoMoveToClassCommand(Model& model, int student_id, int class_id)
{
if (model.GetStudentPtr(student_id) != nullptr && model.GetClassRoomPtr(class_id) != nullptr)
{
Student* student = model.GetStudentPtr(student_id);
cout << student->GetName() << " to classroom " << class_id << endl;
student->StartMovingToClass(model.GetClassRoomPtr(class_id));
}
else
{
throw Invalid_Input("Enter a valid command");
}
}
void DoStopCommand(Model& model, int student_id)
{
if (model.GetStudentPtr(student_id) != nullptr)
{
Student* student = model.GetStudentPtr(student_id);
cout << "Stopping " << student->GetName() << endl;
student->Stop();
}
else
{
throw Invalid_Input("Enter a valid command");
}
}
void DoLearningCommand(Model& model, int student_id, unsigned int assignments)
{
if (model.GetStudentPtr(student_id) != nullptr)
{
Student* student = model.GetStudentPtr(student_id);
cout << "Teaching " << student->GetName() << endl;
student->StartLearning(assignments);
}
else
{
throw Invalid_Input("Enter a valid command");
}
}
void DoRecoverInOfficeCommand(Model& model, int student_id, unsigned int vaccine_needs)
{
if (model.GetStudentPtr(student_id) != nullptr)
{
Student* student = model.GetStudentPtr(student_id);
cout << "Recovering " << student->GetName() << "'s antibodies" << endl;
student->StartRecoveringAntibodies(vaccine_needs);
}
else
{
throw Invalid_Input("Enter a valid command");
}
}
void DoGoCommand(Model& model, View& view)
{
cout << "Advancing one tick" << endl;
model.Update();
model.ShowStatus();
model.Display(view);
}
void DoRunCommand(Model& model, View& view)
{
cout << "Advancing to next event" << endl;
int time_count = 0;
while (!model.Update())
{
time_count++;
if (time_count == 5)
break;
}
model.ShowStatus();
model.Display(view);
}