integrating classes to a long running project

this is a game I've been building on since i started learning c++ about a year and a half ago. id like to integrate classes into it now in the form of making the planets in a sort of map linked together such as terra novus connects to noctus and rouge, rouge goes to noctus and aquilis aquilis links to ager and noctus goes to rouge and aquilis (and back again). with a certain number of random events between (once i get this part up im going to add some random effects to the dead space such as meteor storms for damage, or a commodedety gain so on) no like between novus and noctus theres minimum of 3 events and max of like 5. im about to this point in my books but they dont make any sence to me on using classes. code follows

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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<cstdlib>
#include<ctime>


using namespace std;
// Function Pototypes

void Charac();
void Planet();
void Fight();
void DeadSpace();
void Save();
void Load();

// global money variables
int purchace;
int bounty = 0;
int have = 0;
int money = 500;

//character stats
int cSTR = 1 ;
int cHULL = 1;
int cREF = 1;
int hp;
int turn;
int clev = 0;
int z = 10;

int endcheck;

void main()
{
	string x;
	srand(time(0));
	
	cout << "Welcome to the Space Lanes v 1.11.02\n\n";
	system("Pause");
	system("cls");
    
	cout << "Would you like to load a saved game?(y/n) ";
	cin >> x;

	if(x == "y" || x == "Y")
	{
		system("cls");
		Load();
	}
	else
	{
		system("cls");
		Charac(); // call chara creation
	}
while(endcheck != -1)//game loop
{	
	system("cls");
	int dice = (rand()%3)+1;
    if(dice == 1)
	{
    Planet();
	}
	else if(dice == 2)
	{
    Fight();
	}
	else
	{
    DeadSpace();
	}
}
    cout << "You were shot down.  You made " << money << " credits in your career and acheived level " << clev <<".\n\n";
	
	system("pause");
	return;
	}


void Charac()

{
	cout << "Please assign your stats\n 1) For Damage\n 2) For Hull durability\n 3) For Reflexs\n\n";
	cout << "Health: " << hp << endl << endl
		 << "Damage: " << cSTR << endl
		 << "HULL: " << cHULL << endl
		 << "Reflex: " << cREF << endl << endl
		 << "Sequence: " << turn << endl;
	for(int i=0; i != z; i++)
	{
		
      	int choose;
        cin >> choose;

	  if(choose == 1)
	  {cSTR=cSTR+1;}
	  else if(choose == 2)
	  {cHULL = cHULL++;}
	  else
	  {cREF = cREF++;}

	  turn = cREF + 5;
	  hp = cHULL * 20;
	system("cls");

	cout << "Please assign your stats.\n 1) For Damage\n 2) For Hull durability\n 3) For Reflex\n\n";
	cout << "Health: " << hp << endl << endl
		 << "Damage: " << cSTR << endl
		 << "HULL: " << cHULL << endl
		 << "Reflex: " << cREF << endl << endl
		 << "Sequence: " << turn << endl;
	}
	clev = clev + 1;
    z = 5;
	system("cls");
	return;
}
void Planet()
{
	
	srand(time(0));
    int x;
	int commod = (rand()%100)+1;
	int bmon = ((rand()%75)+(10*clev))* bounty;
	int levcost = clev*1000;
	int dice = (rand()%5)+0;
	
	string planet[5]=
	{
		"Terra Novus",
	    "Terra Noctus",
		"Terra Rouge",
		"Terra Aqualis",
		"Terra Ager",
	};

	
	money = money + bmon;
	bounty = 0;
    
	
label2:
	while(x != 5)
	{
	  int levcost = clev*1000;
	  int mhp = cHULL * 20;
	  int repair = mhp - hp;
	  
	  system("cls");

	  cout << "\nYou've arrived at " << planet[dice] << endl;
	  cout << "You made " << bmon <<" credits for the pirates you have shot down\n\n";
	  cout << "you have: " << money <<" credits \n";
	  cout << "1) Repair ("<< repair << ")\n";
	  cout << "2) Purchace(" << commod <<")(" << purchace << ") \n" ;
	  cout << "3) Upgrade (" << levcost <<")\n";
	  cout << "4) Save Game \n";
	  cout << "5) Leave \n\n";
	  cin >> x;

	  switch(x)
	  {
	  case 1:
		  if(money < repair)
		  {
			  cout << "I'm sorry, you don't have the funds \n";
			  break;
		  }
		  else
		  {
			  money = money - repair;
			  hp = mhp;
			  break;
		  }
	  case 2:
		if(have == 0)
		{
		  if(money < commod)
		  {
			  cout << "I'm sorry you don't have the funds \n";
			  break;
		  }
		  else
		  {
			  money = money - commod;
			  have = 1;
			  purchace = commod;
			  cout << "Purchace made \n";
			  break;
		  }
		}
		else
		{
			money = money + commod;
			have = 0;
			purchace = 0;
			cout << "product sold\n";
			break;

		}
	 
	  

	  case 3:
		  if(money < levcost)
		  {
			  cout << "I'm sorry, you don't have the funds \n";
			  break;
		  }
		  else
		  {   
			  money = money - levcost;
			  system("cls");
			  Charac();
			  hp = mhp;
			  break;
		  }

		  case 4:
			
			Save();
			cout << "game saved ";
			system("pause");
            break;


	  default:
		  goto label2;
		  break;
	  }
	}
	return;
}

void Fight()
{
	srand(time(0));
	//Enemy Stats

	int eSTR = 1 ;
    int eHULL = 1;
    int eREF = 1;
    int ehp;
    int eturn;
	int a;
	int batend = 1;
	int lev = (rand()%clev)+1;
	

	for(int i = 0; i != (lev * 5);i++)  //generate enemy stats
	{
		int choose = (rand()%3)+1;

	    if(choose == 1)
	    {eSTR=eSTR+1;}
	    else if(choose == 2)
	    {eHULL = eHULL++;}
	    else
	    {eREF = eREF++;}

	  eturn = eREF + 5;
	  ehp = eHULL *20;

	  
	}
      
	
	 while(batend > 0)
	{

label1 :cout << "You have been attacked by a pirate! You have " << hp << " hull points remaining\n\n";
	    cout << "1)Fight\n2)Flee\n\n";
	    
		int cdam = (rand()%(cSTR * 2)) + cSTR; // Player Damage
	    int edam = (rand()%(eSTR * 2)) + eSTR; // Enemy Damage
		int cgo = (rand()%20)+turn;  //Player turn
		int ego = (rand()%20)+eturn;  //Enemy Turn
        
		cin >> a;
		
		system("cls");

		switch(a)
		{
		case 1:
		   
            if (cgo >= ego)
			{

			ehp = ehp - cdam;
			
			if(ehp <= 0)
			{
				cout << "victory";
				system("Pause");
				bounty++;
				batend = -1;
			}
			else
			{
				hp = hp - edam;
				
				if(hp < 0)
				{
					endcheck = -1;
					batend = -1;
				}
				else
				{
		        break;
				}
			}
			}
			else
			{
				hp = hp - edam;

				  if(hp <= 0)
				  {
					  endcheck = -1;
					  batend = -1;
				  }
			

				  else
				  {
					  ehp = ehp - cdam;
					  if (ehp <=0)
					  {
						  cout << "Victory ";
						  system("pause");
						  bounty ++;
						  batend = -1;
						  
					  }
					  else
					  {
						  break;
					  }
				  }
			
					break;
		case 2:
		 
		 hp = hp - edam;
		 
		 if(hp <= 0)
		 {
			 endcheck = -1;
			 batend = -1;
		 }
		 else
		 {
			 cout << "Escaped Successfully ";
			 system("pause");
			 batend = -1;
			 
		 }
		 break;

		

		default:
			
				goto label1;
				break;
         }	

		}
	 }
		  return;
	
		
	 }

void DeadSpace()
{
	cout << "Before you lies the vast and empty trade lanes ";

	system("Pause");
	return;
}

void Save()
{
	ofstream outfile;
	outfile.open("save.sav");
	 outfile << clev << endl;
	 outfile << cSTR << endl;
	 outfile << cHULL << endl; ;
	 outfile << cREF << endl;
	 outfile << money << endl;
	 outfile << have << endl;
	 outfile << purchace << endl;
	 outfile << hp << endl;
	outfile.close();
     return;
}

void Load()
{
	
	int x;
  ifstream infile;
  infile.open("save.sav");
   if(infile.fail() == 1)
   {
	   cout << "File does not exist please make a new charactor and save your game ";
	   system("pause");
	   system("cls");
	   Charac();
	   return;
   }
   else
   {
   infile >> x;
   clev = x;
   infile >> x;
   cSTR = x;
   infile >> x;
   cHULL = x;
   infile >> x;
   cREF = x;
   infile >> x;
   money = x;
   infile >> x;
   have = x;
   infile >> x;
   purchace = x;
   infile >> x;
   hp = x;
   }
   infile.close();

   z = 5;
   cout << "Game Loaded Successfully ";
   system("pause");
   system("cls");
   Planet();
   return;
}


any help would be GREATLY appreciated
The thing you need to do first is work out what the logical set of objects are for your game and how they interrelate.
Things that spring to mind from the description are;
Ship - Holds the data on a spaceship, methods to interact with other spaceships, move, etc.
Planet - Holds the data for a given planet, and methods to manipulate that data (such as adjusting current comodity values).
Space - A 'map' of the planets, and how they link together, methods to determine links, time for moving from one to another, etc.
If you are unsure, you might want to look at a less open-ended problem first to get a handle on objects then come back to this one when you are more familiar with them.
Topic archived. No new replies allowed.