#include "ClapTrap.hpp" /* * default/parametric constructor */ ClapTrap::ClapTrap( void ) { return; } /* * destructor */ ClapTrap::~ClapTrap( void ) { return; } /* * copy constructor */ ClapTrap::ClapTrap( ClapTrap const & src ) { *this = src; return; } /* * assignement operator */ ClapTrap & ClapTrap::operator=( ClapTrap const & rhs ) { if ( this != &rhs ) { this->_hit = rhs.getHit(); this->_energy = rhs.getEnergy(); this->_attack = rhs.getAttack(); } return *this; } /* * constructor */ ClapTrap::ClapTrap( std::string name ) : _name(name) { _hit = 10; _energy = 10; _attack = 1; return; } /* * getters */ std::string ClapTrap::getName() const {return _name;} int ClapTrap::getHit() const {return _hit;} int ClapTrap::getEnergy() const {return _energy;} int ClapTrap::getAttack() const {return _attack;} /* * robots */ void ClapTrap::attack(const std::string & target) { std::cout << B_CYAN "[" B_PURPLE "h,e,a" B_CYAN ":" B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "->"; _energy--; std::cout << B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "]" RESET << " ClapTrap " << _name << " attacked " << target << ", causing " B_YELLOW << _attack << RESET << " points of damage!" << '\n'; } void ClapTrap::takeDamage(unsigned int amount) { std::cout << B_CYAN "[" B_PURPLE "h,e,a" B_CYAN ":" B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "->"; _hit -= amount; std::cout << B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "]" RESET << " ClapTrap " << _name << " looses " B_YELLOW << amount << RESET << " points of damage :/" << '\n'; } void ClapTrap::beRepaired(unsigned int amount) { std::cout << B_CYAN "[" B_PURPLE "h,e,a" B_CYAN ":" B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "->"; _energy--; _hit += amount; std::cout << B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "]" RESET << " ClapTrap " << _name << " repaired itself and gained " B_YELLOW << amount << RESET << " points of life :)" << '\n'; }