/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ScavTrap.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/07/13 08:03:51 by apommier #+# #+# */ /* Updated: 2022/08/03 18:08:53 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ #include "ScavTrap.hpp" ScavTrap::ScavTrap() { std::cout << "ScavTrap Default constructor called" << std::endl; this->_hitPoints = 100; this->_energyPoints = 50; this->_attackDamage = 20; } ScavTrap::ScavTrap(std::string name) { std::cout << "ScavTrap Name constructor called" << std::endl; this->_name = name; this->_hitPoints = 100; this->_energyPoints = 50; this->_attackDamage = 20; } ScavTrap::ScavTrap(const ScavTrap& copy) { std::cout << "ScavTrap Copy constructor called" << std::endl; this->_name = copy.getName(); this->_hitPoints = copy.getHitPoints(); this->_energyPoints = copy.getEnergyPoints(); this->_attackDamage = copy.getAttackDamage(); } ScavTrap::~ScavTrap() { std::cout << "ScavTrap " << this->_name << " Destructor called" << std::endl; } void ScavTrap::attack(const std::string& target) { if (this->_hitPoints <= 0) std::cout << "ScavTrap " << this->_name << " could not attack because he died" << std::endl; else if (this->_energyPoints <= 0) std::cout << "ScavTrap " << this->_name << " could not attack because he don't have energy" << std::endl; else { std::cout << "ScavTrap " << this->_name << " attacks " << target << ", causing " << this->_attackDamage << " points of damage!" << std::endl; this->_energyPoints--; } } ScavTrap &ScavTrap::operator=(const ScavTrap& rhs) { std::cout << "ScavTrap " << this->_name << " Assignation operator called" << std::endl; this->_name = rhs.getName(); this->_hitPoints = rhs.getHitPoints(); this->_energyPoints = rhs.getEnergyPoints(); this->_attackDamage = rhs.getAttackDamage(); return *this; } void ScavTrap::guardGate() { if (this->_hitPoints <= 0) std::cout << "ScavTrap " << this->_name << " could not guard because he died" << std::endl; else std::cout << "ScavTrap " << this->_name << " came into Gatekeeper mode\n"; }