YAPOG
0.0.1
Yet Another Pokemon Online Game
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
BattleCore.cpp
Go to the documentation of this file.
1
#include "
YAPOG/Game/Battle/BattleCore.hpp
"
2
#include "
YAPOG/System/RandomHelper.hpp
"
3
4
namespace
yap
5
{
6
BattleCore::BattleCore
()
7
{
8
}
9
10
int
BattleCore::ComputeDamage
(
11
const
PokemonMove
& move,
12
const
PokemonFighter
& attacker,
13
const
PokemonFighter
& defender)
14
{
15
float
stab = 1.f;
16
17
if
(move.
GetType
() == attacker.
GetType1
()
18
|| move.
GetType
() == attacker.
GetType1
())
19
stab = 1.5f;
20
21
float
type = defender.
GetTypeEffectFactor
(move.
GetType
());
22
float
critical = 1.f;
23
24
if
(
RandomHelper::Percentage
(6.25f))
25
critical = 2.f;
26
27
float
other = 1.f;
28
float
rand =
RandomHelper::GetNext
(0.85f, 1.0f);
29
float
modifier = stab * type * critical * other * rand;
30
float
levelFactor = (2 * attacker.
GetLevel
() + 10) / 250.f;
31
float
atkOverDef = 1.f;
32
33
if
(move.
GetCategory
() == 1)
34
{
35
if
(defender.
GetDefense
().
GetValue
() != 0)
36
{
37
atkOverDef =
38
attacker.
GetAttack
().
GetValue
() /
39
defender.
GetDefense
().
GetValue
();
40
}
41
}
42
else
43
{
44
if
(defender.
GetSpecialDefense
().
GetValue
() != 0)
45
{
46
atkOverDef =
47
attacker.
GetSpecialAttack
().
GetValue
() /
48
defender.
GetSpecialDefense
().
GetValue
();
49
}
50
}
51
52
float
base = move.
GetPower
();
53
54
float
damage = levelFactor * atkOverDef * base + 2;
55
damage *= modifier;
56
57
return
damage;
58
}
59
}
// namespace yap
YAPOG
src
YAPOG
Game
Battle
BattleCore.cpp
Generated on Mon Sep 17 2012 22:24:24 for YAPOG by
1.8.1.1