How would i implent this into the BattlePhase part of the program?

I tried to implement this into both my monster and battlephase but i could not figure out how to do it,
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
class Moves
{
public:
string GetType() { return Type; }
void SetType(string x) { Type = x; }

string GetCategory() { return Category; }
void SetCategory(string x) { Category = x; }

int GetPower() { return Power; }
void SetPower(int x) { Power = x; }

int GetAccuracy() { return Accuracy; }
void SetAccuracy(int x) { Accuracy = x; }

int GetPP() { return PP; }
void SetPP(int x) { PP = x; }

private:
string Type;
string Category;
int Power;
int Accuracy;
int PP;
}Atk1,Atk2,Atk3,Atk4;
void Move1(Moves & move) //The Move
{
move.SetType("Normal");
move.SetCategory("Physical");
move.SetPower(100);
move.SetAccuracy(100);
move.SetPP(10);
};

any help would be greatful, important things needed to know before helping below (thanks to anybody who helps me with this problem)

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
class Monster // Defines the existance of monsters
{
      public: 
      Monster(){}
      ~Monster(){}    
      void DisplayStats()
      {
           cout << "--------Monster Stats--------------------";
           cout << "\nType:" << Type;
           cout << " Name:" << MonsterName;
           cout << "\nAdvantage:" << Advantage;
           cout << " Disadvantage:" << Disadvantage;
           cout << "\nAtk:----------> " << Atk;
           cout << "\nDef:----------> " << Def;
           cout << "\nSpAtk---------> " << SpAtk;
           cout << "\nSpDef---------> " << SpDef;
           cout << "\nHP:-----------> " << HP;
           cout << "\nSpeed:--------> " << Speed;
           cout << "\nLevel:--------> " << Level;
           cout << "\nExperience:---> " << Experience;
           cout << "\n-----------------------------------------";
      } 
      string GetType() { return Type; }
      void SetType(string x) { Type = x; }
      
      int GetAttack() { return Atk; }
      void SetAttack(int x) { Atk = x; }
           
      int GetDefense() { return Def; }
      void SetDefense(int x) { Def = x; }
      
      int GetSpAttack() { return SpAtk; }
      void SetSpAttack(int x) { SpAtk = x; }
           
      int GetSpDefense() { return SpDef; }
      void SetSpDefense(int x) { SpDef = x; }
      
      int GetHealth() { return HP; }
      void SetHealth(int x) { HP = x; }
      
      int GetSpeed() { return Speed; }
      void SetSpeed(int x) { Speed = x; }
      
      string GetAdvantage() { return Advantage; }
      void SetAdvantage(string x) { Advantage = x; }
      
      string GetDisadvantage() { return Disadvantage; }
      void SetDisadvantage(string x) { Disadvantage = x; }
      
      string GetMonsterName() { return MonsterName; }
      void SetMonsterName(string x) { MonsterName = x; }
      
      int GetLevel() { return Level; }
      void SetLevel(int x) { Level = x; }
      
      int GetExperience() { return Experience; }
      void SetExperience(int x) { Experience = x; }
      
      int GetDamage() { return Damage; }
      void SetDamage(int x) { Damage = x; }
        
      private:
      string Type;
      int Atk;
      int Def;
      int HP;
      int SpAtk;
      int SpDef;
      string Advantage;
      string Disadvantage;
      string MonsterName;
      int Speed;
      int Level;
      int Experience;
      int Damage;
}monster1,monster2;

void FireType(Monster & monster) //The Fire Type
{   
monster.SetType("Fire");
monster.SetAdvantage("Nature");
monster.SetDisadvantage("Water");
monster.SetMonsterName("FireType");
monster.SetAttack(6);
monster.SetDefense(1);
monster.SetSpAttack(6);
monster.SetSpDefense(1);
monster.SetHealth(40);
monster.SetSpeed(10);
monster.SetLevel(5);
monster.SetExperience(1000);
monster.DisplayStats();
cin.ignore( std::numeric_limits <std::streamsize> ::max(), '\n' );
}

void BattlePhase (Monster & monster1, Monster & monster2)//does the battle phase
{
     while (monster1.GetHealth() > 0 && monster2.GetHealth() > 0)
     {   
         if(monster1.GetHealth() > 0)
         {
         cout << "Which move would you like to do?\n?";
         int BasePower = 10; /*Default value till moves get added.*/
         int SpAtk;
         int SpDef;
         double Type1 = 1;
         double CH;
         double STAB = 1.5; /*Same Type Attack Bonus Default till moves get added*/
         int R;
             if (monster1.GetType() == "Physical") /*needs monster 1's move type, not complete*/
             {SpAtk = monster1.GetAttack();
             SpDef = monster2.GetDefense();}
             else
             {SpAtk = monster1.GetSpAttack();
             SpDef = monster2.GetSpDefense();}
                   CH = rand() % 16 + 1;
                   if (CH == 8){CH = 1.5;}
                   else{CH = 1;}
                   R = rand() % 15 + 85;
if(monster1.GetType() == "Fire" && monster2.GetType() == "Water")
{Type1 = 0.5;}
if(monster1.GetType() == "Fire" && monster2.GetType() == "Nature")
{Type1 = 2.0;}
if(monster1.GetType() == "Water" && monster2.GetType() == "Fire")
{Type1 = 2.0;}
if(monster1.GetType() == "Water" && monster2.GetType() == "Nature")
{Type1 = 0.5;}
if(monster1.GetType() == "Nature" && monster2.GetType() == "Fire")
{Type1 = 0.5;}
if(monster1.GetType() == "Nature" && monster2.GetType() == "Water")
{Type1 = 2.0;}
monster1.SetDamage(((((((monster1.GetLevel() * 2 / 5) + 2) * BasePower * SpAtk / 50) / SpDef) + 2) * CH * R / 100) * STAB * Type1);
              cout << "You attacked and dealt " << monster1.GetDamage() <<" Damage\n";
              monster2.SetHealth(monster2.GetHealth() - monster1.GetDamage()); 
              cout << "Your opponents health is " << monster2.GetHealth() << "\n\n";
              if(monster2.GetHealth() <= 0) 
              { 
              cout <<"You Win!"<< "\n\n";
              }
              cin.ignore(numeric_limits<streamsize>::max(), '\n');
         }
         if(monster2.GetHealth() > 0)
         {
         int BasePower = 10; //Default value till moves get added
         int SpAtk;
         int SpDef;
         double Type1 = 1;
         double CH;
         double STAB = 1.5; //Same Type Attack Bonus Default til moves get added
         int R;
             if (monster2.GetType() == "Physical")/*needs monster 2's move type, not complete*/
             {
             SpAtk = monster2.GetAttack();
             SpDef = monster1.GetDefense();
             }
             else
             {SpAtk = monster2.GetSpAttack();
             SpDef = monster1.GetSpDefense();}
                   CH = rand() % 16 + 1;
                   if (CH == 8){CH = 1.5;}
                   else{CH = 1;}
                   R = rand() % 15 + 85;
if(monster2.GetType() == "Fire" && monster1.GetType() == "Water")
{Type1 = 0.5;}
if(monster2.GetType() == "Fire" && monster1.GetType() == "Nature")
{Type1 = 2.0;}
if(monster2.GetType() == "Water" && monster1.GetType() == "Fire")
{Type1 = 2.0;}
if(monster2.GetType() == "Water" && monster1.GetType() == "Nature")
{Type1 = 0.5;}
if(monster2.GetType() == "Nature" && monster1.GetType() == "Fire")
{Type1 = 0.5;}
if(monster2.GetType() == "Nature" && monster1.GetType() == "Water")
{Type1 = 2.0;}
         monster2.SetDamage(((((((monster2.GetLevel() * 2 / 5) + 2) * BasePower * SpAtk / 50) / SpDef) + 2) * CH * R / 100) * STAB * Type1);
              cout << "Your opponent attacked and dealt " << monster2.GetDamage() <<" Damage\n";
              monster1.SetHealth(monster1.GetHealth() - monster2.GetDamage()); 
              cout << "Your health is " << monster1.GetHealth() << "\n\n";   
              if(monster1.GetHealth() <= 0) 
              {  
              cout <<"You Lose :(\n\n";
              }
              cin.ignore(numeric_limits<streamsize>::max(), '\n');
         } 
     }            
}
Last edited on
No idea what you're having trouble with.
Are you getting compile errors?
Is it not working the way you expect?

BTW, you have a missing close quote and semicolon in line 102.
im trying to implent moves into the battlephase (which i cant figure out), each monster has 4 moves (Atk1,Atk2,Atk3,Atk4), each move is either physical and special, the moves have the following stats in move class and i need the user to have a choice as well as use the stats of the moves i currently have in the program (Type, Catagory, Power). (i've been using passing by reference technique if that's any help to you)

link to the whole program, if anybody wants to look at it and try to help

Last edited on
Topic archived. No new replies allowed.