YAPOG
0.0.1
Yet Another Pokemon Online Game
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
BaseStat.cpp
Go to the documentation of this file.
1
#include "
YAPOG/Game/Pokemon/BaseStat.hpp
"
2
#include "
YAPOG/System/MathHelper.hpp
"
3
#include "
YAPOG/System/RandomHelper.hpp
"
4
5
namespace
yap
6
{
7
const
UInt16
BaseStat::INITIAL_STAT_VALUE
= 0;
8
const
UInt16
BaseStat::INITIAL_EFFORT_VALUE
= 1;
9
10
BaseStat::BaseStat
()
11
: value_ (INITIAL_STAT_VALUE)
12
, effortValue_ (INITIAL_EFFORT_VALUE)
13
{
14
individualValue_
=
RandomHelper::GetNext
(0, 32);
15
}
16
17
BaseStat::BaseStat
(
18
const
UInt16
& ev,
19
const
UInt16
& iv)
20
: value_ (INITIAL_STAT_VALUE)
21
, individualValue_ (iv)
22
, effortValue_ (ev)
23
{
24
}
25
26
const
UInt16
&
BaseStat::GetValue
()
const
27
{
28
return
value_
;
29
}
30
31
32
const
UInt16
&
BaseStat::GetIndividualValue
()
const
33
{
34
return
individualValue_
;
35
}
36
37
const
UInt16
&
BaseStat::GetEffortValue
()
const
38
{
39
return
effortValue_
;
40
}
41
42
void
BaseStat::SetValue
(
const
UInt16
& value)
43
{
44
value_
= value;
45
}
46
47
void
BaseStat::SetIndividualValue
(
const
UInt16
& iv)
48
{
49
individualValue_
= iv;
50
}
51
52
void
BaseStat::SetEffortValue
(
const
UInt16
& ev)
53
{
54
effortValue_
= ev;
55
}
56
57
void
BaseStat::ComputeValue
(
const
int
& base,
const
UInt16
level)
58
{
59
UInt16
result =
MathHelper::Floor
((((
individualValue_
+ (2 * base) +
60
MathHelper::Floor
(
effortValue_
/ 4) + 100) * level) / 100)) + 10;
61
62
SetValue
(result);
63
}
64
65
void
BaseStat::AddValue
(
int
value)
66
{
67
value_
+= value;
68
}
69
70
void
BaseStat::ComputeValue
(
71
const
int
& base,
72
const
UInt16
level,
73
const
float
& natureFactor)
74
{
75
UInt16
result =
MathHelper::Floor
(((
individualValue_
+ (2 * base) +
76
MathHelper::Floor
(
effortValue_
/ 4)) * level) / 100) + 5;
77
78
result =
MathHelper::Floor
(result * natureFactor);
79
80
SetValue
(result);
81
}
82
83
}
// namespace yap
YAPOG
src
YAPOG
Game
Pokemon
BaseStat.cpp
Generated on Mon Sep 17 2012 22:24:24 for YAPOG by
1.8.1.1