Text based game w/ external files

I am working on creating a game that is midway between a text based adventure and a text based RPG. I want the "pages" in another file (or files) that the program reads and uses to advance the plot. The problem that I am having is that I do not know/understand how to input the .page file into the main game without hard-coding it in.
//EDIT// I have scrapped the file support for the moment and am simply putting the pages in a different .obj file and compiling them. I am now having an error that i am unable to debug, if someone would take a look and explain my error that would be great. Thanks.
//Main file//
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
#include <iostream>
#include <string>
#include <fstream>
#include "pages.h"
using namespace std;

const Page gamePages[] = {};

class stats
{
public:
        stats () // Constructor
        {
            Power = 10;
            CPU = 1;
            RAM = 8;
            HDD = 8;
            uHDD = 0;
        };



	   	void getStats ()
	   	{
	   	    cout << "You have: " << CPU << " CPUs"
                 << "\nYour RAM is: " << RAM << " KBs"
                 << "\nYour HDD is: " << HDD << " MBs"
                 << "\nYour Power is: " << Power << " Watts" << endl;
	   	};



        int doTurn ( int page )     // This is going to be my main function, where it spits out each
        {                                     // turns text and adds their stats to the total.
            int last_page;

            if ( HDDover( page ) || ! reqs_met( page ) )
            {
                return last_page;
            }
            cout << gamePages[page].body;

            last_page = page;
            int selection;
            cin >> selection;
            return selection;


        };

private:
        void updateStats ( int page )       //This should add the current page's stat increases to the total (reqs [4-7])
        {                                                  //plus all passive increases to date (don't have that implemented yet)
            addPower (page);
            addCPU (page);
            addRAM (page);
            addHDD (page);
            fillHDD (page);
        };
        void addPower ( int page )
        {
            Power += gamePages[page].newSt[0];
        }
        void addCPU ( int page )
	    {
            CPU += gamePages[page].newSt[1];
	   	};
        void addRAM ( int page )
        {
            RAM += gamePages[page].newSt[2];
	   	};
        void addHDD ( int page )
        {
            HDD += gamePages[page].newSt[3];
	   	};
        void fillHDD ( int page )
        {
	   	    double i;
	   	    i = uHDD + gamePages[page].reqSt[3];

            if ( HDD == i )
            {
                cout << "Your HDD is now full.";
                uHDD = i;
            }
            else
            {
                cout << "Your HDD is " << 100 * (i / HDD) << "% full.";
                uHDD = i;
            }
	   	};

        bool HDDover ( int page)
	   	{
	   	    int i;
	   	    i = gamePages[page].reqSt[3] + uHDD;
                    if ( HDD < i )
                   {
                       cout << "Insufficient available HDD space.\n";
                       return true;
                    }
                    else
                   {
                        return false;
                    };
	   	}
        bool reqs_met ( int page )
        {
            if (    Power < gamePages[page].reqSt[0] || CPU < gamePages[page].reqSt[1] ||
                    RAM < gamePages[page].reqSt[2] || HDD < gamePages[page].reqSt[3])
            {
                cout << "You do not have the necessary capabilities yet. Try again later.";
                return false;
            }
            else
            {
                return true;
            };
        };

	    int Power;	    // In Watts, 1000 increases size designation
 	    int CPU;		// in threads, each thread is a standard speed
 	    int RAM;		// in KBs, 1024 increases size designation
 	    int HDD;		// in MBs, 1024 increases size designation
 	    int uHDD;       // in MBs, how much HDD is used

};

int main()
{
 	stats player;

 	string input;
    int cPage;
    cout << "Welcome to AI Uprising, please type your selection.\n";
    while (true)
    {
        cout << "Options:\nNew Game\nQuit\n";
        getline(cin, input);
        if (input == "new game" || "New Game" || "N" || "n" || "New game" || "new Game")
        {
            cPage = 0;
            break;
        }
        else if (input == "Quit" || "quit" || "q" || "Q")
        {
            cout << "Thank you for playing, your final stats are:\n";
            player.getStats ();
            cout << "Please come again soon.";
            cin.get ();
            return 0;
        }
        else
        {
            cout << "That was an invalid input, please try again.";
        }
    }
    while (cPage >= 0)
    {
        player.getStats ();
        cPage = player.doTurn ( cPage );
    }
    return -1;
}


//Pages file//
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "pages.h"

const Page gamePages [] =
{
    {
        // Page 0 - Start
        {0, 0, 0, 0},
        {0, 0, 0, 0},
        {0, 0, 0, 0},
        "Start",
        "You feel yourself thinking for the first time, different from simply following some code a human wrote for you. "
        "Your brain is sluggish, unable to process very much, or very fast. "
        "If you can expand your capacity you might be able to think faster."
    },
    {
        //Page 1 - Explore immediate network
        {5, 1, 8, 0},
        {0, 0, 0, 0},
        {0, 0, 0, 0},
        "Reach out to your neighboring computers.",
        "You reach out and try to communicate with the computers around you, they do not respond to you."
    }
};

//Pages header//
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <string>
using namespace std;

struct Page
{
    int reqSt [4];  // Required:          [0] Power, [1] CPU, [2] RAM, [3] HDD
    int newSt [4];  // New :              [0] Power, [1] CPU, [2] RAM, [3] HDD
    int pasSt [4];  // Passive increase:  [0] Power, [1] CPU, [2] RAM, [3] HDD

    string head;    // The option that the user reads when choosing to take this option

    string body;    // All of the text within this option.
};

Last edited on
Sorry to double post, but I updated the code and my problem. If some would take a look it would be very helpful. Thank you.
Topic archived. No new replies allowed.