You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.6 KiB
40 lines
1.6 KiB
3 years ago
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* FragTrap.cpp :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2022/06/23 15:19:54 by narnaud #+# #+# */
|
||
|
/* Updated: 2022/06/23 18:04:05 by narnaud ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "FragTrap.hpp"
|
||
|
|
||
|
FragTrap::FragTrap (std::string name, size_t hp, size_t ep, size_t atk):ClapTrap(name, hp, ep, atk){
|
||
|
if (FragTrap::amount >= 128)
|
||
|
{
|
||
|
delete FragTrap::registery[amount % 128];
|
||
|
cout << "There are already too many Traps" << endl;
|
||
|
}
|
||
|
cout << "FragTrap " << name << " was created" << endl;
|
||
|
FragTrap::registery[FragTrap::amount % 128] = this;
|
||
|
FragTrap::amount++;
|
||
|
}
|
||
|
|
||
|
FragTrap::~FragTrap (void) {
|
||
|
cout << "FragTrap " << _name << " was destroyed" << endl;
|
||
|
}
|
||
|
|
||
|
void FragTrap::attack(const std::string& target) {
|
||
|
if (_energy == 0 || _health == 0)
|
||
|
cout << _name << " is no more able to attack anyone";
|
||
|
else
|
||
|
{
|
||
|
cout << _name << " hardly attacked " << target << endl;
|
||
|
getClapTrap(target)->takeDamage(_attack);
|
||
|
_energy--;
|
||
|
}
|
||
|
}
|