d03 ex01 refonte complete ok

This commit is contained in:
Hugo LAMY
2022-02-22 18:49:15 +01:00
parent bb6c0515b1
commit 088a54d036
9 changed files with 87 additions and 125 deletions

View File

@@ -1,5 +1,16 @@
#include "ClapTrap.hpp"
# define B_GRAY "\e[1;30m"
# define B_RED "\e[1;31m"
# define B_GREEN "\e[1;32m"
# define B_YELLOW "\e[1;33m"
# define B_BLUE "\e[1;34m"
# define B_PURPLE "\e[1;35m"
# define B_CYAN "\e[1;36m"
# define B_WHITE "\e[1;37m"
# define RESET "\e[0m"
/*********************************************
* CONSTRUCTORS
*********************************************/
@@ -12,7 +23,7 @@ ClapTrap::ClapTrap( std::string name ) {
_energy = _dEnergy;
_attack = _dAttack;
_number = getTotalNumber();
std::cout << _class << " " << _name << " nb:" << _number << " created\n";
std::cout << _class << " " << _name << "-" << _number << " created\n";
return;
}
@@ -21,7 +32,7 @@ ClapTrap::ClapTrap( ClapTrap const & src ) {
_class = _dClass;
*this = src;
_number = getTotalNumber();
std::cout << _class << " " << _name << "-" << _number << " copied from " << src._class << "-" << src._name << "-" << src._number << "\n";
std::cout << _class << " " << _name << "-" << _number << " copied from " << src._class << " " << src._name << "-" << src._number << "\n";
return;
}
@@ -77,7 +88,7 @@ void ClapTrap::attack(const std::string & target) {
std::ostringstream state;
state << B_CYAN "[" B_GREEN << _class[0] << _number << B_PURPLE "h,e,a" B_CYAN ":" B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "->";
action << _class << " " << _name;
action << _class << " " << _name << "-" << _number;
if (_energy > 0 && _hit > 0)
{
@@ -105,7 +116,7 @@ void ClapTrap::takeDamage(unsigned int amount) {
std::ostringstream state;
state << B_CYAN "[" B_GREEN << _class[0] << _number << B_PURPLE "h,e,a" B_CYAN ":" B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "->";
action << _class << " " << _name;
action << _class << " " << _name << "-" << _number;
if (_hit > 0)
{
@@ -127,7 +138,7 @@ void ClapTrap::beRepaired(unsigned int amount) {
std::ostringstream state;
state << B_CYAN "[" B_GREEN << _class[0] << _number << B_PURPLE "h,e,a" B_CYAN ":" B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "->";
action << _class << " " << _name;
action << _class << " " << _name << "-" << _number;
if (_energy > 0 && _hit > 0)
{