-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScavTrap.cpp
73 lines (62 loc) · 2.57 KB
/
ScavTrap.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ScavTrap.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wcorrea- <wcorrea-@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/17 16:43:19 by wcorrea- #+# #+# */
/* Updated: 2023/07/24 23:53:03 by wcorrea- ### ########.fr */
/* */
/* ************************************************************************** */
#include "ScavTrap.hpp"
// --------------------------- CONSTURCTORS ----------------------------------
ScavTrap::ScavTrap(void)
{
std::cout << "ScavTrap default constructor called" << std::endl;
this->_hitPoints = this->initHit;
this->_energyPoints = this->initEnergy;
this->_attackDamage = this->initDamage;
}
ScavTrap::ScavTrap(std::string const &name) : ClapTrap(name)
{
std::cout << "ScavTrap constructor with parameter called" << std::endl;
this->_hitPoints = this->initHit;
this->_energyPoints = this->initEnergy;
this->_attackDamage = this->initDamage;
}
ScavTrap::ScavTrap(ScavTrap const ©) : ClapTrap(copy)
{
std::cout << "ScavTrap copy constructor called" << std::endl;
}
ScavTrap::~ScavTrap(void)
{
std::cout << "ScavTrap destructor called" << std::endl;
}
// --------------------------- OPERATORS ----------------------------------
ScavTrap &ScavTrap::operator = (ScavTrap const ©)
{
if (this == ©)
return (*this);
this->_name = copy.getName();
this->_hitPoints = copy.getHitPoints();
this->_energyPoints = copy.getEnergyPoints();
this->_attackDamage = copy.getAttackDamage();
return (*this);
}
// --------------------------- MEMBER FUNCTIONS ----------------------------------
void ScavTrap::attack(std::string const &target)
{
if (!this->getHitPoints() || !this->getEnergyPoints())
{
std::cout << "ScavTrap " << this->_name << " is out of action!" << std::endl;
return ;
}
std::cout << "ScavTrap " << this->_name << " bombs " << target;
std::cout << ", causing " << this->_attackDamage << " points of damage!" << std::endl;
this->_energyPoints--;
}
void ScavTrap::guardGate(void)
{
std::cout << "ScavTrap " << this->_name << " has enterred in Gate keeper mode" << std::endl;
}