void combat()
{
int a=1;
CPlayer player;
cout << "You intiate combat with a " << furbolg.getname() << endl;
while (a==1)
{
sleep(2);
player.sethealth((player.gethealth()) - (furbolg.getdamage()));
cout << "The furbolg hits you for: " << furbolg.getdamage() << endl;
cout << "Your health is: " << player.gethealth() << endl;
}
}
and a command for combat for the player...
1 2 3 4 5 6 7 8 9 10 11 12 13
elseif (input == "attack" or input == "hit")
{
if (fight == true)
{
furbolg.sethealth((furbolg.gethealth()) - (player.getdamage()));
cout << "You deal " << player.getdamage() << " to the " << furbolg.getname() << endl;
cout << "His health is: " << furbolg.gethealth() << endl;
if ((furbolg.gethealth()) <= 0)
{
cout << "You killed the " << furbolg.getname();
}
}
}
The attack and hit is not working during battle. The furbolg keeps dealing damage to the player, but it doesn't allow me to type in attack. What can I do to fix this problem?
I tried to interrupt the loop with in a=0; but the commands in which the player enters is below the combat function. I can't move the combat function below the commands function or I will not be able to call it. I don't know what to do, could someone help?