From 96dcf214a8c40529b251ea31ef037868583dd1da Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Thu, 12 Nov 2020 10:54:47 +0100 Subject: Fixing cpp03, moved more common logic in ClapTrap, Added better main --- cpp03/ex02/ScavTrap.cpp | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) (limited to 'cpp03/ex02/ScavTrap.cpp') diff --git a/cpp03/ex02/ScavTrap.cpp b/cpp03/ex02/ScavTrap.cpp index 1acf126..40da89a 100644 --- a/cpp03/ex02/ScavTrap.cpp +++ b/cpp03/ex02/ScavTrap.cpp @@ -6,47 +6,33 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/13 14:15:03 by charles #+# #+# */ -/* Updated: 2020/11/11 06:42:58 by cacharle ### ########.fr */ +/* Updated: 2020/11/12 10:07:26 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include "ScavTrap.hpp" -ScavTrap::ScavTrap() : ClapTrap() -{ - m_energyPoints = 50; - m_maxEnergyPoints = 50; - m_meleeAttackDamage = 20; - m_rangedAttackDamage = 15; - m_armorDamageReduction = 3; - std::cout << "SC4V-TP New " << m_name << ": your gaming references suck" << std::endl; -} - ScavTrap::ScavTrap(std::string const& name) : ClapTrap(name) { + m_hitPoints = 100; + m_maxHitPoints = 100; m_energyPoints = 50; m_maxEnergyPoints = 50; + m_level = 1; m_meleeAttackDamage = 20; m_rangedAttackDamage = 15; m_armorDamageReduction = 3; std::cout << "SC4V-TP New " << m_name << ": your gaming references suck" << std::endl; } -ScavTrap::ScavTrap(ScavTrap const& other) +ScavTrap::ScavTrap(ScavTrap const& other) : ClapTrap(other) { - *this = other; + std::cout << "SC4V-TP New from "<< other.m_name << std::endl; } ScavTrap& ScavTrap::operator=(ScavTrap const& other) { - m_hitPoints = other.m_hitPoints; - m_maxHitPoints = other.m_maxHitPoints; - m_energyPoints = other.m_energyPoints; - m_maxEnergyPoints = other.m_maxEnergyPoints; - m_level = other.m_level; - m_meleeAttackDamage = other.m_meleeAttackDamage; - m_rangedAttackDamage = other.m_rangedAttackDamage; - m_armorDamageReduction = other.m_armorDamageReduction; + ClapTrap::operator=(other); return *this; } @@ -64,7 +50,10 @@ void ScavTrap::challengeNewcomer(std::string const& target) "draw your name by peeing in the snow", "punch me" }; - std::cout << "SC4V-TP " << m_name + std::cout << "SC4V-TP " << m_name << " challenge " << target - << " to " << challenges[rand() % 5] << std::endl; + << " to " << challenges[rand() % 5] + << std::endl; } + +ScavTrap::ScavTrap() {} -- cgit