Zork Cone (Help please)

For some reason the loop won't stop when the playerHP < zero, however. The loop does stop when the dragonHP < zero. Why is this happening?

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
  #include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

string name;
int playerHP = 20;
int dragonHP = 30;
string choice;


int main(){
    srand(time(NULL));
    cout << "Hello wanderer, what is your name?" << endl;
    cin >> name;
    cout << "Welcome " << name <<". Kill the fucking dragon." << endl;
    do{
    int Attack = rand() % 10 + 1;
    int Heal = rand() % 10 + 1;
    int dragonAttack = rand() % 15 + 1;
    cout << "Attack - Heal" << endl;
    cin >> choice;

    if(choice == "Attack" || choice == "attack"){
        dragonHP = dragonHP - Attack;
        cout << "You attacked the dragon! It has " << dragonHP << " left!" <<  endl;
    }
    else{
        playerHP = playerHP + Heal;
        cout << "You healed yourself for " << Heal << " ! Your current HP is" << playerHP << endl;

    }

    playerHP = playerHP - dragonAttack;
    cout << "The dragon attacked you for " << dragonAttack << " damage! You have " << playerHP << " left!" << endl;


    }while(dragonHP > 0 || playerHP > 0);

    cout << "Game over" << endl;

    return 0;
}


Output:

http://prntscr.com/2eg2b7

Help is MUCH appreciated! Also an explaination please.
1- indent you code properly
a- || means or (truth table http://en.wikipedia.org/wiki/Truth_table#Logical_disjunction )
If the dragonHP is lower than 0 why wouldn't it trigger the truth table then?
Think about it.
while(dragonHP > 0 || playerHP > 0);

do whatever while dragonHP is more than zero, or while playerHP is more than zero.
Oooooh. I see, stupid me.

How would i fix it so it i'd stop when ONE of those is less than 0?
Somebody please?
while (dragonHP > 0 && playerHP > 0);
Topic archived. No new replies allowed.