d03 ex03 a priori ok
This commit is contained in:
@@ -43,6 +43,34 @@ ScavTrap & ScavTrap::operator=( ScavTrap const & rhs ) {
|
||||
* PUBLIC MEMBER FUNCTIONS
|
||||
*********************************************/
|
||||
|
||||
void ScavTrap::attack(const std::string & target) {
|
||||
|
||||
std::ostringstream action;
|
||||
std::ostringstream state;
|
||||
|
||||
state << B_CYAN "[" B_GREEN << _class[0] << _number << B_PURPLE "h,e,a" B_CYAN ":" B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "->";
|
||||
action << _class << " " << _name << "-" << _number << B_CYAN " SPECIAL SCAV" RESET;
|
||||
|
||||
if (_energy > 0 && _hit > 0)
|
||||
{
|
||||
_energy--;
|
||||
if (_energy < 0)
|
||||
_energy = 0;
|
||||
action << " attacked " << target << ", causing " B_YELLOW << _attack << RESET << " points of damage" << '\n';
|
||||
}
|
||||
else
|
||||
{
|
||||
_attack = 0;
|
||||
if (_energy <= 0)
|
||||
action << " cannot attack because " B_RED " is out of energy" RESET"\n";
|
||||
else if (_hit <= 0)
|
||||
action << " cannot attack because " B_RED " is out of hit" RESET "\n";
|
||||
}
|
||||
|
||||
state << B_BLUE << _hit << "," << _energy << "," << _attack << B_CYAN "]" RESET;
|
||||
std::cout << state.str() << action.str();
|
||||
}
|
||||
|
||||
void ScavTrap::guardGate() {
|
||||
std::cout << _class << " " << _name << "-" << _number << " entered special mode Gate Keeper\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user