-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pokemon.h
283 lines (221 loc) · 9.54 KB
/
Pokemon.h
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
//
// Pokemon.h
// Pokemon
//
// Created by Jody Kocis on 11/23/18.
// Header file for Pokemon.c
//
#ifndef Pokemon_h
#define Pokemon_h
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#define LEVELOFNOMOREEVOLUTION -1
#define LEVELOFFIRSTEVOLUTION 4
#define LEVELOFSECONDEVOLUTION 8
#define MAXNUMBEROFLEVELS 5
#define MAXLINESPERMAP 100
#define MAXEMOJILENGTH 10
#define MAXSTRINGLENGTH 50 + 1
#define MAXNUMBEROFITEMSINBAG 20
#define TIMESUNTILASKTOQUIT 4
#define MAXMOVES 4
#define STAB 1.5
#define CRITICAL 1.5
#define FIRSTUNLOCKEDMAP "Starting Map"
#define NOMAPFILE "No Map File"
#define ALLMAPSFILE "All Pokemon Maps (DO NOT EDIT).txt"
#define ALLPOKEMONFILE "All Pokemon.txt"
#define ENDOFMAP "End of Map"
//When accessing these files always add the player name after
#define UNLOCKEDMAPSFILE "Unlocked Maps "
#define MYPOKEMON "My Pokemon "
#define MYITEMS "My Items "
//Map Key
#define BUSH '*'
#define PATH 'P'
#define SHORTGRASS '_'
#define LONGGRASS '^'
#define WATER '~'
#define FENCE '['
#define ROCK 'o'
#define HOUSE 'H'
#define MOUNTAIN 'M'
#define SHOPDOOR '$'
#define PLAYER '8'
#define GYMLEADER '0'
//MARK: - Enums
//Used to determine if the user is fighting a wild pokemon or a gymLeader. Is an enum because we wanted to make it easy to add future support for a feature we originally intended to add which was multiplayer battling
enum battleMode {
wild, gymLeader
};
//The natures a Pokemon can have
enum nature {
hardy, lonely, brave, adamant, naughty, bold, docile, relaxed, impish, lax, timid, hasty, serious, jolly, naive, modest, mild, quiet, bashful, rash, calm, gentle, sassy, careful, lastNature
};
//The types that a move a can be
enum moveType {
bug, fight, fire, flying, grass, ground, normal, poison, phsycic, rock, water, noType
};
//The name of every move the game supports
enum moveName {
tackle, confusion, gust, silverWind, pursuit, hyperFang, ironTail, wingAttack, steelWing, airSlash, flamethrower, slash, fireBlast, razorLeaf, sludgeBomb, powerWhip, engeryBall, surf, iceBeam, hydroPump, strength
};
//Determines if a move is physical or special
enum physicalOrSpecial {
physical, special
};
//The effectiveness values a move can have on a Pokemon
enum effectiveness {
notEffective, notVeryEffective, normalEffectiveness, superEffective
};
//The different stats value a Pokemon has
enum stats {
attack, defense, specialAttack, specialDefense, speed
};
//The name of every Pokemon the game supports
enum pokemonName {
caterpie, metapod, butterfree, rattata, raticate, pidgey, pidgeotto, pidgeot, charmander, charmeleon, charizard, bulbasaur, ivysaur, venusaur, squirtle, wartortle, blastoise, none
};
//MARK: - Structs
//Represents the player currently playing the game
typedef struct player {
char name[MAXSTRINGLENGTH];
FILE* unlockedMapsFile;
FILE* pokemonFile;
char unlockedMapsFileName[MAXSTRINGLENGTH];
char pokemonFileName[MAXSTRINGLENGTH];
int numberOfPokemon;
} Player;
//Represents a move a Pokemon can have
typedef struct move {
int damage;
enum moveType type;
enum physicalOrSpecial isPhysicalOrSpecial;
int accuracy;
enum moveName name;
} Move;
//Represent a Pokemon in game
typedef struct pokemon {
char name[MAXSTRINGLENGTH];
int baseHP;
int baseAttack;
int baseDefense;
int baseSpecialAttack;
int baseSpecialDefense;
int baseSpeed;
int ivHP;
int ivAttack;
int ivDefense;
int ivSpecialAttack;
int ivSpecialDefense;
int ivSpeed;
int evHP;
int evAttack;
int evDefense;
int evSpecialAttack;
int evSpecialDefense;
int evSpeed;
int hiddenEvAttack;
int hiddenEvDefense;
int hiddenEvSpecialAttack;
int hiddenEvSpecialDefense;
int hiddenEvSpeed;
int HP;
enum nature nature;
int XP;
int level;
enum pokemonName nextEvolution;
enum moveType type1;
enum moveType type2;
int catchRate;
int levelToEvolve;
enum stats evTypeGiven;
int evAmountGiven;
int fileNumber;
int numberOfMoves;
Move moves[MAXMOVES];
} Pokemon;
//MARK: - Function Headers
void endGame(void);
int getRandomNumber(int lower, int upper);
//Dealing with files
int playerHasPlayed(char playerName[MAXSTRINGLENGTH]);
FILE* getAllMapsFile(void);
void removeFinalNewLineCharacter(char string[MAXSTRINGLENGTH]);
//Dealing with maps
int getAllMaps(FILE* allMapsFile, char maps[MAXNUMBEROFLEVELS][MAXSTRINGLENGTH], const int maxNumberOfLevels, const int maxStringLength);
int readMap(FILE* mapsFile, char maps[MAXLINESPERMAP][MAXLINESPERMAP + 1]);
//Reading pokemon information
void getPokemonNamesAndNumbers(char pokemonFileName[MAXSTRINGLENGTH], int numberOfPokemon, char pokemonNames[numberOfPokemon][MAXSTRINGLENGTH], int pokemonNumbers[numberOfPokemon]);
int fileExistsFor(Player* player, char pokemonName[MAXSTRINGLENGTH], int pokemonNumber);
int getPokemonInformation(Pokemon* pokemon, Player* player, char pokemonName[MAXSTRINGLENGTH], int pokemonNumber);
int readPokemonInformation(FILE* pokemonFile, Pokemon* pokemon, char name[MAXSTRINGLENGTH], int fileNumber);
int checkPokemonFileInformation(Pokemon* pokemon, char informationTitle[MAXSTRINGLENGTH], char correctTitle[MAXSTRINGLENGTH]);
int fillMoveInformation(Move* move);
void writeToFile(FILE* file, char fileName[MAXSTRINGLENGTH], char string[MAXSTRINGLENGTH]);
//Getting player files
FILE* getPlayerUnlockedMapsFile(char* playerName);
FILE* getPlayerPokemon(char* playerName);
//Getting player Pokemon
int getNumberOfPokemon(void);
void getListOfAllPokemon(char allPokemon[getNumberOfPokemon()][MAXSTRINGLENGTH]);
int doesPokemonExist(char pokemonName[MAXSTRINGLENGTH]);
//Startup
void launchGame(void);
int startMainMenu(Player *player, int isNewPlayer);
int createPlayer(char playerName[MAXSTRINGLENGTH], Player* player);
//Creating Pokemon and writing Pokemon informatnio
void chooseStarterPokemon(Player* player, Pokemon* starterPokemon);
void addPokemonToPlayer(Player* player, Pokemon* pokemon);
void writePokemonInformation(FILE* pokemonFile, char pokemonFileName[MAXSTRINGLENGTH], Pokemon* pokemon);
int createPokemon(Pokemon* pokemon, enum pokemonName pokemonName);
//Presenting visual aspects of the game
int startMap(Player* player, int isNewPlayer, char mapFileName[MAXSTRINGLENGTH]);
void presentPokemon(Player* player);
int elementsAreInArrays(Player* player, char element[MAXSTRINGLENGTH], int number, char array[player->numberOfPokemon][MAXSTRINGLENGTH], int intArray[player->numberOfPokemon]);
int checkAndPerformAction(char map[MAXLINESPERMAP][MAXLINESPERMAP + 1], int playerRow, int playerColumn, Player* player);
int canStandOnSpot(char map[MAXLINESPERMAP][MAXLINESPERMAP + 1], int playerRow, int playerColumn);
int isActionBreakable(char action);
void printMapAndKeyAndPlayer(char map[MAXLINESPERMAP][MAXLINESPERMAP + 1], int mapHeight, int playerRow, int playerColumn);
void printMapWithPlayer(char map[MAXLINESPERMAP][MAXLINESPERMAP + 1], int mapHeight, int playerRow, int playerColumn);
void convertCharacterToEmoji(char character, char emoji[MAXEMOJILENGTH]);
void printMapKey(void);
//Dealing with maps
void findAvailableSpot(char map[MAXLINESPERMAP][MAXLINESPERMAP + 1], int mapHeight, int availableSpot[2]);
int isPositionInMap(char map[MAXLINESPERMAP][MAXLINESPERMAP + 1], int mapHeight, int row, int column);
int characterIsAvailableToPlacePlayerOn(char character);
int unlockedNewMaps(Player* player);
int isMapUnlocked(char map[MAXSTRINGLENGTH], char unlockedMaps[MAXNUMBEROFLEVELS][MAXSTRINGLENGTH]);
//Simulating spots on the map
int checkLongGrass(Player* player);
void startGymLeaderBattle(Player* player);
void showShop(Player* player);
//Battling
int startBattle(Pokemon* pokemon1, Pokemon* pokemon2, enum battleMode battleMode, const char player1Name[MAXSTRINGLENGTH], const char player2Name[MAXSTRINGLENGTH], Player* player1);
int getMaxHP(Pokemon pokemon);
double getAttack(Pokemon pokemon);
double getDefense(Pokemon pokemon);
double getSpecialAttack(Pokemon pokemon);
double getSpecialDefense(Pokemon pokemon);
double getSpeed(Pokemon pokemon);
enum effectiveness damage(int moveIndex, Pokemon* attackingPokemon, Pokemon* attackedPokemon);
double getTypeMultipler(enum moveType moveType, enum moveType pokemonType1, enum moveType pokemonType2);
double getValueOfEffectiveness(enum effectiveness effectiveness);
int levelUp(Pokemon *pokemon);
double getNatureMultiplyer(enum stats stat, enum nature);
//Converting enums to string and strings to enums
void convertPhysicalOrSpecialToString(enum physicalOrSpecial physicalOrSpecial, char physicalOrSpecialAsString[MAXSTRINGLENGTH]);
enum physicalOrSpecial convertPhysicalOrSpecialStringToPhysicalOrSpecial(char physicalOrSpecialString[MAXSTRINGLENGTH]);
void convertMoveTypeToString(enum moveType moveType, char moveTypeAsString[MAXSTRINGLENGTH]);
enum moveType convertMoveTypeStringToMoveType(char moveTypeAsString[MAXSTRINGLENGTH]);
void convertMoveNameToString(enum moveName moveName, char moveNameAsString[MAXSTRINGLENGTH]);
enum moveName convertMoveNameStringToMoveName(char moveNameAsString[MAXSTRINGLENGTH]);
void convertNatureToString(enum nature nature, char natureAsString[MAXSTRINGLENGTH]);
enum nature convertNatureStringToNature(char natureAsString[MAXSTRINGLENGTH]);
void convertPokemonNextEvolutionToString(enum pokemonName nextEvolution, char nextEvolutionName[MAXSTRINGLENGTH]);
enum pokemonName convertPokemonStringToNextEvolution(char pokemonString[MAXSTRINGLENGTH]);
void convertStatToString(enum stats stat, char statAsString[MAXSTRINGLENGTH]);
enum stats convertStatStringToStat(char statAsString[MAXSTRINGLENGTH]);
#endif /* Pokemon_h */