aboutsummaryrefslogtreecommitdiff
path: root/cpp03/ex02/ScavTrap.cpp
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-11-12 10:54:47 +0100
committerCharles Cabergs <me@cacharle.xyz>2020-11-12 10:54:47 +0100
commit96dcf214a8c40529b251ea31ef037868583dd1da (patch)
treeecbb74fd1982829b550f5b5f5451497245db1358 /cpp03/ex02/ScavTrap.cpp
parent2e0cf63a219d24ef07412deca9b0e6cb02882b46 (diff)
downloadpiscine_cpp-96dcf214a8c40529b251ea31ef037868583dd1da.tar.gz
piscine_cpp-96dcf214a8c40529b251ea31ef037868583dd1da.tar.bz2
piscine_cpp-96dcf214a8c40529b251ea31ef037868583dd1da.zip
Fixing cpp03, moved more common logic in ClapTrap, Added better main
Diffstat (limited to 'cpp03/ex02/ScavTrap.cpp')
-rw-r--r--cpp03/ex02/ScavTrap.cpp35
1 files changed, 12 insertions, 23 deletions
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 <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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() {}