style: adding the boradcast and the moulinette character
This commit is contained in:
parent
016ddd0846
commit
51f2946231
2 changed files with 12 additions and 7 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/01/10 13:59:49 by rparodi #+# #+# */
|
||||
/* Updated: 2025/01/13 14:58:53 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/01/14 21:59:42 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -27,12 +27,12 @@ ClapTrap::~ClapTrap() {
|
|||
}
|
||||
|
||||
void ClapTrap::attack(const std::string& target) {
|
||||
if (_energy_point <= 0 && _hit_point <= 0) {
|
||||
std::cerr << "Not enough energy to attack" << std::endl;
|
||||
if (_energy_point <= 0 || _hit_point <= 0) {
|
||||
std::cerr << "\n[Attack] ClapTrap:\n\t" << "Not enough energy to attack" << std::endl;
|
||||
return ;
|
||||
}
|
||||
_energy_point--;
|
||||
std::cout << "[Attack] ClapTrap:\n\t" << _name << " attacks " << target << ", causing " << _attack_damage << " points of damage!" << std::endl;
|
||||
std::cout << "\n[Attack] ClapTrap:\n\t" << _name << " attacks " << target << ", causing " << _attack_damage << " points of damage!" << std::endl;
|
||||
}
|
||||
|
||||
void ClapTrap::takeDamage(unsigned int amount) {
|
||||
|
|
@ -41,8 +41,8 @@ void ClapTrap::takeDamage(unsigned int amount) {
|
|||
}
|
||||
|
||||
void ClapTrap::beRepaired(unsigned int amount) {
|
||||
if (_energy_point <= 0 && _hit_point <= 0) {
|
||||
std::cerr << "Not enough energy to repair" << std::endl;
|
||||
if (_energy_point <= 0 || _hit_point <= 0) {
|
||||
std::cerr << "\n[Repair] ClapTrap:\n\t" << "Not enough energy to repair" << std::endl;
|
||||
return ;
|
||||
}
|
||||
_energy_point--;
|
||||
|
|
|
|||
|
|
@ -6,16 +6,21 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/01/10 15:50:07 by rparodi #+# #+# */
|
||||
/* Updated: 2025/01/10 15:57:10 by rparodi ### ########.fr */
|
||||
/* Updated: 2025/01/14 22:04:48 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ClapTrap.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int main(void) {
|
||||
std::cout << "[Broadcast]\n\tIn the Red corner the first cat of the 42 school !" << std::endl;
|
||||
ClapTrap test("Norminet");
|
||||
test.attack("Moulinette");
|
||||
test.takeDamage(42);
|
||||
test.beRepaired(42);
|
||||
std::cout << "\n\n[Broadcast]\n\tIn the Blue corner the actual cat of the 42 school !" << std::endl;
|
||||
ClapTrap test2("Moulinette");
|
||||
test2.beRepaired(32);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue