Min fixes
This commit is contained in:
@@ -65,14 +65,14 @@ void ClapTrap::attack(const std::string &target)
|
|||||||
this->energy -= 1;
|
this->energy -= 1;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "ClapTrap " << this->name
|
std::cout << "ClapTrap " << this->name
|
||||||
<< " cant attack anymore..." << std::endl;
|
<< " can't attack anymore..." << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClapTrap::takeDamage(unsigned int amount)
|
void ClapTrap::takeDamage(unsigned int amount)
|
||||||
{
|
{
|
||||||
std::cout << "ClapTrap " << this->name
|
std::cout << "ClapTrap " << this->name
|
||||||
<< " recieves " << amount
|
<< " receives " << amount
|
||||||
<< " points of damage!" << std::endl;
|
<< " points of damage!" << std::endl;
|
||||||
if (amount >= this->health)
|
if (amount >= this->health)
|
||||||
this->health = 0;
|
this->health = 0;
|
||||||
@@ -82,16 +82,20 @@ void ClapTrap::takeDamage(unsigned int amount)
|
|||||||
|
|
||||||
void ClapTrap::beRepaired(unsigned int amount)
|
void ClapTrap::beRepaired(unsigned int amount)
|
||||||
{
|
{
|
||||||
if (this->energy > 0)
|
if (this->health == 0)
|
||||||
{
|
{
|
||||||
std::cout << "ClapTrap " << this->name
|
std::cout << "ClapTrap " << this->name << " can't repair itself because it's destroyed" << std::endl;
|
||||||
<< " repairs itself, recovering " << amount
|
return ;
|
||||||
<< " hit points!" << std::endl;
|
|
||||||
|
|
||||||
this->health += amount;
|
|
||||||
this->energy -= 1;
|
|
||||||
} else {
|
|
||||||
std::cout << "ClapTrap " << this->name
|
|
||||||
<< " cant be repaired..." << std::endl;
|
|
||||||
}
|
}
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ClapTrap.cpp :+: :+: :+: */
|
/* ClapTrap.hpp :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
NAME = claptrap
|
NAME = claptrap
|
||||||
|
|
||||||
SRCS = main.cpp ClapTrap/ClapTrap.cpp
|
SRCS = main.cpp ClapTrap/ClapTrap.cpp
|
||||||
OBJS=$(SRCS:.cpp=.o)
|
OBJS = $(SRCS:.cpp=.o)
|
||||||
|
|
||||||
CC=c++
|
CC = c++
|
||||||
CFLAGS=-Wall -Wextra -Werror -std=c++98
|
CFLAGS = -Wall -Wextra -Werror -std=c++98
|
||||||
|
|
||||||
all: $(NAME)
|
all: $(NAME)
|
||||||
|
|
||||||
|
|||||||
@@ -65,14 +65,14 @@ void ClapTrap::attack(const std::string &target)
|
|||||||
this->energy -= 1;
|
this->energy -= 1;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "ClapTrap " << this->name
|
std::cout << "ClapTrap " << this->name
|
||||||
<< " cant attack anymore..." << std::endl;
|
<< " can't attack anymore..." << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClapTrap::takeDamage(unsigned int amount)
|
void ClapTrap::takeDamage(unsigned int amount)
|
||||||
{
|
{
|
||||||
std::cout << "ClapTrap " << this->name
|
std::cout << "ClapTrap " << this->name
|
||||||
<< " recieves " << amount
|
<< " receives " << amount
|
||||||
<< " points of damage!" << std::endl;
|
<< " points of damage!" << std::endl;
|
||||||
if (amount >= this->health)
|
if (amount >= this->health)
|
||||||
this->health = 0;
|
this->health = 0;
|
||||||
@@ -82,16 +82,20 @@ void ClapTrap::takeDamage(unsigned int amount)
|
|||||||
|
|
||||||
void ClapTrap::beRepaired(unsigned int amount)
|
void ClapTrap::beRepaired(unsigned int amount)
|
||||||
{
|
{
|
||||||
if (this->energy > 0)
|
if (this->health == 0)
|
||||||
{
|
{
|
||||||
std::cout << "ClapTrap " << this->name
|
std::cout << "ClapTrap " << this->name << " can't repair itself because it's destroyed" << std::endl;
|
||||||
<< " repairs itself, recovering " << amount
|
return ;
|
||||||
<< " hit points!" << std::endl;
|
|
||||||
|
|
||||||
this->health += amount;
|
|
||||||
this->energy -= 1;
|
|
||||||
} else {
|
|
||||||
std::cout << "ClapTrap " << this->name
|
|
||||||
<< " cant be repaired..." << std::endl;
|
|
||||||
}
|
}
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
NAME = scavtrap
|
NAME = scavtrap
|
||||||
|
|
||||||
SRCS = main.cpp ClapTrap/ClapTrap.cpp ScavTrap/ScavTrap.cpp
|
SRCS = main.cpp ClapTrap/ClapTrap.cpp ScavTrap/ScavTrap.cpp
|
||||||
OBJS=$(SRCS:.cpp=.o)
|
OBJS = $(SRCS:.cpp=.o)
|
||||||
|
|
||||||
CC=c++
|
CC = c++
|
||||||
CFLAGS=-Wall -Wextra -Werror -std=c++98
|
CFLAGS = -Wall -Wextra -Werror -std=c++98
|
||||||
|
|
||||||
all: $(NAME)
|
all: $(NAME)
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include "ScavTrap.hpp"
|
#include "ScavTrap.hpp"
|
||||||
|
|
||||||
ScavTrap::ScavTrap() : ClapTrap("(NULL)")
|
ScavTrap::ScavTrap() : ClapTrap("(NULL)"), guarding_gate(false)
|
||||||
{
|
{
|
||||||
this->health = 100;
|
this->health = 100;
|
||||||
this->energy = 50;
|
this->energy = 50;
|
||||||
@@ -21,7 +21,7 @@ ScavTrap::ScavTrap() : ClapTrap("(NULL)")
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScavTrap::ScavTrap(std::string name) : ClapTrap(name)
|
ScavTrap::ScavTrap(std::string name) : ClapTrap(name), guarding_gate(false)
|
||||||
{
|
{
|
||||||
this->health = 100;
|
this->health = 100;
|
||||||
this->energy = 50;
|
this->energy = 50;
|
||||||
@@ -62,22 +62,21 @@ void ScavTrap::attack(const std::string &target)
|
|||||||
this->energy -= 1;
|
this->energy -= 1;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "ScavTrap " << this->name
|
std::cout << "ScavTrap " << this->name
|
||||||
<< " cant attack anymore..." << std::endl;
|
<< " can't attack anymore..." << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScavTrap::guardGate()
|
void ScavTrap::guardGate()
|
||||||
{
|
{
|
||||||
if (this->guardGate)
|
if (!this->guarding_gate)
|
||||||
{
|
{
|
||||||
this->guardGate = false;
|
this->guarding_gate = true;
|
||||||
std::cout << "ScavTrap " << this->name << " is not in Gate keeper mode"
|
std::cout << "ScavTrap " << this->name << " is in Gate keeper mode"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->guardGate = true;
|
std::cout << "ScavTrap " << this->name << " is already in Gate keeper mode"
|
||||||
std::cout << "ScavTrap " << this->name << " is in Gate keeper mode"
|
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
class ScavTrap : public ClapTrap
|
class ScavTrap : public ClapTrap
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
boold guarding_gate;
|
bool guarding_gate;
|
||||||
public:
|
public:
|
||||||
ScavTrap();
|
ScavTrap();
|
||||||
ScavTrap(std::string name);
|
ScavTrap(std::string name);
|
||||||
|
|||||||
@@ -65,14 +65,14 @@ void ClapTrap::attack(const std::string &target)
|
|||||||
this->energy -= 1;
|
this->energy -= 1;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "ClapTrap " << this->name
|
std::cout << "ClapTrap " << this->name
|
||||||
<< " cant attack anymore..." << std::endl;
|
<< " can't attack anymore..." << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClapTrap::takeDamage(unsigned int amount)
|
void ClapTrap::takeDamage(unsigned int amount)
|
||||||
{
|
{
|
||||||
std::cout << "ClapTrap " << this->name
|
std::cout << "ClapTrap " << this->name
|
||||||
<< " recieves " << amount
|
<< " receives " << amount
|
||||||
<< " points of damage!" << std::endl;
|
<< " points of damage!" << std::endl;
|
||||||
if (amount >= this->health)
|
if (amount >= this->health)
|
||||||
this->health = 0;
|
this->health = 0;
|
||||||
@@ -82,16 +82,20 @@ void ClapTrap::takeDamage(unsigned int amount)
|
|||||||
|
|
||||||
void ClapTrap::beRepaired(unsigned int amount)
|
void ClapTrap::beRepaired(unsigned int amount)
|
||||||
{
|
{
|
||||||
if (this->energy > 0)
|
if (this->health == 0)
|
||||||
{
|
{
|
||||||
std::cout << "ClapTrap " << this->name
|
std::cout << "ClapTrap " << this->name << " can't repair itself because it's destroyed" << std::endl;
|
||||||
<< " repairs itself, recovering " << amount
|
return ;
|
||||||
<< " hit points!" << std::endl;
|
|
||||||
|
|
||||||
this->health += amount;
|
|
||||||
this->energy -= 1;
|
|
||||||
} else {
|
|
||||||
std::cout << "ClapTrap " << this->name
|
|
||||||
<< " cant be repaired..." << std::endl;
|
|
||||||
}
|
}
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
# define FRAGTRAP_HPP
|
# define FRAGTRAP_HPP
|
||||||
|
|
||||||
# include <iostream>
|
# include <iostream>
|
||||||
# include "../ClapTrap/ClapTrab.hpp"
|
# include "../ClapTrap/ClapTrap.hpp"
|
||||||
|
|
||||||
class FragTrap : public ClapTrap
|
class FragTrap : public ClapTrap
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -68,16 +68,15 @@ void ScavTrap::attack(const std::string &target)
|
|||||||
|
|
||||||
void ScavTrap::guardGate()
|
void ScavTrap::guardGate()
|
||||||
{
|
{
|
||||||
if (this->guardGate)
|
if (!this->guarding_gate)
|
||||||
{
|
{
|
||||||
this->guardGate = false;
|
this->guarding_gate = true;
|
||||||
std::cout << "ScavTrap " << this->name << " is not in Gate keeper mode"
|
std::cout << "ScavTrap " << this->name << " is in Gate keeper mode"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->guardGate = true;
|
std::cout << "ScavTrap " << this->name << " is already in Gate keeper mode"
|
||||||
std::cout << "ScavTrap " << this->name << " is in Gate keeper mode"
|
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
class ScavTrap : public ClapTrap
|
class ScavTrap : public ClapTrap
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
boold guarding_gate;
|
bool guarding_gate;
|
||||||
public:
|
public:
|
||||||
ScavTrap();
|
ScavTrap();
|
||||||
ScavTrap(std::string name);
|
ScavTrap(std::string name);
|
||||||
|
|||||||
Reference in New Issue
Block a user