53 lines
1.3 KiB
C++
53 lines
1.3 KiB
C++
#include "FragTrap.hpp"
|
|
|
|
FragTrap::FragTrap() : ClapTrap() {
|
|
this->name = "Default";
|
|
this->hp = 100;
|
|
this->energy = 100;
|
|
this->damage = 30;
|
|
std::cout << "FragTrap " + this->name + " is created" << std::endl;
|
|
}
|
|
|
|
FragTrap::FragTrap(std::string name) : ClapTrap() {
|
|
this->name = name;
|
|
this->hp = 100;
|
|
this->energy = 100;
|
|
this->damage = 30;
|
|
std::cout << "FragTrap " + this->name + " is created" << std::endl;
|
|
}
|
|
|
|
FragTrap::FragTrap(const FragTrap &frag) : ClapTrap(frag) {
|
|
*this = frag;
|
|
std::cout << "FragTrap " + this->name + " is created" << std::endl;
|
|
}
|
|
|
|
FragTrap::~FragTrap() {
|
|
std::cout << "FragTrap " + this->name + " is destroyed" << std::endl;
|
|
}
|
|
|
|
FragTrap& FragTrap::operator=(const FragTrap &frag) {
|
|
if (this != &frag) {
|
|
ClapTrap::operator=(frag);
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
void FragTrap::attack(const std::string& target) {
|
|
if (this->energy > 0 && this->hp > 0) {
|
|
std::cout << "FragTrap " + this->name + " attacks " + target + ", causing "
|
|
<< this->damage << " points of damage! " << std::endl;
|
|
this->energy--;
|
|
}
|
|
else
|
|
std::cout << this->name + " is out of combat" << std::endl;
|
|
}
|
|
|
|
void FragTrap::highFivesGuys() {
|
|
if (this->energy > 0 && this->hp > 0) {
|
|
std::cout << "FragTrap " + this->name + " making a high fives" << std::endl;
|
|
this->energy--;
|
|
}
|
|
else
|
|
std::cout << this->name + " is out of combat" << std::endl;
|
|
}
|