Commit 61348d37 authored by a-j.towse's avatar a-j.towse

All functions working

parent 7518d06b
No preview for this file type
...@@ -49,7 +49,7 @@ struct PlayerNode * FindPlayer(struct Pokedex pokedex, char name[]); ...@@ -49,7 +49,7 @@ struct PlayerNode * FindPlayer(struct Pokedex pokedex, char name[]);
//Define functions for other functionality //Define functions for other functionality
void AddPokemonToPlayer(struct Pokedex pokedex, char playerName[], char pokemonName[]); void AddPokemonToPlayer(struct Pokedex pokedex, char playerName[], char pokemonName[]);
void DisplayPokemonDetails(struct Pokedex pokedex, char name[]); void DisplayPokemonDetails(struct Pokedex pokedex, char name[]);
void DiplayPlayerDetails(struct Pokedex pokedex, char name); void DisplayPlayerDetails(struct Pokedex pokedex, char name[]);
void ListPokemon(struct Pokedex pokedex); void ListPokemon(struct Pokedex pokedex);
void ListPlayers(struct Pokedex pokedex); void ListPlayers(struct Pokedex pokedex);
...@@ -85,6 +85,11 @@ int main (void) { ...@@ -85,6 +85,11 @@ int main (void) {
ListPlayers(pokedex); ListPlayers(pokedex);
AddPokemonToPlayer(pokedex,"Joe","Charmander"); AddPokemonToPlayer(pokedex,"Joe","Charmander");
AddPokemonToPlayer(pokedex,"Joe","Squirtle");
DisplayPokemonDetails(pokedex,"Charmander");
DisplayPlayerDetails(pokedex,"Joe");
return 0; return 0;
} }
...@@ -250,7 +255,7 @@ void AddPokemonToPlayer(struct Pokedex pokedex, char playerName[], char pokemonN ...@@ -250,7 +255,7 @@ void AddPokemonToPlayer(struct Pokedex pokedex, char playerName[], char pokemonN
return; return;
} }
for (int i = 0; 1 < playerAdd->pokemonCount; i++) { for (int i = 0; i < playerAdd->pokemonCount; i++) {
if (playerAdd->pokemonArray[i] == pokemonAdd){ if (playerAdd->pokemonArray[i] == pokemonAdd){
return; return;
...@@ -262,5 +267,21 @@ void AddPokemonToPlayer(struct Pokedex pokedex, char playerName[], char pokemonN ...@@ -262,5 +267,21 @@ void AddPokemonToPlayer(struct Pokedex pokedex, char playerName[], char pokemonN
} }
void DisplayPokemonDetails(struct Pokedex pokedex, char name[]) { void DisplayPokemonDetails(struct Pokedex pokedex, char name[]) {
PokemonNode *pokemonAdd = FindPokemon(pokedex,name);
printf("Name: %s\n"
"\tType: %s\n"
"\tAbility: %s\n",pokemonAdd->name,pokemonAdd->type,pokemonAdd->ability);
}
void DisplayPlayerDetails(struct Pokedex pokedex, char name[]) {
PlayerNode *playerAdd = FindPlayer(pokedex,name);
printf("Name: %s\n"
"\tPokemon Count: %i\n"
"\tPokemon Owned: ",playerAdd->name,playerAdd->pokemonCount);
for (int i = 0 ; i < playerAdd->pokemonCount ; i++) {
printf("\t\t%s,",playerAdd->pokemonArray[i]->name);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment