/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ClapTrap.hpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: aortigos name = target.name; this->health = target.health; this->energy = target.energy; this->attackDamage = target.attackDamage; } ClapTrap& ClapTrap::operator=(const ClapTrap &target) { if (this != &target) { this->name = target.name; this->health = target.health; this->energy = target.energy; this->attackDamage = target.attackDamage; } return (*this); } ClapTrap::~ClapTrap() { std::cout << "Destructor called" << std::endl; } void ClapTrap::attack(const std::string &target) { if (this->health > 0 && this->energy > 0) { std::cout << "ClapTrap " << this->name << " attacks " << target << ", causing " << this->attackDamage << " points of damage!" << std::endl; this->energy -= 1; } else { std::cout << "ClapTrap " << this->name << " cant attack anymore..." << std::endl; } } void ClapTrap::takeDamage(unsigned int amount) { std::cout << "ClapTrap " << this->name << " recieves " << amount << " points of damage!" << std::endl; this->health -= amount; } void ClapTrap::beRepaired(unsigned int amount) { if (this->energy > 0) { this->health += amount; this->energy -= 1; } else { std::cout << "ClapTrap " << this->name << " cant be repaired..." << std::endl; } }