YAPOG
0.0.1
Yet Another Pokemon Online Game
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
PokemonTeam.cpp
Go to the documentation of this file.
1
#include "
YAPOG/System/Error/Exception.hpp
"
2
#include "
YAPOG/System/StringHelper.hpp
"
3
#include "Pokemon/PokemonTeam.hpp"
4
5
namespace
yse
6
{
7
PokemonTeam::PokemonTeam
()
8
: yap::
PokemonTeam
()
9
, pokemonTeam_ (MAX_POKEMON_TEAM_NUMBER, nullptr)
10
, pokemonNumber_ (0)
11
{
12
}
13
14
PokemonTeam::~PokemonTeam
()
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
29
int
PokemonTeam::GetPokemonCount
()
const
30
{
31
return
pokemonNumber_
;
32
}
33
34
35
bool
PokemonTeam::AddPokemon
(
Pokemon
* pokemon)
36
{
37
for
(
int
i = 0; i <
MAX_POKEMON_TEAM_NUMBER
; i++)
38
{
39
if
(
pokemonTeam_
[i] ==
nullptr
)
40
{
41
pokemonTeam_
[i] = pokemon;
42
pokemonNumber_
++;
43
44
return
true
;
45
}
46
}
47
48
return
false
;
49
}
50
}
// namespace yse
YAPOG.Server
src
Pokemon
PokemonTeam.cpp
Generated on Mon Sep 17 2012 22:24:25 for YAPOG by
1.8.1.1