style: adding the boradcast and the moulinette character

This commit is contained in:
Raphael 2025-01-14 22:05:48 +01:00
parent 016ddd0846
commit 51f2946231
2 changed files with 12 additions and 7 deletions

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */ /* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/10 13:59:49 by rparodi #+# #+# */ /* 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) { void ClapTrap::attack(const std::string& target) {
if (_energy_point <= 0 && _hit_point <= 0) { if (_energy_point <= 0 || _hit_point <= 0) {
std::cerr << "Not enough energy to attack" << std::endl; std::cerr << "\n[Attack] ClapTrap:\n\t" << "Not enough energy to attack" << std::endl;
return ; return ;
} }
_energy_point--; _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) { void ClapTrap::takeDamage(unsigned int amount) {
@ -41,8 +41,8 @@ void ClapTrap::takeDamage(unsigned int amount) {
} }
void ClapTrap::beRepaired(unsigned int amount) { void ClapTrap::beRepaired(unsigned int amount) {
if (_energy_point <= 0 && _hit_point <= 0) { if (_energy_point <= 0 || _hit_point <= 0) {
std::cerr << "Not enough energy to repair" << std::endl; std::cerr << "\n[Repair] ClapTrap:\n\t" << "Not enough energy to repair" << std::endl;
return ; return ;
} }
_energy_point--; _energy_point--;

View file

@ -6,16 +6,21 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */ /* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/10 15:50:07 by rparodi #+# #+# */ /* 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 "ClapTrap.hpp"
#include <iostream>
int main(void) { int main(void) {
std::cout << "[Broadcast]\n\tIn the Red corner the first cat of the 42 school !" << std::endl;
ClapTrap test("Norminet"); ClapTrap test("Norminet");
test.attack("Moulinette"); test.attack("Moulinette");
test.takeDamage(42); test.takeDamage(42);
test.beRepaired(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); return (0);
} }