Fixing the bugs in the program that happened when creating the functions.

Can you help me fix 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#include <iostream>
//NAMESPACE
using namespace std;
//MY VARIABLES
     long a = 0;
     long b = 1;//never changes
     long c = 2;//never changes
     long d = 0;
     long e = 0;
     long f = 3;//never changes
     long Attack = 0;
     long Defence = 0;
     long Health = 0;
     long Damage = 0;
     long OAttack = 0;
     long ODefence = 0;
     long OHealth = 0;
     long Battlephase = 0;
     long Number = 0;
     long Void = 0;
//CALLS MY FUNCTIONS
void Program();//calls the Program function
void Character();//calls the Character function
void TypeCharacter();//calls the TypeCharacter function
void Rules();//calls the Rules function
void Stat();//calls the Stat function
void YourAdvantageDisadvantage();//calls the YourAdvantageDisadvantage function
void OponentAdvantageDisadvantage();//calls the OponentAdvantageDisadvantage function
void Battlephase();//calls the Battlephase function

//EXECUTES THE PROGRAM
int main()
{
     Program();
     Character();
     TypeCharacter();
     Rules();
     Stat();
     YourAdvantageDisadvantage();
     OponentAdvantageDisadvantage();
     Battlephase();

     system("PAUSE"); 
	 return 0;
}
void Program()
{
     cout << "Please note this program will only work if you press ENTER after each responce."<< endl;
}
void Character()
{
     cout << "What character do you want?" << endl << endl;
     cout << "There is a fire type who specializes with fire attacks. (#1)" << endl;
     cout << "There is a water type who specializes with water attacks. (#2)" << endl;
     cout << "There is a nature type who specializes with nature attacks. (#3)" << endl << endl;
     cout << "Please enter the number of the monster you would like.";
     cin >> a;
     cout << endl;
}
void TypeCharacter()
{
     if(a == b)
     {
     e = 1;
     cout << "You chose the fire type." << endl << "It does twice as much damage on nature types and half as much damage on water   types.";
     }
     else if(a == c)
     {
     e = 2;
     cout << "You chose the water type." << endl << "It does twice as much damage on fire types and half as much damage on nature    types.";
    
     }
     else{e = 3; 
     cout << "You chose the nature type." << endl << "It does twice as much damage on water types and half as much damage on fire     types."<< endl << endl; 
     ; 
     }
}
void Rules()
{ 
     cout << "Each of your characters battle." << endl; 
     cout << "You each alternate by taking turns. " << endl; 
     cout << "Since you are a beginner you will go first." << endl << endl; 
     cout << "To continue, type a number."; 
     cin >> d; 
     cout << endl;
}
void Stat()
{   
     if(e == b) 
     { 
     cout << "Your fire type has the following stats" <<endl <<endl; 
     } 
     else if(a == c) 
     { 
     cout << "Your water type has the following stats" <<endl <<endl; 
     } 
     else{ 
     cout << "Your nature type has the following stats"<<endl <<endl; 
     ; 
     } 
 
     Attack = 10; 
     Defence = 2; 
     Health = 40; 
     OAttack = 10; 
     ODefence = 2; 
     OHealth = 40; 
 
 
     cout << "Attack:" << Attack << endl << "Defense:" << Defence << endl << 
     "Health:" << Health << endl << endl; 
     cout <<"Your opponent sent out a water type."<<endl; 
     cout <<"Its stats are"<<endl<<endl; 
     cout << "Attack:" << OAttack << endl << "Defense:" << ODefence << endl << 
     "Health:" << OHealth << endl << endl; 
     cout << "Type a number to continue.";
}
void YourAdvantageDisadvantage()
{
//fire 
     if(e == b) 
     { 
     Attack = Attack / 2; 
     } 
//water 
     if(e == c) 
     { 
     Attack = Attack + 0; 
     } 
//nature 
     if (e == f) 
     { 
     Attack = Attack * 2; 
     } 
}
void OponentAdvantageDisadvantage()
{ 
//water vs fire 
     if(e == b) 
     { 
     OAttack = OAttack * 2; 
     } 
//water vs water 
     if(e == c) 
     { 
     OAttack = OAttack + 0; 
     }
//water vs nature 
     if (e == f) 
     { 
     OAttack = OAttack / 2; 
     } 
 
     cin >> d; 
     cout << endl; 
}
void Battlephase()
{ 
     cout <<"Let the battle begin!"<<endl; 
     YouAttack:
     { 
          if(Health != Number)
          {
                    {
                                cout << "You attacked and dealt " << Attack <<" Damage" <<endl; 
                                OHealth = OHealth - Attack; 
                                cout << "Your opponents health is " << OHealth <<endl <<endl; 
                    }
          if(OHealth == Number) 
                    { 
                                cout <<"You Win!"<<endl<<endl;
                    }
          if (OHealth > Number)goto OpponentAttack;
          }
     }
     OpponentAttack:
     {
          if(OHealth != Number)
          {
                     {
                                cout << "Your opponent attacked and dealt " << OAttack <<" Damage" <<endl; 
                                Health = Health - OAttack; 
                                cout << "Your health is " << Health <<endl <<endl; 
                     }     
          if(Health == Number) 
                     {  
                     cout <<"You Lose :("<<endl<<endl;  
                     } 
          if (Health > Number)goto YouAttack;
          }
     }
}                

  
There are these ";" in spots they shouldn't be(They have no purpose).
At line 75 and 99.
That is all i could find.
It is obvious that this statement is invalid (#73)

else{e = 3;
<brandonator>
you cannot have a variable and a function named the same such as battlephase.
Last edited on
Topic archived. No new replies allowed.