-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBalfur.cpp
More file actions
88 lines (69 loc) · 1.7 KB
/
Balfur.cpp
File metadata and controls
88 lines (69 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include "Balfur.h"
#include <time.h>
#include <stdexcept>
int Balfur::GenerateRandomNumber(int n)
{
if (n <= 0 || n >= RAND_MAX)
throw std::domain_error("Argument of GenerateRandomNumber() must be between 0 32767... ");
const int bucket_size = RAND_MAX / n; // divide the random values on intervals so that the random function be more random
int newRandomNumber;
do newRandomNumber = rand() / n;
while (newRandomNumber > n); // else a number will have a bigger chance to be chosen then other
return newRandomNumber;
}
Balfur::Balfur() :Creature("Balfur")
{
m_Symbol = startingValuesSymbol;
m_Level = startingValuesLevel;
m_Experience = startingValuesExperience;
m_ExperienceGives = startingValuesExperienceGives;
m_PowerRating = startingValuesPowerRating;
m_HP = startingValuesHP;
m_Mana = startingValuesMana;
m_Agility = startingValuesAgility;
m_Attack = startingValuesAttack;
m_Shots = startingValuesShots;
m_Armor = startingValuesArmor;
m_Stealth = startingValuesStealth;
m_MovementOnBattlefield = startingValuesMovementOnBattlefield;
m_IsRange = false;
}
Balfur::~Balfur()
{
}
void Balfur::LevelUp()
{
Dragon::LevelUp();
Demon::LevelUp();
}
void Balfur::Die()
{
Dragon::Die();
}
void Balfur::PassTurn()
{
Dragon::PassTurn();
}
void Balfur::Attack(Creature& enemy)
{
int randomNumber = GenerateRandomNumber(42);
if (randomNumber < 21)
Dragon::Attack(enemy);
else
Demon::Attack(enemy);
}
void Balfur::Defend(Creature & enemy)
{
}
void Balfur::MoveOnBattlefield(const int x, const int y)
{
Dragon::MoveOnBattlefield(x, y);
}
GameObject * Balfur::GetObjectInstance() const
{
return new Balfur(*this);
}
Creature * Balfur::GetCreatureInstance() const
{
return new Balfur(*this);
}