-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassignment.cpp
More file actions
323 lines (293 loc) · 8.97 KB
/
assignment.cpp
File metadata and controls
323 lines (293 loc) · 8.97 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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
#include "Dice.h"
#include "Creature.h"
#include "Barbarian.h"
#include "Shadow.h"
#include "Goblin.h"
#include "BlueM.h"
#include "Reptile.h"
#include<iostream>
#include<string>
#include<vector>
int displayMenu();
void fight(Creature* one, Creature* two, std::vector<int> &oneWin, std::vector<int> &twoWin, int &game);
void statistics(std::string player, std::vector<int> &oneWin, std::vector<int> &twoWin);
int main()
{
Barbarian* b1 = new Barbarian;
Barbarian* b2 = new Barbarian;
Shadow* s1 = new Shadow;
Shadow* s2 = new Shadow;
Reptile* r1 = new Reptile;
Reptile* r2 = new Reptile;
BlueM* bl1 = new BlueM;
BlueM* bl2 = new BlueM;
Goblin* g1 = new Goblin;
Goblin* g2 = new Goblin;
int menuChoice;
int prevMenu;
int game;
std::string moveOn;
std::vector<int> oneWin;
std::vector<int> twoWin;
game = 0;
prevMenu = 0;
std::cout << "\n" <<std::endl;
menuChoice = displayMenu();
while(menuChoice != 16)
{
switch(menuChoice)
{
case 1:
if(prevMenu != menuChoice){
oneWin.clear();
twoWin.clear();}
std::cout << "Barbarian vs. Barbarian" << std::endl;
fight(b1, b2, oneWin, twoWin, game);
prevMenu = menuChoice;
std::cout << "Please hit any key to return to menu";
std::getline(std::cin, moveOn);
delete b1;
delete b2;
b1 = new Barbarian;
b2 = new Barbarian;
menuChoice = displayMenu();
break;
case 2: if(prevMenu != menuChoice){
oneWin.clear();
twoWin.clear();}
std::cout << "Shadow vs. Shadow" << std::endl;
fight(s1, s2, oneWin, twoWin, game);
prevMenu = menuChoice;
std::cout << "Please hit any key to return to menu";
std::getline(std::cin, moveOn);
delete s1;
delete s2;
s1 = new Shadow;
s2 = new Shadow;
menuChoice = displayMenu();
break;
case 3: if(prevMenu != menuChoice){
oneWin.clear();
twoWin.clear();}
std::cout << "Reptile Men vs. Reptile Men" << std::endl;
fight(r1, r2, oneWin, twoWin, game);
prevMenu = menuChoice;
std::cout << "Please hit any key to return to menu";
std::getline(std::cin, moveOn);
delete r1;
delete r2;
r1 = new Reptile;
r2 = new Reptile;
menuChoice = displayMenu();
break;
case 4: if(prevMenu != menuChoice){
oneWin.clear();
twoWin.clear();}
std::cout << "Blue Men vs. Blue Men" << std::endl;
fight(bl1, bl2, oneWin, twoWin, game);
prevMenu = menuChoice;
std::cout << "Please hit any key to return to menu";
std::getline(std::cin, moveOn);
bl1 = new BlueM;
bl2 = new BlueM;
menuChoice = displayMenu();
break;
case 5 : if(prevMenu != menuChoice){
oneWin.clear();
twoWin.clear();}
std::cout << "Goblin vs. Goblin" << std::endl;
fight(g1, g2, oneWin, twoWin, game);
prevMenu = menuChoice;
std::cout << "Please hit any key to return to menu";
std::getline(std::cin, moveOn);
delete g1;
delete g2;
g1 = new Goblin;
g2 = new Goblin;
menuChoice = displayMenu();
break;
case 6 : if(prevMenu != menuChoice){
oneWin.clear();
twoWin.clear();}
std::cout << "Barbarian vs. Shadow" << std::endl;
fight(b1, s2, oneWin, twoWin, game);
prevMenu = menuChoice;
std::cout << "Please hit any key to return to menu";
std::getline(std::cin, moveOn);
delete b1;
delete s2;
b1 = new Barbarian;
s2 = new Shadow;
menuChoice = displayMenu();
break;
case 7 : if(prevMenu != menuChoice){
oneWin.clear();
twoWin.clear();}
std::cout << "Barbarian vs. Reptile Men" << std::endl;
fight(b1, r2, oneWin, twoWin, game);
prevMenu = menuChoice;
std::cout << "Please hit any key to return to menu";
std::getline(std::cin, moveOn);
delete b1;
delete r2;
b1 = new Barbarian;
r2 = new Reptile;
menuChoice = displayMenu();
break;
case 8 : if(prevMenu != menuChoice){
oneWin.clear();
twoWin.clear();}
std::cout << "Barbarian vs. Blue Men" << std::endl;
fight(b1, bl2, oneWin, twoWin, game);
prevMenu = menuChoice;
std::cout << "Please hit any key to return to menu";
std::getline(std::cin, moveOn);
delete b1;
delete bl2;
b1 = new Barbarian;
bl2 = new BlueM;
menuChoice = displayMenu();
break;
case 9 : if(prevMenu != menuChoice){
oneWin.clear();
twoWin.clear();}
std::cout << "Barbarian vs. Goblin" << std::endl;
fight(b1, g2, oneWin, twoWin, game);
prevMenu = menuChoice;
std::cout << "Please hit any key to return to menu";
std::getline(std::cin, moveOn);
delete b1;
delete g2;
b1 = new Barbarian;
g2 = new Goblin;
menuChoice = displayMenu();
break;
case 10 : if(prevMenu != menuChoice){
oneWin.clear();
twoWin.clear();}
std::cout << "Shadow vs. Reptile" << std::endl;
fight(s1, r2, oneWin, twoWin, game);
prevMenu = menuChoice;
std::cout << "Please hit any key to return to menu";
std::getline(std::cin, moveOn);
delete s1;
delete r2;
s1 = new Shadow;
r2 = new Reptile;
menuChoice = displayMenu();
break;
case 11 : if(prevMenu != menuChoice){
oneWin.clear();
twoWin.clear();}
std::cout << "Shadow vs. Blue Men" << std::endl;
fight(s1, bl2, oneWin, twoWin, game);
prevMenu = menuChoice;
std::cout << "Please hit any key to return to menu";
std::getline(std::cin, moveOn);
delete s1;
delete bl2;
s1 = new Shadow;
bl2 = new BlueM;
menuChoice = displayMenu();
break;
case 12 : if(prevMenu != menuChoice){
oneWin.clear();
twoWin.clear();}
std::cout << "Shadow vs. Goblin" << std::endl;
fight(s1, g2, oneWin, twoWin, game);
prevMenu = menuChoice;
std::cout << "Please hit any key to return to menu";
std::getline(std::cin, moveOn);
delete s1;
delete g2;
s1 = new Shadow;
g2 = new Goblin;
menuChoice = displayMenu();
break;
case 13 : if(prevMenu != menuChoice){
oneWin.clear();
twoWin.clear();}
std::cout << "Blue Men vs. Goblin" << std::endl;
fight(bl1, g2, oneWin, twoWin, game);
prevMenu = menuChoice;
std::cout << "Please hit any key to return to menu";
std::getline(std::cin, moveOn);
delete bl1;
delete g2;
bl1 = new BlueM;
g2 = new Goblin;
menuChoice = displayMenu();
break;
case 14 : if(prevMenu != menuChoice){
oneWin.clear();
twoWin.clear();}
std::cout << "Blue Men vs. Reptile" << std::endl;
fight(bl1, r2, oneWin, twoWin, game);
prevMenu = menuChoice;
std::cout << "Please hit any key to return to menu";
std::getline(std::cin, moveOn);
delete bl1;
delete r2;
bl1 = new BlueM;
r2 = new Reptile;
menuChoice = displayMenu();
break;
case 15 : if(prevMenu != menuChoice){
oneWin.clear();
twoWin.clear();}
std::cout << "Goblin vs. Reptile" << std::endl;
fight(g1, r2, oneWin, twoWin, game);
prevMenu = menuChoice;
std::cout << "Please hit any key to return to menu";
std::getline(std::cin, moveOn);
delete g1;
delete r2;
g1 = new Goblin;
r2 = new Reptile;
menuChoice = displayMenu();
break;
case 16 : return 0;
}
}
}
/*******************************************************************
* int displayMenu()
*
* Purpose: Displays the menu options for the user to pick from
* Entry: Within the function, receives user input for menu choice
* Exit: Returns the user's choice so it may be used in main for the
* switch
* *****************************************************************/
int displayMenu()
{
int choice;
std::string option;
std::cout << "\n" << std::endl;
std::cout << "Please select from the following options: " << std::endl;
std::cout << "1. Test Barbarian vs. Barbarian " << std::endl;
std::cout << "2. Test Shadow vs. Shadow " <<std::endl;
std::cout << "3. Test Reptile vs. Reptile " << std::endl;
std::cout << "4. Test Blue Men vs. Blue Men " << std::endl;
std::cout << "5. Test Goblin vs. Goblin " << std::endl;
std::cout << "6. Test Barabarian vs. Shadow " << std::endl;
std::cout << "7. Test Barbarian vs. Reptile " << std::endl;
std::cout << "8. Test Barbarian vs. Blue Men " << std::endl;
std::cout << "9. Test Barbarian vs. Goblin " << std::endl;
std::cout << "10. Test Shadow vs. Reptile " << std::endl;
std::cout << "11. Test Shadow vs. Blue Men " << std::endl;
std::cout << "12. Test Shadow. vs. Goblin " << std::endl;
std::cout << "13. Test Blue Men vs. Goblin " << std::endl;
std::cout << "14. Test Blue Men vs. Reptile " << std::endl;
std::cout << "15. Test Goblin vs. Reptile " << std::endl;
std:: cout << "16. Quit " << std::endl;
std::cout << "\n" << "Selection: ";
std::getline(std::cin, option);
choice = atoi(option.c_str());
while(choice < 1 || choice > 16)
{
std::cout << "Error. Please enter a valid choice: " << std::endl;
choice = displayMenu();
}
std::cout << "\n" << std::endl;
return choice;
}