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
|
#include <iostream>
#include <string>
#include <fstream>
#include "dungeonGraph.h"
using namespace std;
int main()
{
dungeonGraph G;
ifstream myfile;
//myfile.open ("Map.txt");
myfile.open ("map.txt");
string x, y;
int num;
bool var = false;
getline(myfile, x);
while (myfile && var == false)
{
getline(myfile, x);
if (x == " ")
{
//getline(myfile, x);
var = true;
}
else
{
G.addVertex(x);
}
}
while (!myfile.eof())
{
myfile>> x;
if ( x == "Doors")
{
myfile >> y;
myfile >> y;
}
else
{
myfile>>num;
G.addWeightedEdge(y, x, num);
}
}
myfile.close();
//G.addWeightedEdge("foyer","helipad", 4);
//G.addWeightedEdge("helipad","snakepit", 2);
//G.addWeightedEdge("snakepit","foyer", 10);
//G.addWeightedEdge("helipad","foyer", 4);
//G.addWeightedEdge("foyer", "snakepit", 2);
//G.addWeightedEdge("snakepit", "helipad", 10);
//where you start your journey
G.movePlayer("foyer");
cout << "If at anytime you want to find the shortest path to a location" << endl << "just type in 'cheater'!!!!"<< endl;
string destination;
while(true)
{
//tell the player where they are
cout << "You are in the " << G.getPlayerLocation() << ". " << G.getTime() << " hours have passed since you entered." << endl;
//tell the player where they can go
cout << "There are doors to " << G.getExits() << endl;
//get desired destination from player, try to move them their
cout << "Where would you like to go?" << endl;
cin >> destination;
if( G.tryToTravelTo(destination) )
cout << "You begin walking to your destination..." << endl;
else if (destination == "cheater")
{
cout<<"cheater"<<endl;
}
else
cout << "You RUN INTO A WALL!!!" << endl;
cout << endl;
}
}
|