YAPOG
0.0.1
Yet Another Pokemon Online Game
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
PokemonFighterTeam.cpp
Go to the documentation of this file.
1
#include "
YAPOG/Graphics/Game/Sprite/ISprite.hpp
"
2
#include "
YAPOG/Collection/Array.hpp
"
3
#include "
YAPOG/System/Error/Exception.hpp
"
4
5
#include "Pokemon/Pokemon.hpp"
6
#include "Pokemon/PokemonTeam.hpp"
7
#include "Battle/PokemonFighterTeam.hpp"
8
9
namespace
ycl
10
{
11
const
bool
PokemonFighterTeam::DEFAULT_VISIBLE_STATE
=
true
;
12
const
sf::Color
PokemonFighterTeam::DEFAULT_COLOR
= sf::Color ();
13
14
PokemonFighterTeam::PokemonFighterTeam
()
15
: yap::
PokemonFighterTeam
()
16
, isVisible_ (DEFAULT_VISIBLE_STATE)
17
, fighters_ (
PokemonTeam
::MAX_POKEMON_TEAM_NUMBER, nullptr)
18
{
19
}
20
21
PokemonFighterTeam::~PokemonFighterTeam
()
22
{
23
}
24
25
bool
PokemonFighterTeam::AddPokemon
(
PokemonFighter
* pokemonFighter)
26
{
27
for
(
int
i = 0; i <
PokemonTeam::MAX_POKEMON_TEAM_NUMBER
; i++)
28
{
29
if
(
fighters_
[i] ==
nullptr
)
30
{
31
fighters_
[i] = pokemonFighter;
32
return
true
;
33
}
34
}
35
36
return
false
;
37
}
38
39
void
PokemonFighterTeam::LoadFromPokemonTeam
(
40
PokemonTeam
& pokemonTeam,
41
bool
isOpponent)
42
{
43
int
counter = pokemonTeam.
GetPokemonCount
();
44
45
for
(
int
i = 0; i < counter; i++)
46
{
47
try
48
{
49
AddPokemon
(
new
PokemonFighter
(
50
&(pokemonTeam.
GetPokemon
(i)), isOpponent));
51
}
52
catch
(
yap::Exception
)
53
{
54
continue
;
55
}
56
}
57
}
58
59
PokemonFighter
&
PokemonFighterTeam::GetCurrentFighter
()
60
{
61
return
*
fighters_
[
currentFighterIndex_
];
62
}
63
64
const
PokemonFighter
&
PokemonFighterTeam::GetCurrentFighter
()
const
65
{
66
return
*
fighters_
[
currentFighterIndex_
];
67
}
68
71
void
PokemonFighterTeam::Draw
(
yap::IDrawingContext
& context)
72
{
73
if
(!
IsVisible
())
74
return
;
75
76
HandleDraw
(context);
77
}
78
79
bool
PokemonFighterTeam::IsVisible
()
const
80
{
81
return
isVisible_
;
82
}
83
84
void
PokemonFighterTeam::Show
(
bool
isVisible)
85
{
86
isVisible_
= isVisible;
87
88
HandleShow
(isVisible);
89
}
90
91
void
PokemonFighterTeam::ChangeColor
(
const
sf::Color& color)
92
{
93
color_
= color;
94
95
HandleChangeColor
(color);
96
}
98
99
void
PokemonFighterTeam::HandleInit
()
100
{
101
}
102
103
void
PokemonFighterTeam::HandleUpdate
(
const
yap::Time
& dt)
104
{
105
}
106
107
void
PokemonFighterTeam::HandleDraw
(
yap::IDrawingContext
& context)
108
{
109
GetCurrentFighter
().
Draw
(context);
110
}
111
112
void
PokemonFighterTeam::HandleShow
(
bool
isVisible)
113
{
114
}
115
116
void
PokemonFighterTeam::HandleChangeColor
(
const
sf::Color& color)
117
{
118
}
119
122
yap::ISprite
&
PokemonFighterTeam::GetBattleSprite
()
123
{
124
return
GetCurrentFighter
().
GetBattleSprite
();
125
}
127
128
}
// namespace yap
YAPOG.Client
src
Battle
PokemonFighterTeam.cpp
Generated on Mon Sep 17 2012 22:24:24 for YAPOG by
1.8.1.1