/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* FragTrap.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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--; } }