making a do while within a if statment for a basic attacking system

basicly im making a simple attacking system and i need help on making the do while within the if statments.

heres the code

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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include <cstdlib>
#include <iostream>
#include <sstream>



using namespace std;

int main(int argc, char *argv[])
{
 
    
    int long persona = 1000; // persona life yourself
    int long personb = 1000; // personb life  yourself knife attack
    int hit = 0;// how much damage your going to hit for
    int hit1 =0; // how much damage harry hits for
    int name; // person who is playing name
    int choose; // choose gun or knife
    int gun; // gun 
    int knife; // knife
    int attackstage = 1;  // attacking stage 
    int random_counter;// amount of damage withing the range
    
    
    string mystr;
    
    cout << "welcome to a basic battle system" << "\n";
    cout << "Please enter your name: ";
    getline (cin,mystr);
    stringstream(mystr) >> name; // enter your name
    cout << "\n";
    cout << "You have two weapons that you can choose from" << "\n";
    cout << "Knife has a more steady damage rate of 200-250" << "\n";
    cout << "while the gun has a more random danage rate of 100-400" << "\n"; 
    cout << "\n";
    cout << "Enter 0 for knife or 1 for gun" << "\n";
    cout << "what would you rather use gun or knife: " ;
    cout << "\n"; // storyline
    getline (cin, mystr);
    stringstream(mystr) >> choose; //choosing weopen 
   

    
    if (choose ==0) {// knife fight
    cout << "\n";
    cout << "You have choosen knife" << "\n";
    cout << "your about to fight for your life against the deadly Harry  " << "\n";
    cout << "He has also choosen a knife to attack, winner takes all the bottle caps" <<  "\n";
    cout << "\n"; //storyline
     

do{     
    cout << "attacking round: " << attackstage << "\n"; // what round in the fight it is
    attackstage = attackstage +1; // adds another round to a attack
    
    
    srand((unsigned)time(0)); 
    int random_integer; 
    int lowest=200, highest=250; 
    int range=(highest-lowest)+1; 
    for(int index=1; index<2; index++)
        random_integer = lowest+int(range*rand()/(RAND_MAX + 1.0)); 
        
    
    hit = hit + random_integer;
    cout << "You hit Harry for: " << hit << "\n";
    personb = personb -hit;
    cout << "Harry now have: " << personb << " life ponits left" << "\n";
    cout << "\n";
    
    
    int random_integer1; 

    for(int index=1; index<2; index++)
        random_integer1 = lowest+int(range*rand()/(RAND_MAX + 1.0)); 
        
    
    hit1 = hit1 + random_integer1;
    cout << "Harry hits you for: " << hit1 << "\n";
    persona = persona -hit1;
    cout << "You now have: " << persona << " life ponits left" << "\n";
    cout << "\n";}
    
   

}while (persona <= 0);
    
    
    
    else if (choose == 1){ // gun fight
    cout << "\n";
    cout << "You have choosen Gun" << "\n";
    cout << "your about to fight for your life against the nerd raged Scott " << "\n";
    cout << "He has also choosen a gun to attack, winner takes all the bottle caps" << "\n";} //storyline
    
   
    
    
    system("PAUSE");
    return 0;
   
}


sorted it out on my own using voids etc
Topic archived. No new replies allowed.