YAPOG  0.0.1
Yet Another Pokemon Online Game
PokemonTeam.cpp
Go to the documentation of this file.
3 #include "Pokemon/PokemonTeam.hpp"
4 
5 namespace ycl
6 {
8  : yap::PokemonTeam ()
9  , pokemonTeam_ (MAX_POKEMON_TEAM_NUMBER, nullptr)
10  , pokemonCount_ (0)
11  {
12  }
13 
15  {
16  }
17 
18  Pokemon& PokemonTeam::GetPokemon (int index) const
19  {
20  if (index >= MAX_POKEMON_TEAM_NUMBER)
21  YAPOG_THROW("Pokemon Team: index out of bound (" + yap::StringHelper::ToString (index) + ")");
22 
23  if (pokemonTeam_[index] == nullptr)
24  YAPOG_THROW("Pokemon Team: no Pokemon at this index (" + yap::StringHelper::ToString (index) + ")");
25 
26  return *pokemonTeam_[index];
27  }
28 
30  {
31  return pokemonCount_;
32  }
33 
34 
36  {
37  for (int i = 0; i < MAX_POKEMON_TEAM_NUMBER; i++)
38  {
39  if (pokemonTeam_[i] == nullptr)
40  {
41  pokemonTeam_[i] = pokemon;
42 
43  pokemonCount_++;
44 
45  return true;
46  }
47  }
48 
49  return false;
50  }
51 } // namespace ycl