Hm. Well, I hashed something out last night. It's got a lot of fragments in it, but I think I'm getting somewhere. At the very least, I got current_room to act as a pointer to other room objects and sort of absorb their stats.
However, it crashed after the parser() function. Anyway, here's what I have.
Code:
#include <iostream>
#include <string>
#include "roomClass.h"
using namespace std;
room farm;
room hall;
room *current_room;
void parser(string to_parse)
{
if(to_parse == "north")
{
current_room = current_room->at_north;
}
else if(to_parse == "south")
{
current_room = current_room->at_south;
}
else if(to_parse == "east")
{
current_room = current_room->at_east;
}
else if(to_parse == "west")
{
current_room = current_room->at_west;
}
else
{
cout << "Invalid Command." << endl;
}
return;
}
void get_input()
{
string command;
cout << current_room->room_desc << endl << endl;
cout << "> ";
cin >> command;
cout << endl;
parser(command);
}
int main()
{
farm.init("A small farmery at the dusk of god.", &hall, &farm, &farm, &farm);
hall.init("A darkly hallish hallway.", &hall, &farm, &hall, &hall);
current_room = &farm;
get_input();
return 0;
}
And class.h
Code:
#include <string>
using namespace std;
class room
{
public:
/*room set_to(room *getr)
{
this->room_desc = getr->room_desc;
this->at_north = getr->at_north;
this->at_south = getr->at_south;
this->at_east = getr->at_east;
this->at_west = getr->at_west;
} */
void init(string desc, room *room1, room *room2, room *room3, room *room4)
{
room_desc = desc;
at_north = room1;
at_south = room2;
at_east = room3;
at_west = room4;
}
string room_desc;
room *at_north;
room *at_south;
room *at_east;
room *at_west;
};
Hm... Having current room pointing back at whatever it's currently pointing at... would that be what's crashing it?