61 lines
1.2 KiB
C++
61 lines
1.2 KiB
C++
#include "ScavTrap.hpp"
|
|
#include "ClapTrap.hpp"
|
|
|
|
#include <iostream>
|
|
#include <string>
|
|
|
|
ScavTrap::ScavTrap()
|
|
{
|
|
this->_name = "";
|
|
this->_life = 100;
|
|
this->_energy = 50;
|
|
this->_damage = 20;
|
|
std::cout << "ScavTrap()" << std::endl;
|
|
}
|
|
|
|
ScavTrap::ScavTrap(const std::string& name)
|
|
{
|
|
this->_name = name;
|
|
this->_life = 100;
|
|
this->_energy = 50;
|
|
this->_damage = 20;
|
|
std::cout << "ScavTrap(" << name << ")" << std::endl;
|
|
}
|
|
|
|
ScavTrap::ScavTrap(const ScavTrap& src): ClapTrap(src)
|
|
{
|
|
*this = src;
|
|
std::cout << "ScavTrap(ScavTrap)" << std::endl;
|
|
}
|
|
|
|
ScavTrap::~ScavTrap()
|
|
{
|
|
std::cout << "~ScavTrap()" << std::endl;
|
|
}
|
|
|
|
ScavTrap& ScavTrap::operator=(const ScavTrap &src)
|
|
{
|
|
this->_life = src._life;
|
|
this->_name = src._name;
|
|
this->_energy = src._energy;
|
|
this->_damage = src._damage;
|
|
|
|
return *this;
|
|
}
|
|
|
|
void ScavTrap::guardGate()
|
|
{
|
|
std::cout << "ScavTrap " << this->_name << " turn in Gate keeper mode" << std::endl;
|
|
}
|
|
|
|
void ScavTrap::attack(const std::string& target)
|
|
{
|
|
if (this->_life == 0 || this->_energy == 0)
|
|
{
|
|
std::cerr << "error: ScavTrap " << this->_name << " dead" << std::endl;
|
|
return;
|
|
}
|
|
this->_energy--;
|
|
std::cerr << "ScavTrap " << this->_name << " attacks " << target << ", causing " << this->_damage << " points of damage" << std::endl;
|
|
}
|