-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
181 lines (151 loc) · 4.47 KB
/
main.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
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
#include <iostream>
#include <string.h>
#include "Point2D.h"
#include "Vector2D.h"
#include "GameObject.h"
#include "Building.h"
#include "PokemonCenter.h"
#include "PokemonGym.h"
#include "Trainer.h"
#include "Model.h"
#include "GameCommand.h"
#include "View.h"
#include "WildPokemon.h"
using namespace std;
int main() {
bool a = true;
Model M1 = Model();
View V1 = View();
cout << "Welcome to EC327 Pokemon Deluxe Extraordinaire!" << endl;
cout << "For instructions on how to play, type 'h' and press enter" << endl;
do {
V1.Clear();
int ID1, ID2, x, y, potion_amount, battle_amount, X, Y, id_num;
char command, type;
M1.Display(V1);
cout << "Enter commands: " << endl;
cin >> command;
try{
switch (command) {
case 'h':
{
cout << "\n"
"GAME OBJECTIVE:\n"
"To win, Trainers must defeat all of the PokemonGyms.\n"
"If all Trainers run out of health, you lose.\n"
"Trainers can only fight battles inside of a PokemonGym.\n"
"Trainers can only recover health inside of a PokemonCenter.\n"
"PokeDollars are obtained by moving around the map and fighting battles\n"
"Use PokeDollars to buy potions and recover health\n"
"WildPokemon will follow Trainers and decrease health\n"
"\n"
"GAME COMMANDS:\n"
"(m Trainer_ID X Y) moves a Trainer to the given coordinates\n"
"(c Trainer_ID Center_ID) moves a Trainer to the PokemonCenter\n"
"(g Trainer_ID Center_ID) moves a Trainer to the PokemonGym\n"
"(s Trainer_ID) stops Trainer from moving\n"
"(b Trainer_ID battle_amount) Trainer fights given number of battles\n"
"(p Trainer_ID potion_amount) Trainer takes given number of potions\n"
"(a) advances time by one tick\n"
"(q) quits game\n"
" " << endl;
break;
}
//moves Trainer to user-defined point
case 'm':
{
cin >> ID1 >> x >> y;
Point2D p1 = Point2D(x, y);
DoMoveCommand(M1, ID1, p1);
break;
}
//moves Trainer to a specified PokemonCenter
case 'c':
{
cin >> ID1 >> ID2;
DoMoveToCenterCommand(M1, ID1, ID2);
break;
}
//moves Trainer to a specified PokemonGym
case 'g':
{
cin >> ID1 >> ID2;
DoMoveToGymCommand(M1, ID1, ID2);
break;
}
//stops trainer
case 's':
{
cin >> ID1;
DoStopCommand(M1, ID1);
break;
}
//battling command
case 'b':
{
cin >> ID1 >> battle_amount;
DoBattleCommand(M1, ID1, battle_amount);
break;
}
//dispensing potions command
case 'p':
{
cin >> ID1 >> potion_amount;
DoRecoverInCenterCommand(M1, ID1, potion_amount);
break;
}
//quit program - PROBABLY INCORRECT, MAY NEED TO WRITE A QUIT FUNCTION
case 'q':
{
exit(0);
break;
}
//advance time by updating all objects once
case 'a':
{
M1.Update();
M1.ShowStatus();
cout << "Time advanced one tick" << endl;
break;
}
//advance time by five, or until any object returns true
//this is how we check for important events
case 'r':
{
//iterates five times unless stopped
for (int i = 0; i < 5; i++)
{
//model.Update();
bool result = false;
result = M1.Update();
M1.ShowStatus();
cout << "Time advanced one tick" << endl;
//if Update() is true, return
if (result)
{
break;
}
}
break;
}
//creating a new object
case 'n':
{
cin >> type >> id_num >> X >> Y;
M1.NewCommand(type, id_num, X, Y);
break;
}
default:
{
cout << "Error: Please enter a valid command!" << endl;
break;
}
}
}
catch(Invalid_Input& except) {
cout << "Invalid input - " << except.msg_ptr << endl;
//any other actions taken
}
} while (a == true);
return 0;
}