73 lines
1.9 KiB
C++
73 lines
1.9 KiB
C++
#include "ScavTrap.hpp"
|
|
|
|
ScavTrap::ScavTrap() : ClapTrap() {
|
|
this->name = "Default";
|
|
this->hp = 100;
|
|
this->energy = 50;
|
|
this->damage = 20;
|
|
std::cout << "ScavTrap " + this->name + " is created" << std::endl;
|
|
}
|
|
|
|
ScavTrap::ScavTrap(std::string name) : ClapTrap() {
|
|
this->name = name;
|
|
this->hp = 100;
|
|
this->energy = 50;
|
|
this->damage = 20;
|
|
std::cout << "ScavTrap " + this->name + " is created" << std::endl;
|
|
}
|
|
|
|
ScavTrap::ScavTrap(const ScavTrap &scav) : ClapTrap(scav) {
|
|
*this = scav;
|
|
std::cout << "ScavTrap " + this->name + " is created" << std::endl;
|
|
}
|
|
|
|
ScavTrap::~ScavTrap() {
|
|
std::cout << "ScavTrap " + this->name + " is destroyed" << std::endl;
|
|
}
|
|
|
|
ScavTrap& ScavTrap::operator=(const ScavTrap &scav) {
|
|
if (this != &scav) {
|
|
ClapTrap::operator=(scav);
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
void ScavTrap::attack(const std::string& target) {
|
|
if (this->energy > 0 && this->hp > 0) {
|
|
std::cout << "ScavTrap " + this->name + " attacks " + target + ", causing "
|
|
<< this->damage << " points of damage! " << std::endl;
|
|
this->energy--;
|
|
}
|
|
else
|
|
std::cout << "ScavTrap " + this->name + " is out of combat" << std::endl;
|
|
}
|
|
|
|
void ScavTrap::takeDamage(unsigned int amount) {
|
|
if (this->hp > 0) {
|
|
std::cout << "ScavTrap " + this->name + " takes " << amount << " damages" << std::endl;
|
|
this->energy--;
|
|
this->hp -= amount;
|
|
}
|
|
else
|
|
std::cout << "ScavTrap " + this->name + " is out of combat" << std::endl;
|
|
}
|
|
|
|
void ScavTrap::beRepaired(unsigned int amount) {
|
|
if (this->energy > 0 && this->hp > 0) {
|
|
std::cout << "ScavTrap " + this->name + " is repaired by " << amount << std::endl;
|
|
this->energy--;
|
|
this->hp += amount;
|
|
}
|
|
else
|
|
std::cout << "ScavTrap " + this->name + " is out of combat" << std::endl;
|
|
}
|
|
|
|
void ScavTrap::guardGate() {
|
|
if (this->energy > 0 && this->hp > 0) {
|
|
std::cout << "ScavTrap is now in Gate Keeper Mode" << std::endl;
|
|
this->energy--;
|
|
}
|
|
else
|
|
std::cout << "ScavTrap " + this->name + " is out of combat" << std::endl;
|
|
}
|