@@ -14,7 +14,7 @@ Pokemon::Pokemon(std::string name, const std::int32_t level, const std::int32_t
14
14
15
15
Move Pokemon::make_move (Pokemon& source, Pokemon& target)
16
16
{
17
- if ((random_range<int >(0 , 100 ) <= source.m_next_move .m_accuracy ) && source.isAlive && target.isAlive )
17
+ if ((random_range<int >(0 , 100 ) <= source.m_next_move .m_accuracy ) && source.m_hp > 0 && target.m_hp > 0 )
18
18
{
19
19
switch (source.m_next_move .m_mt )
20
20
{
@@ -30,27 +30,25 @@ Move Pokemon::make_move(Pokemon& source, Pokemon& target)
30
30
return source.m_next_move ;
31
31
}
32
32
}
33
- Move fail = Move ( " Failed " , MoveTypes::NONE, 100 , 0 );
34
- return fail ;
33
+
34
+ return Move ( " Failed " , MoveTypes::NONE, 100 , 0 ) ;
35
35
}
36
36
37
37
Move Pokemon::attack (Pokemon& source, Pokemon& target)
38
38
{
39
- /* (2 * Level / 5+2) * Attack * Power) / Defense) / 50) + 2) * random number(217-255)) / 255
40
- damage formula https://www.math.miami.edu/~jam/azure/compendium/battdam.htm*/
39
+
41
40
if (target.m_hp > 0 )
42
41
{
43
42
int attack = source.m_attack ;
44
43
if (random_range<int >(random_range<int >(1 , 20 ), 100 ))
45
44
{
46
45
attack *= 2 ; // crit damage
47
46
}
47
+ /* (2 * Level / 5+2) * Attack * Power) / Defense) / 50) + 2) * random number(217-255)) / 255
48
+ damage formula https://www.math.miami.edu/~jam/azure/compendium/battdam.htm*/
48
49
int damage = ((((((2 * source.m_level / 5 + 2 ) * attack * source.m_next_move .m_power ) / target.m_def ) / 50 ) + 2 ) * random_range<int >(217 , 255 )) / 255 ;
49
50
target.m_hp -= damage;
50
- if (target.m_hp <= 0 )
51
- {
52
- target.isAlive = false ;
53
- }
51
+
54
52
return source.m_next_move ;
55
53
}
56
54
return Move (" Failed" , MoveTypes::NONE, 100 , 0 );
0 commit comments