Multiple Condition Do While Loops

Sorry for the long code but was wondering if anyone could help me with the do - while loop with multiple conditions. Basically i want the loop to end when player dies or when the monster dies

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
void fightMenu()         // SMALL MOB FIGHT
{
     srand(time(NULL));
     
     int choice = -1;
     int enemyHP = rand()%50+1;
     int enemyATK = rand()%10+1;
     
     do
     {
     
     cout<<"Enemy HP : "<<enemyHP;
     cout<<"\t\t\t\tYour HP : "<<player.pHealth<<endl;
     
     cout<<"1. Attack It!"<<endl;
     cout<<"2. Run!!!!"<<endl<<endl;
     
     cout<<"Your Choice : ";
     cin>>choice;
     
     if (choice == 1)
     {
                enemyHP -= player.pAtkPoint;
                cout<<enemyHP;
                
                if(enemyHP > 0)
                {
                           player.pHealth -= enemyATK;
                }
                
                
                
     }
     
     else if (choice == 2)
     {
          player.pPosX = player.pOldPosX;
          player.pPosY = player.pOldPosY;
     }
     cout<<string(50,'\n');
     }while((enemyHP > 0) || (player.pHealth > 0));
     
     if(enemyHP < 0)
     {
                map[player.pPosY][player.pPosX] = '_';
     }

}
replace || with &&

It reads then: loop as long as both are not dead (ie have health points)

your condition reads: loop as long as one of them is not dead
Thanks. Amatuer mistake
Topic archived. No new replies allowed.