/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ScavTrap.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/23 15:19:54 by narnaud #+# #+# */ /* Updated: 2022/06/23 17:55:34 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #include "ScavTrap.hpp" ScavTrap::ScavTrap (std::string name, size_t hp, size_t ep, size_t atk):ClapTrap(name, hp, ep, atk){ if (ScavTrap::amount >= 128) { delete ScavTrap::registery[amount % 128]; cout << "There are already too many Traps" << endl; } cout << "ScavTrap " << name << " was created" << endl; ScavTrap::registery[ScavTrap::amount % 128] = this; ScavTrap::amount++; } ScavTrap::~ScavTrap (void) { cout << "ScavTrap " << _name << " was destroyed" << endl; } void ScavTrap::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 ScavTrap::guardGate(void) { if (_health == 0) cout << _name << " is no more able to guard" << endl; else cout << _name << " is now in guard gate mode.\n"; }