Integrating old Function into newly Modified code.

If anyone would take time to look at this, I'D like to keep main, as free of as much code as possible, while doing something similar to the outdated code, where this function calls the already created monsters (each in separate functions), to be used in BattlePhase function. Any help would be appreciated.
Old function that's most likely outdated due to modefications.
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
void YourType()
{
     string CharacterDetails;

     cout << "What character do you want?\n\n";
     cout << "There is a fire type who specializes with fire attacks. (fire)\n";
     cout << "There is a water type who specializes with water attacks. (water)\n";
     cout << "There is a nature type who specializes with nature attacks. (nature)\n\n";
     cout << "Please enter the type of the monster you would like:";
     cin >> CharacterDetails;     
     system("CLS");
     if(CharacterDetails == "fire")
     {
     YourFireType();
     }
     else if(CharacterDetails == "water")
     {
     YourWaterType();
     }
     else{ 
     YourNatureType();
     }

     system("CLS");
}


New Code that i would like to integrate it into.
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#include <iostream>
#include <ctime>
#include <string>
#include <sstream>
#include <cstdlib>
#include <vector>
#include <fstream>
using namespace std;
class Monster
{
      public:
      Monster(){}
      ~Monster(){}     
      void DisplayStats()
      {
           cout << "--------Monster Stats--------";
           cout << "\nType:" << Type;
           cout << "\nAttack:" << Attack;
           cout << "\nDefense:" << Defense;
           cout << "\nHealth:" << Health;
           cout << "\nEvade:" << Evade;
           cout << "\nLuck:" << Luck;
           cout << "\nSpeed:" << Speed;
           cout << "\nAdvantage:" << Advantage;
           cout << "\nDisadvantage:" << Disadvantage;
           cout <<"\nLevel:" << Level;
           cout <<"\nExperience:" << Experience;
           cout <<"\nSkillPoints:" << SkillPoints;
           cout << "\n-------------------------------";
      } 
      string GetType() { return Type; }
      void SetType(string x) { Type = x; }
      
      int GetAttack() { return Attack; }
      void SetAttack(int x) { Attack = x; }
           
      int GetDefense() { return Defense; }
      void SetDefense(int x) { Defense = x; }
      
      int GetHealth() { return Health; }
      void SetHealth(int x) { Health = x; }
      
      int GetSpeed() { return Speed; }
      void SetSpeed(int x) { Speed = x; }
      
      int GetEvade() { return Evade; }
      void SetEvade(int x) { Evade = x; }
      
      int GetLuck() { return Luck; }
      void SetLuck(int x) { Luck = 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 GetSkillPoints() { return SkillPoints; }
      void SetSkillPoints(int x) { SkillPoints = x; }
      
      int GetDamage() { return Damage; }
      void SetDamage(int x) { Damage = x; }
      
      
      
      private:
      string Type;
      int Attack;
      int Defense;
      int Health;
      string Advantage;
      string Disadvantage;
      string MonsterName;
      int Evade;
      int Luck;
      int Speed;
      int Level;
      int Experience;
      int SkillPoints;
      int Damage;
};

class Player
{
public:
void PlayerCard()
{
cout << "Here " << Name << " This is your I'D card I have created for you.\n";
cout << "-----------------------------\n";
cout << "| ID CARD |                 |\n";
cout << "-----------------------------\n";
cout << "| NAME:   " << Name << "\n";
cout << "| AGE:    " << Age << "\n";
cout << "| GENDER: " << Gender << "\n";
cout << "=============================\n\n\n";
cin.get();
}
string GetName() { return Name; }
void SetName(string x) { Name = x; }

string GetAge() { return Age; }
void SetAge(string x) { Age = x; }

string GetGender() { return Gender; }
void SetGender(string x) { Gender = x; }

int GetMoney() { return Money; }
void SetMoney(int x) { Money = x; }

private:       
string Name;
string Age;
string Gender;
int Money;
};
void YourFireType(Monster & monster)
{
monster.SetType("fire");//type
monster.GetType();
monster.SetAttack(8);//attack
monster.GetAttack();
monster.SetDefense(1);//defense
monster.GetDefense();
monster.SetHealth(40);//health
monster.GetHealth();
monster.SetAdvantage("Nature");//advantage
monster.GetAdvantage();
monster.SetDisadvantage("Water");//disadvantage
monster.GetDisadvantage();
monster.SetMonsterName("YourFireType");//name
monster.GetMonsterName();
monster.SetEvade(10);
monster.GetEvade();
monster.SetLuck(10);
monster.GetLuck();
monster.SetSpeed(10);
monster.GetSpeed();
monster.SetLevel(5);
monster.GetLevel();
monster.SetExperience(1000);
monster.GetExperience();
monster.SetSkillPoints(0);
monster.GetSkillPoints();
monster.DisplayStats();
cin.get();
}

void OpponentFireType(Monster & monster)
{
monster.SetType("fire");//type
monster.GetType();
monster.SetAttack(9);//attack
monster.GetAttack();
monster.SetDefense(1);//defense
monster.GetDefense();
monster.SetHealth(40);//health
monster.GetHealth();
monster.SetAdvantage("Nature");//advantage
monster.GetAdvantage();
monster.SetDisadvantage("Water");//disadvantage
monster.GetDisadvantage();
monster.SetMonsterName("OpponentFireType");//name
monster.GetMonsterName();
monster.SetEvade(10);
monster.GetEvade();
monster.SetLuck(10);
monster.GetLuck();
monster.SetSpeed(10);
monster.GetSpeed();
monster.SetLevel(5);
monster.GetLevel();
monster.SetExperience(1000);
monster.GetExperience();
monster.SetSkillPoints(0);
monster.GetSkillPoints();
monster.DisplayStats();
cin.get();
}
void BattlePhase (Monster & monster1, Monster & monster2)
{
     while (monster1.GetHealth() > 0 && monster2.GetHealth() > 0)
     {   
         if(monster1.GetHealth() > 0)
         {
              monster1.SetDamage(monster1.GetAttack() - monster2.GetDefense());
              if(monster1.GetDamage() <=1)
              {
              monster1.SetDamage(1);
              }
              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.get();
         }
         if(monster2.GetHealth() > 0)
         {          
              monster2.SetDamage(monster2.GetAttack() - monster1.GetDefense());
              if(monster2.GetDamage() <=1)
              {
              monster2.SetDamage(1);
              }
              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.get();
         } 
     }
}
int main(int argc, char *argv[])
{  Monster  monster1;
    Monster  monster2;

    YourFireType (monster1);
    OpponentFireType (monster2);
    BattlePhase (monster1, monster2);
    cin.get();
    return 0;
}
Last edited on
so any help integrating that into my code, while keeping main as clear from as much code as you can would be highly apprecieated (i want to be able to choose my monsters (YourFireType, YourWaterType,YourNatureType) from a seperate void function, and maybe clear up main a bit)
Last edited on
Topic archived. No new replies allowed.