@@ -75,7 +75,7 @@ class Pokemon{
75
75
int currHealth;
76
76
int level;
77
77
int exp;
78
- int maxLevelExp;
78
+ int maxLevelExp; // experience needed to level up
79
79
int maxAttack;
80
80
int currAttack;
81
81
int maxDef;
@@ -84,8 +84,8 @@ class Pokemon{
84
84
int currSpeed;
85
85
int KO; // boolean var
86
86
int moveLevel; // level at which Pokemon learns fifth move
87
- string type;
88
- string name;
87
+ string type; // Pokemon elemental type
88
+ string name; // Pokemon name
89
89
string weak; // type Pokemon is weak to
90
90
vector <string> attackName;// how can we still utilize this given the Moves class?
91
91
vector <Moves> myMoves;// then we can use for example myMoves[2].attack()
@@ -95,10 +95,6 @@ Pokemon::Pokemon(){
95
95
srand (time (NULL )); // seed rand
96
96
maxLevelExp = 50 ; // genaric maxlevelexp
97
97
}
98
- // non-default for loading a pokemon
99
- // Pokemon::Pokemon(int,int,int,int,int,int,int,int,int,int,int,int,string,string,string){ //check if knows 5 move
100
-
101
- // }
102
98
103
99
void Pokemon::setnum (int n) {
104
100
num = n;
@@ -120,21 +116,9 @@ void Pokemon::levelUp() {
120
116
exp = exp - maxLevelExp; // set exp to the overflow
121
117
maxLevelExp+=30 ; // increase max exp to next level up
122
118
maxAttack += (rand () % 4 ) + 1 ; // add a random attack stat amount
123
- // Don't increment current attack?
124
119
maxDef += (rand () % 4 ) + 1 ; // increment defense by a random stat amount
125
- // Don't increment current def?
126
120
maxSpeed += (rand () % 4 ) + 1 ; // increment speed
127
- // Don't increment current Speed?
128
- // KO does not change
129
-
130
- // If necessary, add a new move
131
- /*
132
- myMoves[0] = myMoves[1];
133
- myMoves[1] = myMoves[2];
134
- myMoves[2] = myMoves[3];
135
- myMoves.pop_back(); // remove move from back
136
- myMoves.push_back(newmove); // add new move to the back
137
- */
121
+
138
122
if (level == moveLevel){ // at level 5 learn new moves
139
123
cout << " Learned new move: " << myMoves[4 ].display () << " Replaced move: " << myMoves[0 ].display () << endl;
140
124
myMoves[0 ] = myMoves[1 ]; // first move is removed
@@ -157,39 +141,24 @@ void Pokemon::setcurrHealth(int h) {
157
141
if (h > 0 )
158
142
currHealth = h; // sets new health
159
143
else
160
- currHealth = 0 ;
144
+ currHealth = 0 ; // fallback value
161
145
}
162
146
163
147
void Pokemon::inccurrHealth (int add) {
164
148
currHealth += add; // inc health for potion and other increases
165
149
}
166
- /* void Pokemon::attack(int moveNum){ //attack function that calls certain moveNumber
167
- int userNum; //input by user, can be removed
168
- while (userNum != -1){ //just a way to check each attack
169
- cout << "What attack would you like to use (1-4): "; //1-2 right now
170
- cin >> userNum; //user enters attack
171
- if(userNum > 0 && userNum < 5){ //makes sure attack is in vector and 1 - 4
172
- cout << "Move number "<< userNum <<" is " << myMoves[userNum-1].display() << endl;
173
- int damage = myMoves[userNum-1].attack(maxAttack); //calculate damage eventually take into account weaknesses and such
174
- cout << "The attack did " << damage << " damage!" << endl; //display results
175
- subHealth(damage); // subtract health based on damage dealt
176
- }
177
- }
178
- }*/
179
150
180
151
void Pokemon::attack (int attackNum,Pokemon* poke_damage_ptr){ // attack function that calls certain moveNumber
181
- // cout << "Move number "<< attackNum <<" is " << myMoves[attackNum-1].display() << endl;
182
152
int damage = myMoves[attackNum-1 ].attack (maxAttack); // calculate damage eventually take into account weaknesses and such
183
153
cout << " Attack power: " << damage << endl; // display results
184
154
(*poke_damage_ptr).subHealth (damage); // subtract health based on damage dealt
185
155
}
186
156
187
157
void Pokemon::subHealth (int dam) {
188
- // cout << "Health was: " << getcurrHealth() << endl;
189
158
int damage = dam - currDef; // calculate damage
190
- cout << " Resisted " << getcurrDef () << " damage!" << endl;
159
+ cout << " Resisted " << getcurrDef () << " damage!" << endl; // account for defense
191
160
if (damage > 0 ) {
192
- cout << " Actual damage: " << (damage) << endl;
161
+ cout << " Actual damage: " << (damage) << endl; // display damage
193
162
setcurrHealth ((getcurrHealth () - damage)); // reduce current health
194
163
}
195
164
else {
@@ -200,7 +169,6 @@ void Pokemon::subHealth(int dam) {
200
169
KO = 1 ; // if health falls below 0, Pokemon becomes KO'd
201
170
cout << " KO" << endl;
202
171
}
203
- // cout << "Health is now: " << getcurrHealth() << endl;
204
172
cout << endl;
205
173
}
206
174
@@ -210,6 +178,8 @@ void Pokemon::addHealth(int add) {
210
178
}
211
179
}
212
180
181
+ /* Getters and setters for Pokemon data members */
182
+
213
183
void Pokemon::setlevel (int lv) {
214
184
level = lv;
215
185
}
@@ -335,24 +305,24 @@ string Pokemon::attackname(int moveNum){
335
305
}
336
306
337
307
void Pokemon::learnNewMove (){
338
- myMoves[0 ] = myMoves[1 ]; // first move is removed
339
- myMoves[1 ] = myMoves[2 ];
308
+ myMoves[0 ] = myMoves[1 ]; // first move is replaced
309
+ myMoves[1 ] = myMoves[2 ]; // move other moves back one usable spot
340
310
myMoves[2 ] = myMoves[3 ];
341
- myMoves[3 ] = myMoves[4 ];
311
+ myMoves[3 ] = myMoves[4 ]; // move in fifth slot moved to usable fourth slot
342
312
}
343
313
344
314
void Pokemon::setMoves (int mv1, int mv2, int mv3, int mv4, int mv5) {
345
315
346
- Moves move1 (mv1), move2 (mv2), move3 (mv3), move4 (mv4), move5 (mv5);
316
+ Moves move1 (mv1), move2 (mv2), move3 (mv3), move4 (mv4), move5 (mv5); // assign moves based on enum values
347
317
348
318
myMoves.push_back (move1); // push moves into myMoves
349
319
myMoves.push_back (move2);
350
320
myMoves.push_back (move3);
351
- myMoves.push_back (move4);
321
+ myMoves.push_back (move4); // last usable move slot
352
322
myMoves.push_back (move5); // potential move to learn
353
323
}
354
324
355
- int Pokemon::getMoveNum (int move) {
325
+ int Pokemon::getMoveNum (int move) { // returns enum values of specified move number
356
326
switch (move) {
357
327
case 0 :
358
328
return myMoves[0 ].getmovenum ();
0 commit comments