Can anyone see the problem with my method ATTACK
#include "Monster.h"
#include "Player.h"
#include "Weapon.h"
#include <iostream>
using namespace std;
Monster::Monster(std::string Name, int health, int hitPoints,
int miss, int damage,const std::string& weaponName)
{
Name = Name;
hitPoints = hitPoints;
Weapon weapon;
miss = miss;
damage = damage;
weapon.Name = weaponName;
}
bool Monster::Death()
{
return hitPoints <= 0;
}
std::string Monster::getName()
{
return Name;
}
void Monster::attack(Player& player)
{
cout << "A " << Name << " attacks you "
<<"with a " << weapon.Name << endl;
int damage = weapon.weaponHitPoints;
int totalDamage = damage;
if(totalDamage <= 0)
{
cout << "The monster's attack failed to "
<< "penetrate your armour." << endl;
}
else
{
cout << "You are hit for " << totalDamage
<< " damage!" << endl;
player.takeDamage(totalDamage);
}
}
else
{
cout << "The " << Name << "missed!" << endl;
}
cout << endl;
}