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
109
110
111
112
113
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* FragTrap.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/22 05:20:45 by cacharle #+# #+# */
/* Updated: 2020/11/12 10:43:53 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "FragTrap.hpp"
FragTrap::FragTrap(std::string const& name):
m_hitPoints(100),
m_maxHitPoints(100),
m_energyPoints(100),
m_maxEnergyPoints(100),
m_level(1),
m_name(name),
m_meleeAttackDamage(30),
m_rangedAttackDamage(20),
m_armorDamageReduction(5)
{
std::cout << "FR4G-TP New " << m_name << ": your gaming references suck" << std::endl;
}
FragTrap::FragTrap(FragTrap const& other)
{
std::cout << "FR4G-TP New from " << other.m_name << std::endl;
*this = other;
}
FragTrap& FragTrap::operator=(FragTrap const& other)
{
m_hitPoints = other.m_hitPoints;
m_maxHitPoints = other.m_maxHitPoints;
m_energyPoints = other.m_energyPoints;
m_maxEnergyPoints = other.m_maxEnergyPoints;
m_level = other.m_level;
m_meleeAttackDamage = other.m_meleeAttackDamage;
m_rangedAttackDamage = other.m_rangedAttackDamage;
m_armorDamageReduction = other.m_armorDamageReduction;
return *this;
}
FragTrap::~FragTrap()
{
std::cout << "FR4G-TP Delete " << m_name << ": your gaming references still suck" << std::endl;
}
void FragTrap::rangedAttack(std::string const& target) const
{
std::cout << "FR4G-TP " << m_name
<< " attacks " << target
<< " at range, causing " << m_rangedAttackDamage
<< " points of damage!" << std::endl;
}
void FragTrap::meleeAttack(std::string const& target) const
{
std::cout << "FR4G-TP " << m_name
<< " attacks " << target
<< " in melee mode causing " << m_meleeAttackDamage
<< " points of damage!" << std::endl;
}
void FragTrap::takeDamage(unsigned int amount)
{
if (amount < m_armorDamageReduction)
amount = 0;
else
amount -= m_armorDamageReduction;
if (amount > m_hitPoints)
amount = m_hitPoints;
m_hitPoints -= amount;
std::cout << "FR4G-TP " << m_name
<< " takes " << amount
<< " damage" << std::endl;
}
void FragTrap::beRepaired(unsigned int amount)
{
if (amount + m_hitPoints > m_maxHitPoints)
amount = m_maxHitPoints - m_hitPoints;
m_hitPoints += amount;
std::cout << "FR4G-TP " << m_name
<< " gained " << amount
<< " hit points" << std::endl;
}
void FragTrap::vaulthunter_dot_exe(std::string const& target)
{
if (m_energyPoints < 25)
{
std::cout << "FR4G-TP " << m_name << " does not have enough energy" << std::endl;
return;
}
std::string attacks[5] = {
"boum boum",
"cursed for generations",
"sit and wait for your death",
"mimic a gun with his hand and make 'piou piou' sound",
"shot you in the face"
};
std::cout << "FR4G-TP " << m_name
<< " attacks " << target
<< " with " << attacks[rand() % 5] << std::endl;
m_energyPoints -= 25;
}
FragTrap::FragTrap() {}
|