-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fighter.cpp
108 lines (103 loc) · 2.49 KB
/
Fighter.cpp
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include "Fighter.h"
#include <iostream>
using namespace std;
Fighter::Fighter(string name_in, int hitPoints_in, int strength_in, int speed_in, int magic_in)
{
name = name_in;
hitPoints = hitPoints_in;
currentHP = hitPoints;
speed = speed_in;
magic = magic_in;
strength = strength_in;
//newStrength = strength;
}
string Fighter::getName() const
{
return name;
}
int Fighter::getMaximumHP() const
{
return hitPoints;
}
int Fighter::getCurrentHP() const
{
return currentHP;
}
int Fighter::getStrength() const
{
; return strength;
}
int Fighter::getSpeed() const
{
return speed;
}
int Fighter::getMagic() const
{
return magic;
}
int Fighter::getDamage() //int damage
{
return 0; //damage
}
void Fighter::takeDamage(int damage)
{
int totalDamage = damage;
// cout << "\nIncoming takeDamage is " << damage;
totalDamage -= speed / 4;
// cout << "\nSpeed = " << speed;
// cout << "\nAdjusted totalDamage is " << totalDamage;
if (totalDamage < 1)
{
totalDamage = 1;
currentHP -= totalDamage;
// cout << "\nFighter class received Final Adjusted damage of " << totalDamage;
}
else
{
currentHP -= totalDamage;
// cout << "\nFighter class received Final damage of " << totalDamage;// << " in, currentHP is " << currentHP << " before attack ";
}
}
void Fighter::reset()
{
// cout << "\nBefore reset in fighter class, currentHP is " << currentHP;
currentHP = hitPoints;
// strength = newStrength;
// cout << "\nAfter reset, currentHP is " << currentHP;
}
void Fighter::regenerate()
{
//cout << "\nstrength is currently " << strength;
// cout << "\ncurrentHP is currently " << currentHP;
int hp_before = currentHP;
if ((strength / 6) < 1)
{
//cout << "\nStrength / 6 is less than 1, prior to addition. currentHP is " << currentHP;
currentHP += 1;
//cout << "\nafter addition, currentHP is now " << currentHP;
}
else
{
//cout << "\nprior to else addition, currentHP is " << currentHP;
currentHP += (strength / 6);
//cout << "\nafter else addition, currentHP is now " << currentHP;
}
// cout << "\ncurrentHP and hitPoints: " << currentHP << ", " << hitPoints;
if (currentHP > hitPoints)
{
// cout << "\nequalized currentHP and hitPoints: " << currentHP << ", " << hitPoints;
currentHP = hitPoints;
}
// cout << "\nCurrentHP became " << currentHP;
if (hp_before > currentHP)
{
// cout << "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
}
}
bool Fighter::useAbility()
{
return true;
}
Fighter::~Fighter()
{
}