Min fixes

This commit is contained in:
Angel Ortigosa Perez
2025-10-26 20:20:14 +01:00
parent e4c2000a4a
commit 46b7b99abb
11 changed files with 69 additions and 59 deletions

View File

@@ -65,14 +65,14 @@ void ClapTrap::attack(const std::string &target)
this->energy -= 1;
} else {
std::cout << "ClapTrap " << this->name
<< " cant attack anymore..." << std::endl;
<< " can't attack anymore..." << std::endl;
}
}
void ClapTrap::takeDamage(unsigned int amount)
{
std::cout << "ClapTrap " << this->name
<< " recieves " << amount
<< " receives " << amount
<< " points of damage!" << std::endl;
if (amount >= this->health)
this->health = 0;
@@ -82,16 +82,20 @@ void ClapTrap::takeDamage(unsigned int amount)
void ClapTrap::beRepaired(unsigned int amount)
{
if (this->energy > 0)
if (this->health == 0)
{
std::cout << "ClapTrap " << this->name
<< " repairs itself, recovering " << amount
<< " hit points!" << std::endl;
this->health += amount;
this->energy -= 1;
} else {
std::cout << "ClapTrap " << this->name
<< " cant be repaired..." << std::endl;
std::cout << "ClapTrap " << this->name << " can't repair itself because it's destroyed" << std::endl;
return ;
}
if (this->energy == 0)
{
std::cout << "ClapTrap " << this->name << " has no energy left to repair!" << std::endl;
return ;
}
std::cout << "ClapTrap " << this->name
<< " repairs itself, recovering " << amount
<< " hit points!" << std::endl;
this->health += amount;
this->energy -= 1;
}

View File

@@ -1,7 +1,7 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ClapTrap.cpp :+: :+: :+: */
/* ClapTrap.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */

View File

@@ -1,10 +1,10 @@
NAME = claptrap
SRCS = main.cpp ClapTrap/ClapTrap.cpp
OBJS=$(SRCS:.cpp=.o)
OBJS = $(SRCS:.cpp=.o)
CC=c++
CFLAGS=-Wall -Wextra -Werror -std=c++98
CC = c++
CFLAGS = -Wall -Wextra -Werror -std=c++98
all: $(NAME)