-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenu.cpp
More file actions
269 lines (260 loc) · 8.38 KB
/
Copy pathMainMenu.cpp
File metadata and controls
269 lines (260 loc) · 8.38 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
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#include "MainMenu.h"
#include "State.h"
void MainMenu::maximizeWindow()
{
HWND hwnd = GetConsoleWindow();
ShowWindow(hwnd, SW_SHOWMAXIMIZED);
}
void MainMenu::displayMainMenu() //main menu
{
while(true)
{
system("cls");
cout<<"Welcome to the Virus Infection Game!\n";
int choice = IOHandler::askChoices(
{"Start Game",
"Settings",
"Help",
"Credits",
"Exit"});
switch(choice)
{
case 0:
newGame();
break;
case 1:
displaySettings();
break;
case 2:
displayHelpMenu();
break;
case 3:
displayCredits();
break;
case 4:
displayExitMenu(); //exit from here
break;
default:
assert(0);
}
}
}
void MainMenu::displaySettings() //settings menu
{
while(true)
{
system("cls");
cout<<"Current Settings:\n";
cout<<"Difficulty: "<<difficulty<<'\n';
cout<<"Delay between hours: "<<int(min_seconds_between_hour*1000)<<"ms\n";
cout<<'\n';
cout<<"Which setting do you want to change? (enter the number corresponding to the setting)\n";
int choice = IOHandler::askChoices(
{"Difficulty",
"Game Speed",
"None"
});
switch(choice)
{
case 0:
changeDifficultyMenu();
break;
case 1:
changeGameSpeedMenu();
break;
case 2:
return ;
break;
default:
assert(0);
}
}
}
void MainMenu::changeDifficultyMenu()
{
system("cls");
cout<<"Choose difficulty (enter the number corresponding to the setting):\n";
int choice = IOHandler::askChoices(
{"Easy",
"Normal",
"Hard",
"Insane",
"Hell"
});
switch(choice)
{
case 0: //easy
initial_testing_acc = 0.4;
virus = Virus(6,10,7,10,1.0,5,0.0061); //min_incubation, max_incubation, min_lethality, max_lethality, cure_difficulty, min_cure_hours, spread_difficulty
initial_infect = 15;
min_activity_level = 7;
max_activity_level = 10;
testing_kits_per_region = 3.0;
medical_cap_per_region = 2.0;
min_merchant_salary = 0.5; max_merchant_salary = 0.6;
min_worker_salary = 0.2; max_worker_salary = 0.3;
typeDistribution = {0.4,0.4,0.2};
initial_scan_limit = 0;
difficulty = "Easy";
time_limit = Time(13,23);
dead_limit = 20000;
cout<<"Difficulty set to easy.\n";
break;
case 1: //normal
initial_testing_acc = 0.4;
virus = Virus(7,12,7,10,1.3,5,0.0065); //min_incubation, max_incubation, min_lethality, max_lethality, cure_difficulty, min_cure_hours, spread_difficulty
initial_infect = 15;
min_activity_level = 7;
max_activity_level = 11;
testing_kits_per_region = 2.5;
medical_cap_per_region = 1.5;
min_merchant_salary = 0.48; max_merchant_salary = 0.55;
min_worker_salary = 0.2; max_worker_salary = 0.28;
typeDistribution = {0.4,0.4,0.2};
initial_scan_limit = 0;
difficulty = "Normal";
time_limit = Time(12,23);
dead_limit = 15000;
cout<<"Difficulty set to normal.\n";
break;
case 2: //hard
initial_testing_acc = 0.35;
virus = Virus(11,15,6,9,1.45,5,0.0069); //min_incubation, max_incubation, min_lethality, max_lethality, cure_difficulty, min_cure_hours, spread_difficulty
initial_infect = 15;
min_activity_level = 8;
max_activity_level = 12;
testing_kits_per_region = 2.5;
medical_cap_per_region = 1.5;
min_merchant_salary = 0.45; max_merchant_salary = 0.5;
min_worker_salary = 0.21; max_worker_salary = 0.25;
typeDistribution = {0.4,0.4,0.2};
initial_scan_limit = 0;
difficulty = "Hard";
time_limit = Time(10,23);
dead_limit = 12500;
cout<<"Difficulty set to hard.\n";
break;
case 3: //insane
initial_testing_acc = 0.3;
virus = Virus(13,16,5,9,1.75,6,0.0072); //min_incubation, max_incubation, min_lethality, max_lethality, cure_difficulty, min_cure_hours, spread_difficulty
initial_infect = 18;
min_activity_level = 9;
max_activity_level = 13;
testing_kits_per_region = 2.0;
medical_cap_per_region = 1.0;
min_merchant_salary = 0.42; max_merchant_salary = 0.5;
min_worker_salary = 0.17; max_worker_salary = 0.22;
typeDistribution = {0.4,0.35,0.25};
initial_scan_limit = 0;
difficulty = "Insane";
time_limit = Time(7,23);
dead_limit = 10000;
cout<<"Difficulty set to insane.\n";
break;
case 4: //hell
initial_testing_acc = 0.25;
virus = Virus(14,17,5,8,2.0,7,0.0076); //min_incubation, max_incubation, min_lethality, max_lethality, cure_difficulty, min_cure_hours, spread_difficulty
initial_infect = 25;
min_activity_level = 10;
max_activity_level = 14;
testing_kits_per_region = 2.0;
medical_cap_per_region = 1.0;
min_merchant_salary = 0.42; max_merchant_salary = 0.5;
min_worker_salary = 0.17; max_worker_salary = 0.21;
typeDistribution = {0.4,0.35,0.25};
initial_scan_limit = 0;
difficulty = "Hell";
time_limit = Time(5,23);
dead_limit = 6666;
cout<<"Difficulty set to hell.\n";
break;
default:
assert(0);
}
system("pause");
}
void MainMenu::changeGameSpeedMenu()
{
cout<<"Current delay between hours: "<<int(min_seconds_between_hour*1000)<<"ms\n";
int x = 0;
cout<<"Enter new delay (between 1000ms to 4000ms inclusive): ";
x=IOHandler::getInt(1000,4000);
min_seconds_between_hour = double(x)/double(1000);
cout<<"New delay between hours: "<<x<<"ms\n";
system("pause");
}
void MainMenu::displayHelpMenu() //tutorial menu
{
system("cls");
cout<<"A virus is spreading in your country! Your task is to ensure that the virus is properly contained in your country.\n";
cout<<"You win if every infected person alive in your country is hospitalized.\n";
cout<<"You lose when the time limit is reached or there are too many deaths in the country.\n";
cout<<"Your country is divided into several states, each of which consists of several connected regions.\n";
cout<<"Every hour, some citizens will move around the country which might spread the virus. Also, some of the citizens work which will generate funds for the country.\n";
cout<<"Every 3 hours, each state will perform random tests (based on the number of testing kits) within the state to detect new infected citizens.\n";
cout<<'\n';
cout<<"You have several tools at your disposal to stop the virus. "; IOHandler::coutc("Press any key during the game to activate the control panel.\n", IOHandler::LIGHTCYAN);
cout<<'\n';
cout<<left<<setw(60)<<"Increase testing accuracy";
cout<<"Increases the probability of finding an infected person via testing.\n";
cout<<left<<setw(60)<<"Increase testing kits";
cout<<"Increase the amount of tests performed in the state.\n";
cout<<left<<setw(60)<<"Increase medical capacity";
cout<<"Increase the amount of patients that can be hospitalized in the state.\n";
cout<<left<<setw(60)<<"Ignore patients";
cout<<"Abandon some of the sickest patients in the state hospital.\n";
cout<<left<<setw(60)<<"Scan region";
cout<<"Manually scan a region to detect infected citizens in a region.\n";
cout<<left<<setw(60)<<"Increase scan limit";
cout<<"Increase the amount of tests done during manual scans.\n";
cout<<left<<setw(60)<<"Lockdown region/state";
cout<<"Prevents people from inside the region/state to leave the region/state.\n";
cout<<left<<setw(60)<<"";
cout<<"Some work might be suspended.\n";
cout<<left<<setw(60)<<"";
cout<<"Activity of citizens within the state/region is decreased.\n";
cout<<left<<setw(60)<<"Activate movement control in state";
cout<<"Prevents people from inside the state from leaving their respective regions.\n";
cout<<left<<setw(60)<<"";
cout<<"All work in the state is suspended.\n";
cout<<left<<setw(60)<<"";
cout<<"Activity of citizens within the state/region is severely restricted.\n";
cout<<right;
system("pause");
}
void MainMenu::displayCredits() //credits menu
{
system("cls");
cout<<"This project is brought to you by:\n";
cout<<"Yeoh Zi Song\n";
cout<<"Tan Wei Jun\n";
cout<<"Hing Wan Yee\n";
cout<<"Lim Shi Qi\n";
cout<<"Kwok Wen Chi\n";
system("pause");
}
void MainMenu::displayExitMenu() //exit menu
{
system("cls");
cout<<"Thanks for playing!\n";
system("pause");
exit(0); //terminates program
}
void MainMenu::newGame() //initializes new game
{
system("cls");
Game game;
game.initGame(rows,cols,initial_testing_acc,initial_money,virus,
state_count,population_count,initial_infect,min_activity_level,max_activity_level,
testing_kits_per_region, medical_cap_per_region,
min_merchant_salary,max_merchant_salary,
min_worker_salary,max_worker_salary,
typeDistribution,initial_scan_limit,
difficulty,
time_limit,dead_limit,min_seconds_between_hour);
while(game.checkWinCondition()==0)
{
game.startHour();
}
//game ends, return to main menu
}