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.
41 lines
1.6 KiB
41 lines
1.6 KiB
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* DiamondTrap.cpp :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/06/23 15:19:54 by narnaud #+# #+# */
|
|
/* Updated: 2022/07/19 02:45:31 by narnaud ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "DiamondTrap.hpp"
|
|
|
|
DiamondTrap::DiamondTrap (std::string name): ScavTrap(name), FragTrap(name){
|
|
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;
|
|
}
|
|
|