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
|
#include "stdafx.h";
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
using namespace std;
//Set some global variables
bool g_Free = false; //boolean telling us if you're free from the cell
int bar = 0; //bar counter telling us if the user has the bar from the window or not
//Make some functions
string object(string *input) //this is supposed to declare the object string used to identify what the action is being used on (ex. "look DOOR"
{
}
string action(string *input) //this is supposed to declare the action, used in the first word of user input (like "LOOK door"
{
std::string str ; //declares input as "str"
}
void DoProcess(string input) //this is the function that will be used to decide which function should be used next, based on the action string that was recieved from the user's input
{
string cmd = action(&input);
if( cmd == "look" ) OnLook(object); //if action is look, run function OnLook
else if( cmd == "use" ) OnUse(object); //if action is use, run function OnUse
else if( cmd == "help" ) OnHelp(object);
else
{
cout << "Silly drunk, what are you doing? Try to do something productive, like getting out of this cell!" << cout;
}
}
void OnLook(string arg) //function that runs if the user's action is look
{
if(arg == "door")
{
cout << "Apon looking at the hulking wooden door, you notice that there is a small clearing between the door and the wall. Almost the right size for a small object, like a bar..." << endl;
}
else if(arg == "window")
{
cout << "Observing the window, you notice that one of the bars is coming loose. Maybe you could use it later?" << endl;
}
else
{
cout << "You seem to be in a small room, almost like a prison cell. The only things in it are a small window and a large wooden door." << endl;
}
}
void OnUse(string arg) //function that runs if the user's action is use
{
if (arg == "window")
{
string answer;
cout << "You notice that a bar in the window is somewhat loose, would you like to take it?" << endl;
cin >> answer;
if(answer == "yes")
{
cout << "You take the bar out of the window!" << endl;
bar = bar + 1;
}
}
else if(arg == "door")
{
if(bar == 1)
{
cout << " You slip the bar through the door and successfully escape! Congradulations!" << endl;
g_Free = true;
}
else
{
cout << "The door is locked silly, you need to find a way to open it!" << endl;
}
}
else
{
cout << "Silly drunk, what are you doing? Try to do something productive, like getting out of this cell!" << endl;
}
}
void OnHelp(string arg) //function that runs if the user types in "help"
{
if(arg == "help")
{
cout << "Use LOOK to look around, use OPEN to open things, and use USE to use things" << endl;
}
else
{
cout << "Silly drunk, what are you doing? Try to do something productive, like getting out of this cell!" << endl;
}
}
int main()
{
string input;
while (g_Free == false)
{
//placeholder for some SICK ASCII ART
cout << "You wake up in a small room, clueless as to what happened last night." << endl;
cout << "Maybe you had a little too much to drink at the tavern last night." << endl;
cout << "You do remember that you needed some HELP getting out of the tavern..." << endl;
cout << endl;
cout << "What would you like to do?" << endl;
cin >> input;
DoProcess(input);
}
}
|