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.

43 lines
1.7 KiB

2 years ago
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* DiamondTrap.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/23 15:19:54 by narnaud #+# #+# */
/* Updated: 2022/08/03 10:30:43 by narnaud ### ########.fr */
/* */
/* ************************************************************************** */
#include "DiamondTrap.hpp"
DiamondTrap::DiamondTrap (std::string name): ScavTrap(name), FragTrap(name){
cout << ScavTrap::_energy << endl;
ClapTrap::_name = name + "_clap_name";
_name = name;
_health = FragTrap::_health;
_energy = ScavTrap::_energy;
_attack = FragTrap::_attack;
cout << name << "is now a DiamondTrap" << endl;
}
DiamondTrap::~DiamondTrap (void) {
cout << "DiamondTrap " << _name << " was destroyed" << endl;
}
void DiamondTrap::attack(const std::string& target) {
if (_energy == 0 || _health == 0)
cout << _name << " is no more able to attack" << endl;
else
{
cout << _name << " heavily attacked " << target << endl;
getClapTrap(target)->takeDamage(_attack);
_energy--;
}
}
void DiamondTrap::whoAmI(void) {
cout << "Name: " << _name << " - Clap name: " << ClapTrap::_name << endl;
}