It just keeps looping. The numbers continue decreasing until the program is closed. Am I misusing something?
The playerHealth and orcHealth ints are 100.
randomNumber = ("%10d", 1 + (rand() % 100));
This was the way I seen the random number used on an srand() explanation page. If this is wrong, how should it be?
Are there any other problems here?
switch(charDecision)
{
case 1:
cout << "FIGHT" << endl;
do{
randomNumber = ("%10d", 1 + (rand() % 100));
if(randomNumber >= 50){
orcHealth = orcHealth - (randomNumber - (randomNumber / 5));
cout << "You hit the orc! He now has " << orcHealth << " life left!" << endl;
}
else
{
playerHealth = playerHealth - (randomNumber - (randomNumber / 5));
cout << "The orc hit you! You now have " << playerHealth << " life left!" << endl;
}
}while(playerHealth || orcHealth >= 0);
break;
default:
break;
}