-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmove.cpp
More file actions
369 lines (298 loc) · 6.22 KB
/
move.cpp
File metadata and controls
369 lines (298 loc) · 6.22 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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
//Brandon Aubrey, Morris LaGrand, Tyler Sammons
//cpp file for move
//4/10/2015
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
//#include "Pokemon.h"
#include "move.h"
using namespace std;
//non-default constructor
move::move(int numb) {
string trash, typeName, statusName, statsName;
ifstream infile;
infile.open("moveList.txt");
if (infile.is_open()) {
getline(infile,trash);
for (int i = 0; i < numb; i++) {
getline(infile, trash);
}
//using string stream
stringstream ss;
ss << trash;
ss >> number >> mve >> typeName >> pwr >> acc >> pp >> statusName >> prob >> specialTag;
ss >> selfChange >> foeChange >> statsName;
typeFromText(typeName);
typeFromText_2(statusName);
statsFromText(statsName);
}
curr_pp = pp;
}
//non-default constructor
move::move(int num, string mv, types tpe, int power, int accur, int pPoint, status st, float Probab) {
number = num; //setting number equal to the num (getting the number of the move)
mve = mv; //setting move = mve (getting the name of hte move)
type = tpe; //setting type = tpe (getting th
pwr = power; //setting pwr equal to power
acc = accur; //setting acc equal to the accuracy
pp = pPoint; //setting pp equal to pPoint
prob = Probab; //setting prob equal to probab
curr_pp = pp;
stat = st;
}
move::move() {
number = 1;
}
//function to return the power of the move
int move::get_pow() {
return pwr;
}
//function to return the accuracy of the move
int move::get_acc() {
return acc;
}
//function to return the power points of the move
int move::get_pp() {
return curr_pp;
}
//returning the status change of the move
status move::get_status() {
return stat;
}
//returns the probability of the status change
float move::get_prob() {
return prob;
}
//returning the chance of a critical hit
float move::get_crit() {
return crit;
}
void move::display() {
cout<<number<<" "<<mve<<" "<<getTypeText(type)<<" "<<pwr<<" "<<acc<<" "<<pp<<" "<<getStatusText()<<" "<<specialTag<<endl;
}
//reduces the current pp after te move is used
int move::reduce_pp() {
curr_pp = curr_pp - 1; //subtracts 1 from the current pp after a move is used
return curr_pp;
}
string move::getName()
{
return mve;
}
//resets the current pp to the value of the pp
int move:: reset_pp() {
curr_pp = pp;
}
//sets type value given a text, used in loading function
void move::typeFromText(string t)
{
if(t == "Normal")
type = Normal;
else if(t == "Grass")
type = Grass;
else if(t == "Water")
type = Water;
else if(t == "Fire")
type = Fire;
else if(t == "Flying")
type = Flying;
else if(t == "Fight")
type = Fight;
else if(t == "Psychic")
type = Psychic;
else if(t == "Bug")
type = Bug;
else if(t == "Poison")
type = Poison;
else if(t == "Eletric")
type = Eletric;
else if(t == "Rock")
type = Rock;
else if(t == "Ground")
type = Ground;
else if(t == "Ghost")
type = Ghost;
else if(t == "Dark")
type = Dark;
else if(t == "Ice")
type = Ice;
else if(t == "Dragon")
type = Dragon;
else
type = Normal;
}
//returns text version of status
string move::getStatusText()
{
string toRet;
switch(stat)
{
case normal:
toRet = "Normal";
break;
case burned:
toRet = "Burned";
break;
case poisoned:
toRet = "Poisoned";
break;
case asleep:
toRet = "Sleep";
break;
case paralyzed:
toRet = "Paralyzed";
break;
case frozen:
toRet = "Frozen";
break;
case fainted:
toRet = "Faint";
break;
default:
toRet = "ERROR";
break;
}
return toRet;
}
string move::getStatText()
{
string toRet;
switch(change)
{
case atk:
toRet = "atk";
break;
case def:
toRet = "def";
break;
case spAtk:
toRet = "spAtk";
break;
case spDef:
toRet = "spDef";
break;
case speed:
toRet = "speed";
break;
case HP:
toRet = "HP";
break;
case maxHP:
toRet = "maxHP";
break;
default:
toRet = "ERROR";
break;
}
return toRet;
}
//returns type in text
string move::getTypeText(types t)
{
string toRet;
switch(t)
{
case Normal:
toRet = "Normal";
break;
case Grass:
toRet = "Grass";
break;
case Water:
toRet = "Water";
break;
case Fire:
toRet = "Fire";
break;
case Flying:
toRet = "Flying";
break;
case Fight:
toRet = "Fight";
break;
case Psychic:
toRet = "Psychic";
break;
case Bug:
toRet = "Bug";
break;
case Poison:
toRet = "Poison";
break;
case Eletric:
toRet = "Eletric";
break;
case Rock:
toRet = "Rock";
break;
case Ground:
toRet = "Ground";
break;
case Ghost:
toRet = "Ghost";
break;
case Dark:
toRet = "Dark";
break;
case Ice:
toRet = "Ice";
break;
case Dragon:
toRet = "Dragon";
break;
}
return toRet;
}
void move::statsFromText(string s)
{
if(s == "atk") change = atk;
else if(s == "def") change = def;
else if(s == "spAtk") change = spAtk;
else if(s == "spDef") change = spDef;
else if(s == "speed") change = speed;
else if(s == "HP") change = HP;
else change = maxHP;
}
void move::typeFromText_2(string t) {
if (t == "normal") stat = normal;
else if (t == "burned") stat = burned;
else if (t == "poisoned") stat = poisoned;
else if (t == "asleep") stat = asleep;
else if (t == "paralyzed") stat = paralyzed;
else if (t == "frozen") stat = frozen;
else if (t == "fainted") stat = fainted;
else stat = normal;
}
string move::BattleDisplay() {
string curr;
string totpp;
stringstream convertCurr;
stringstream convertTotpp;
convertCurr << curr_pp;
convertCurr >> curr;
convertTotpp << pp;
convertTotpp >> totpp;
string str;
str += mve;
str += getTypeText(type) + " PP " + curr + "/" + totpp;
return str;
}
int move::getSpecial() {
return specialTag;
}
types move::get_type() {
return type;
}
int move::getSelfChange()
{
return selfChange;
}
int move::getFoeChange()
{
return foeChange;
}
stats move::getChangeStat()
{
return change;
}