/*
 *** TEXTGAME2.CPP ***
 VERSION 1.0 OF TEXTGAME
 Written by lightatdawn
 We do a whole lot suddenly in Version 2.0. Items are added. This entails that
 they must be usable, and dropable. They must have an effect. We also add spells
 and their effects. Gold and an inventory is added.
 We alter the start room to have a locked door instead of the archway of V1.0.
 You have to pick up and use the iron key to get out.
 I'm going to apologize a little in advance... I tried to make it really simple
 but it got a little out of control. Some things just cant be simplified. :(
 I know that parts of it (Get,Use,Drop) may look a little daunting but just take
 it a section at a time. My skills at organizing my code sometimes leaves a
 little to be desired... :)
  
 *** GENERAL NOTES ***
 I am going to comment EVERYTHING to make it easy to understand.
 I'm making this program in a Win32 Console platform. If it doesnt function
 right on your compiler... Ugg... (It should though.)
 I'm also not going to use cout or cin. It will be replaced by printf and gets.
 Hope this doesnt pose a problem, its just that i like printf...
 Our WORLD is set up in a grid. The grid is 3 squares by 3 squares:
 -------------
 |0x0|0x1|0x2|
 -------------
 |1x0|1x1|1x2|
 -------------
 |2x0|2x1|2x2|
 -------------
 So we map our players location with 2 variables, x and y. x is the horizontal
 positions and y is the vertical ones.
*/
//******************************************************************************
//* INCLUDE FILES                                                              *
//******************************************************************************
#include <windows.h> //we need this for use of the BOOL type
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
#define MAXITEMS 6
//We're defining the variable MAXITEMS to equal 6. This makes life easier.
//We have to use the #define function because it creates constant expression...
//   That means the MAXITEMS can never be changed. We CAN NOT say MAXITEMS = 7; at
//   Some point down the road. No can do. Not allowed. We need to do this because
//   We want to declare our char *item_name[] and other item variables with this.
//   And it wont let us do it unless that variable is constant. Confused yet?
//All the sections of code that check items in a loop, will have:
//for(loop = 0; loop < MAXITEMS; loop ++)
//instead of loop < 6; So that way, when you add some new items, you just change
//MAXITEMS to equal the total number you have. No need to change the loops.
//******************************************************************************
//* MAIN PROCEDURE                                                             *
//******************************************************************************
int main(void)
{
	//***************************************************************************
	//* VARIABLE DECLARATION                                                    *
	//***************************************************************************
	//Dont forget that arrays start at 0 and go to x-1. Meaning that an_array[3]
	//would have 3 elements at 0, 1, 2 respectivly. NOT 1,2,3!!
	//This array will hold the text for each room with up to 5 lines of
	//text in each... Each line may be up to 100 characters long.
	//Hence, [3][3][5][100]. 3x3 World. 5 lines. 100 characters long.
	//I dont feel like explaining multi-dimensional arrays in great detail.
	char text[3][3][5][100];
	//We will set this up to tell us what squares you are allowed
	//to walk to from each room. It would help if you drew your
	//world out on a sheet of graph paper or something...
	//We initialize the exit_ arrays to FALSE before we start. Now they
	//are all zero and we will declare the exit_ to equal TRUE later
	//but ONLY if there IS an exit. :)
	BOOL exit_n[3][3] = {FALSE,FALSE,FALSE,
						 FALSE,FALSE,FALSE,
						 FALSE,FALSE,FALSE,},
		 exit_s[3][3] = {FALSE,FALSE,FALSE,
						 FALSE,FALSE,FALSE,
						 FALSE,FALSE,FALSE},
		 exit_e[3][3] = {FALSE,FALSE,FALSE,
						 FALSE,FALSE,FALSE,
						 FALSE,FALSE,FALSE},
		 exit_w[3][3] = {FALSE,FALSE,FALSE,
						 FALSE,FALSE,FALSE,
						 FALSE,FALSE,FALSE};
	//These variables will hold the names and locations of items in the game
	//Notice that there are 'MAXITEMS' number of elements in the array. This
	//is our #define that we saw earlier coming into effect.
	char item_name[MAXITEMS][20];
	int item_location_x[MAXITEMS],
		 item_location_y[MAXITEMS];
	//The characters spells list. Holding a max of 4 spells (array 0-3)
	//That {"","","",""} is how you initialize the values of an array
	char spell[4][50] = {"","","",""};
	int location_x = 1,		//The X location on our 3x3 World grid of the player
		location_y = 2,		//The Y location
		gold = 20,			//The currency variable
		command_accepted,	// --- Explained later ---
		loop,				//Used in our for loops throughout the function
		in_loop;			//Used for the nested for loops (loops inside another loop)
	char user_input[30];	//Variable that we store the user input in for examination
	//MAP OF THE WORLD
	//Im going to declare the rooms starting with the top left and working right then down...
	//The ---- and the | are the squares. The "#" are the walls (duh!)
    /*
    |------------------|-------------------|-------------------|
    |##################|###################|###################|
    |#                #|#                  |                  #|
    |#                #|#                  |    Another       #|
    |#  You cant ever #|#   Really Dark    |   Really Dark    #|
    |#   get to this  #|#       Room       |      Room        #|
    |#     square     #|#                  |                  #|
    |#                #|#                  |                  #|
    |##################|########   ########|###################|
    |------------------|-------------------|-------------------|
    |##################|########   ########|###################|
    |#                #|#                 #|#                 #|
    |#                 |                  #|#                 #|
    |#                 |     Open Room     |      Moldy       #|
    |#     Empty Room #|#                  |        Room      #|
    |#                #|#                 #|#                 #|
    |#                #|#                 #|#                 #|
    |#                #|#######     #######|#                 #|
    |------------------|-------------------|-------------------|
    |#                #|#######[---]#######|#                 #|
    |#                #|#        Locked   #|#                 #|
    |#                #|#          Iron   #|#                 #|
    |#  Empty Room    #|#            Door #|#                 #|
    |#                #|#                 #|#       Oaken     #|
    |#                #|#    You are      #|#         Throne  #|
    |#                #|#      Here       #|#      [****]     #|
    |##################|###################|###################|
    |------------------|-------------------|-------------------|
    */
	//***************************************************************************
	//* SET UP THE GAME VARIABLES                                               *
	//***************************************************************************
	//COLUMN 0, ROW 0
	//There is no way into this room so everything is blank here...
	strcpy(text[0][0][0], "");
	strcpy(text[0][0][1], "");
	strcpy(text[0][0][2], "");
	strcpy(text[0][0][3], "");
	strcpy(text[0][0][4], "");
	//COLUMN 1, ROW 0
	strcpy(text[1][0][0], "This room is very dark. The floor here is wet and the air is cold.");
	strcpy(text[1][0][1], "You can not even see your fingers in front of your face.");
	strcpy(text[1][0][2], "");
	strcpy(text[1][0][3], "");
	strcpy(text[1][0][4], "");
	//there is an exit here but since its too dark to see, we didnt tell the
	//player about it. :)
	exit_e[1][0] = TRUE;
	exit_s[1][0] = TRUE;
	//COLOUM 2, ROW 0
	strcpy(text[2][0][0], "This room is just as dark as the last.");
	strcpy(text[2][0][1], "");
	strcpy(text[2][0][2], "");
	strcpy(text[2][0][3], "");
	strcpy(text[2][0][4], "");
	//I put some gold in this room. If the player searches, he will find it...
	exit_w[2][0] = TRUE;
	//COLOUM 0, ROW 1
	strcpy(text[0][1][0], "There is a large jagged hole in the ceiling here. You can see blue sky");
	strcpy(text[0][1][1], "above you. This room continues farther to the south. A stone archway");
	strcpy(text[0][1][2], "lies to the east.");
	strcpy(text[0][1][3], "");
	strcpy(text[0][1][4], "");
	exit_e[0][1] = TRUE;
	exit_s[0][1] = TRUE;
	//COLOUM 1, ROW 1 (MIDDLE OF OUR WORLD)
	strcpy(text[1][1][0], "You are in a large room. Tall grass grows through the cracks in the");
	strcpy(text[1][1][1], "flagstones. Sunlight shines through from a large section of the south");
	strcpy(text[1][1][2], "ceiling that has caved in. Three archways lead into darker sections of");
	strcpy(text[1][1][3], "the castle. One north, one west, and one east. An iron door stands");
	strcpy(text[1][1][4], "open to the south.");
	exit_e[1][1] = TRUE;
	exit_s[1][1] = TRUE;
	exit_n[1][1] = TRUE;
	exit_w[1][1] = TRUE;
	//COLOUM 2, ROW 1
	strcpy(text[2][1][0], "This room extends farther to the south. The smell of must and mildew");
	strcpy(text[2][1][1], "wafts from the floor as you disturb the air. Bones of small animals");
	strcpy(text[2][1][2], "crunch under your feet.");
	strcpy(text[2][1][3], "");
	strcpy(text[2][1][4], "");
	exit_w[2][1] = TRUE;
	exit_s[2][1] = TRUE;
	//COLOUM 0, ROW 2
	strcpy(text[0][2][0], "The only light here comes from farther north in the room.");
	strcpy(text[0][2][1], "");
	strcpy(text[0][2][2], "");
	strcpy(text[0][2][3], "");
	strcpy(text[0][2][4], "");
	exit_n[0][2] = TRUE;
	//COLUMN 1, ROW 2 (STARTING POINT)
	strcpy(text[1][2][0], "You are in a dimly lit stone walled room. Rocks and other rubble litters");
	strcpy(text[1][2][1], "the floor. The only light comes from a small crack in the ceiling. There");
	strcpy(text[1][2][2], "is a rusted iron door to the north.");
	strcpy(text[1][2][3], "");
	strcpy(text[1][2][4], "");
	//COLOUM 2, ROW 1
	strcpy(text[2][2][0], "The air here is unnaturally cold. An eerie blue light shines from the");
	strcpy(text[2][2][1], "southern wall. As you get closer you see the light comes from the skull");
	strcpy(text[2][2][2], "of a human skeleton seated upon a great oaken throne. He holds a razor");
	strcpy(text[2][2][3], "edged sword that glints in the light from his eye sockets.");
	strcpy(text[2][2][4], "");
	exit_n[2][2] = TRUE;
	//Set up the items in the game
	strcpy(item_name[0], "Iron Key");
	item_location_x[0] = 1;
	item_location_y[0] = 2;
	strcpy(item_name[1], "Book of FireBall");
	item_location_x[1] = 1;
	item_location_y[1] = 1;
	strcpy(item_name[2], "Bag of Gold");
	item_location_x[2] = 2;
	item_location_y[2] = 0;
	strcpy(item_name[3], "Whistle");
	item_location_x[3] = 0;
	item_location_y[3] = 1;
	//We're going to use this slot later
	strcpy(item_name[4], "");
	item_location_x[4] = -2; //We're going to say that -2 is NON-EXISTANT. This is better than
	item_location_y[4] = -2; //   the 0 we had before because 0 is a room... (-1 is the player)
	strcpy(item_name[5], "Book of PathFinder");
	item_location_x[5] = 0;
	item_location_y[5] = 2;
	//Display some basic information about the game commands
	printf("Type 'quit' to exit the game.\n");
	//***************************************************************************
	//* MAIN LOOP                                                               *
	//***************************************************************************
	command_accepted = 1; //So that the text is printed the first time around...
	//The program will now loop, catching input, printing text, and generally
	//doing everything that makes a game a game, until the user quits
	do
	{
		//Explaining printf: (Dont know if you know printf. If you do, sorry, ignore this.)
		//  -The %s tells printf that the variable (text[][][]) is to be displayed
		//   at this point. You use different "conversion-type" characters for different
		//   types of variables. %s is for a string, %d is for integers, etc...
		//  -The \n is like pressing ENTER. Without this the next printf would continue
		//   on the same line. Try removing it and watch what happens. \n\n would leave
		//   a blank line between each of your text lines. You get the picture...
		printf("\n\n");
		//If you try to walk in a direction you cannot: command_accepted is 2.
		//And if you typed in nonsense then it equals 0. Now the rooms text wont
		//re-print unless you actually move!
		//The results of the command_accepted variable are calculated at the
		//bottom of the do...loop.
		if (command_accepted == 1)
		{
			//print all the text for this room
			for(loop = 0; loop < 5; loop ++)
			{
				printf("%s\n", text[location_x][location_y][loop]);
			}
			//print any items IF the item has the same coordinates as the player
			for(loop = 0; loop < MAXITEMS; loop ++)
			{
				//If not in column 2, row2 (Because this room is too dark to see in...) You have
				//to search to find the items in this room
				if (item_location_x[loop] == location_x && item_location_y[loop] == location_y &&
					(location_x != 2 || location_y != 0))
						printf("There is a %s here...\n", item_name[loop]);
			}
			//Explaining what we just did:
			//  -We just printed out the text for the section of world that our character
			//   is standing in. This prints the info we set up in setup_game_variables()
			//   depending on where we are. If we move, we change our location and the loop
			//   will printf the text from there. This is why arrays are so important. You
			//   dont want to have to write out a whole set of printing commands for EVERY
			//   room in your world.
		}//end if
		//************************************************************************
		//* GET INPUT FROM USER                                                  *
		//************************************************************************
		gets(user_input);
		printf("\n\n");
		//************************************************************************
		//* EXECUTE THE INPUT (DO STUFF)                                         *
		//************************************************************************
		//We declare command_accepted = 0 now, and then under each command that is allowed
		//we declare command_accepted = 1. Then, at the end, we check it. If its equal to
		//0 then that means whatever the user typed, we didnt understand. So if this happens
		//we'll print something like: "I didnt understand that!"
		command_accepted = 0;
		//This checks to see if the player wishes to go NORTH
		//I used a few different things i thought a person might say. You may want to change
		//or add more. ... stricmp(char*,char*); is used to compare two strings. If the strings
		//are the same, it returns 0. So thats how it works. if (user_input == "north") ... basically
		if (stricmp(user_input, "north") == 0 ||
			stricmp(user_input, "n") == 0 ||
			stricmp(user_input, "go north") == 0 ||
			stricmp(user_input, "walk north") == 0)
		{
			//One of those commands did something so we remember this. Setting
			//this to 1 will tell us to print the room text again next loop.
			command_accepted = 1;
			if (exit_n[location_x][location_y])
				location_y --;
			else
				command_accepted = 2; //remember that we cant go that way
			//If we are in column 1, row 2 (starting position) and we try to walk forward, its
			//going to print this message. We've got to use the iron key first!
			if (location_x == 1 && location_y == 2)
			{
				printf("The door is locked!");
				//re-print the room description next time around
				command_accepted = 1;
			}
		}//END OF "GO NORTH"
		//Same deal but for south
		if (stricmp(user_input, "south") == 0 ||
			stricmp(user_input, "s") == 0 ||
			stricmp(user_input, "go south") == 0 ||
			stricmp(user_input, "walk south") == 0)
		{
			command_accepted = 1;
			if (exit_s[location_x][location_y])
				location_y ++;
			else
				command_accepted = 2;
		}//END OF "GO SOUTH"
		//Same deal but for east
		if (stricmp(user_input, "east") == 0 ||
			stricmp(user_input, "e") == 0 ||
			stricmp(user_input, "go east") == 0 ||
			stricmp(user_input, "walk east") == 0)
		{
			command_accepted = 1;
			//east and west change the x coord not the y, of course...
			if (exit_e[location_x][location_y])
				location_x ++;
			else
				command_accepted = 2;
		}//END OF "GO EAST"
		//Yup, you guessed it: west!
		if (stricmp(user_input, "west") == 0 ||
			stricmp(user_input, "w") == 0 ||
			stricmp(user_input, "go west") == 0 ||
			stricmp(user_input, "walk west") == 0)
		{
			command_accepted = 1;
			if (exit_w[location_x][location_y])
				location_x --;
			else
				command_accepted = 2;
		}//END OF "GO WEST"
		//************************************************************************
		//* GET ITEMS                                                            *
		//************************************************************************
		//This get items function is fairly complex. Possibly more complex than you need but I
		//like the feature so its here. Try typing in things like "get the iron key" and
		//"grab iron key from floor" etc... This is because the the string is searched for
		//the relative words ... get/grab/take and then the item iron key/whistle/etc... This
		//DOES mean you could type "get sdfjh iron key shdas" and that would get the key too...
		
		//Unfortunatly it gets a little complicated looking here... I'll try to explain...
		//strnicmp checks only a portion of user_input. x number of digits.
		//Otherwise it works the same as stricmp. Neither one is case sensitive.
		//Now we can check the rest of user_input against our items list...
		if (strnicmp(user_input, "get", 3) == 0 ||
			strnicmp(user_input, "grab", 4) == 0 ||
			strnicmp(user_input, "take", 4) == 0)
		{
			//scan through our list of items
			for(loop = 0; loop < MAXITEMS; loop ++)
			{
				//scan the string from 3 digits left up to 12
				for(in_loop = 3; in_loop < 12; in_loop ++)
				{
					//strnicmp compares a portion of the string (same as before) but here is start
					//comparing the string part way INTO the string...
					//strnicmp(&user_input[in_loop], item_name[loop], strlen(item_name[loop])
					//K... It compares item_name[loop] with user_input starting at [in_loop] bytes
					//into the string... &user_input[in_loop]. The strlen returns the length of a string.
					//Example:
					//Our item_name[0] is "iron key" which is 8 bytes long
					//Now lets say the user types in "get the iron key"
					//strnicmp starts checking user_input at the +3 byte ->
					//   "the iron key" and check the next strlen (8) characters for "iron key"
					//   Not finding this it moves up one byte... "he iron key" nope...
					//	  "e iron key", still no, " iron key", "iron key", AHA! Found it.
					if (strnicmp(&user_input[in_loop], item_name[loop], strlen(item_name[loop])) == 0 &&
						item_location_x[loop] == location_x && item_location_y[loop] == location_y)
					{
						item_location_x[loop] = -1; //Remember that -1 is your characters inventory...
						item_location_y[loop] = -1;
						printf("You get the %s.\n", item_name[loop]);
						if (loop == 2)
						{
							//if the item you get is the BAG OF GOLD then we should just put the
							//money straight into our "gold" variable
							gold += 35; //We're saying there's 35 gold in the bag... Any questions?
							//But we cant keep the BAG OF GOLD in our inventory AND in our purse...
							item_location_x[loop] = -2; //Kill Bag of Gold
							item_location_y[loop] = -2;
							strcpy(item_name[loop], "");
						}//end of if (loop == 2)
						if (loop == 4)
						{
							//if you get the sword of kings, you win! Thats the point of the demo
							printf("\nThe sword shines a glorious white light as you draw it from the floor.\n");
							printf("You now hold the key to defeat the evils that have plagued the land for many\n");
							printf("generations. The power to destroy the foul creatures that slew your brother\n");
							printf("is in you hand. You turn back with a look a vengeance in your eye...\n");
							getch();
							return 0; //finish, game over, the end
						}//end of if (loop == 4)
						command_accepted = 1;
					}//end of: if (user_input equals an item thats in the room) then pick it up
				}//end for
			}//end for
			//If it is not an item (or its not in the room) then say ...
			if (command_accepted != 1)
				printf("There is no such thing here.\n");
			command_accepted = 1;
		}//END OF "GET"
		//************************************************************************
		//* USE ITEMS                                                           *
		//************************************************************************
		if (strnicmp(user_input, "use", 3) == 0)
		{
			//scan through our list of items
			for(loop = 0; loop < MAXITEMS; loop ++)
			{
				//scan the string from 3 digits left up to 12
				for(in_loop = 3; in_loop < 12; in_loop ++)
				{
					if (strnicmp(&user_input[in_loop], item_name[loop], strlen(item_name[loop])) == 0 &&
						item_location_x[loop] == -1 && item_location_y[loop] == -1)
					{
						//---
						//USING THE IRON KEY
						//---
						if (loop == 0 &&		//if we're on the first item (item 0)
							location_x == 1 &&
							location_y == 2)
						{
							printf("You unlock the door!\n");
							exit_n[1][2] = 1; //Open the door! Allow exit to the north from here!
							command_accepted = 1;
						}//end of if (loop == 0)
						//---
						//USING THE BOOK OF FIREBALL
						//---
						if (loop == 1)
						{
							printf("You learn FireBall!\n");
							//Remember that we're inside another loop so we have to use in_loop here
							for(in_loop = 0; in_loop < 4; in_loop ++)
							{
								if (stricmp(spell[in_loop], "") == 0)
								{
									strcpy(spell[in_loop], "FireBall");
									//Exit the "for loop" so that ALL the blank slots dont get
									//filled up...
									break;
								}
							}
							//Just like we killed the BAG OF GOLD when we GET it, we have to kill
							//The BOOK OF FIREBALL when we use it. Otherwise it sticks around and
							//you could keep on learning the same spell.
							item_location_x[loop] = -2; //Kill Book
							item_location_y[loop] = -2;
							strcpy(item_name[loop], "");
							command_accepted = 3;
						}//end of if (loop == 1)
						//---
						//USING THE BOOK OF PATHFINDER
						//---
						if (loop == 5)
						{
							printf("You learn PathFinder!\n");
							for(in_loop = 0; in_loop < 4; in_loop ++)
							{
								if (stricmp(spell[in_loop], "") == 0)
								{
									strcpy(spell[in_loop], "PathFinder");
									//Exit the "for loop" so that ALL the blank slots dont get
									//filled up...
									break;
								}
							}
							item_location_x[loop] = -2; //Kill Book
							item_location_y[loop] = -2;
							strcpy(item_name[loop], "");
							command_accepted = 3;
						}//end of if (loop == 5)
						//---
						//USING THE WHISTLE
						//---
						if (loop == 3 &&
							location_x == 2 &&
							location_y == 2)
						{
							printf("The skeleton king begins to rattle violently!\n");
							printf("The light in his eyes shines brightly for a moment and goes out.\n");
							printf("His bones tremble and then crumble to dust. The sword falls to the floor...\n");
							//Now we cant very well have the same text for this room as we did before
							//so we'll have to change it...
							strcpy(text[2][2][0], "The air here is unnaturally cold. A pile of dust and bone slivers lies");
							strcpy(text[2][2][1], "on a great oaken throne.");
							strcpy(text[2][2][2], "");
							strcpy(text[2][2][3], "");
							strcpy(text[2][2][4], "");
							//Now we use that blank item slot. Now there is a sword on the floor!
							strcpy(item_name[4], "Sword of Kings");
							item_location_x[4] = 2;
							item_location_y[4] = 2;
							command_accepted = 1;
						}//end of if (loop == 3)
						//---
						//IF NOTHING WAS USED...
						//---
						if (command_accepted == 0)
						{
							printf("That does nothing!\n");
							command_accepted = 3;
						}
					}//end if
				}//end for
			}//end for
			//If it is not an item (or you dont have it) then say...
			if (command_accepted == 0)
				printf("You dont have that!\n");
			command_accepted = 3;
		}//END OF "USE"
		//************************************************************************
		//* DROP ITEMS                                                           *
		//************************************************************************
		if (strnicmp(user_input, "drop", 4) == 0)
		{
			//scan through our list of items
			for(loop = 0; loop < MAXITEMS; loop ++)
			{
				//scan the string from 3 digits left up to 12
				for(in_loop = 3; in_loop < 12; in_loop ++)
				{
					if (strnicmp(&user_input[in_loop], item_name[loop], strlen(item_name[loop])) == 0 &&
						item_location_x[loop] == -1 && item_location_y[loop] == -1)
					{
						item_location_x[loop] = location_x;
						item_location_y[loop] = location_y;
						printf("You drop your %s.\n", item_name[loop]);
						command_accepted = 1;
					}
				}
			}
			//If it is not an item (or you dont have it) then say...
			if (command_accepted != 1)
				printf("You dont have that!\n");
			command_accepted = 3;
		}//END OF "DROP"
		//************************************************************************
		//* CAST SPELLS                                                          *
		//************************************************************************
		if (strnicmp(user_input, "cast", 4) == 0)
		{
			//scan through our list of spells
			for(loop = 0; loop < 4; loop ++)
			{
				//If the part of user_input after "cast " is equal to one of the
				//spells found in spells[] then do...
				if (strnicmp(&user_input[5], spell[loop], strlen(spell[loop])) == 0)
				{
					//If the spell was FIREBALL then do this
					if (strnicmp(spell[loop], "FireBall", 8) == 0)
					{
						printf("\nA searing blast of fire streaks from your hand and explodes against a wall.\n");
						command_accepted = 3;
					}
					//If the spell was PATHFINDER then do this
					if (strnicmp(spell[loop], "Pathfinder", 8) == 0)
					{
						printf("\n");
						if (exit_n[location_x][location_y]) printf("There is an exit to the north.\n");
						if (exit_s[location_x][location_y]) printf("There is an exit to the south.\n");
						if (exit_e[location_x][location_y]) printf("There is an exit to the east.\n");
						if (exit_w[location_x][location_y]) printf("There is an exit to the west.\n");
						command_accepted = 3;
					}
				}//end of (if you have this spell) then use it
			}//end for
			if (command_accepted == 0)
			{
				printf("\nYou dont have that spell!\n");
				command_accepted = 3;
			}
		}//END OF "CAST"
		//************************************************************************
		//* SEARCH THE ROOM                                                      *
		//************************************************************************
		if (stricmp(user_input, "search") == 0 ||
			stricmp(user_input, "look") == 0)
		{
			for(loop = 0; loop < MAXITEMS; loop ++)
				if (item_location_x[loop] == location_x && item_location_y[loop] == location_y)
					printf("There is a %s here...\n", item_name[loop]);
			command_accepted = 3;
		}//END OF "SEARCH"
		//************************************************************************
		//* INVENTORY LIST                                                       *
		//************************************************************************
		if (stricmp(user_input, "inven") == 0 ||
			stricmp(user_input, "inventory") == 0)
		{
			printf("\nYou have:\n");
			printf("%d Gold Pieces\n", gold); //Display our money
			//scan through our list of items
			for(loop = 0; loop < MAXITEMS; loop ++)
			{
				if (item_location_x[loop] == -1 &&
					item_location_y[loop] == -1)
					printf("  - %s\n", item_name[loop]);
			}
			printf("\n");
			command_accepted = 3;
		}//END OF "INVEN"
		//************************************************************************
		//* SPELLS LIST                                                          *
		//************************************************************************
		//Works almost the same as in INVENTORY list but it checks spells[] not item_name[]
		if (stricmp(user_input, "spells") == 0)
		{
			printf("\nYour spells:\n");
			for(loop = 0; loop < 4; loop ++) //Scan through the spells (0-3)
			{
				printf("  - %s\n", spell[loop]);
			}
			printf("\n");
			command_accepted = 3;
		}//END OF "SPELLS"
		//************************************************************************
		//* A FEW VARIOUS COMMANDS                                               *
		//************************************************************************
		if (strnicmp(user_input, "yell", 4) == 0 ||
			strnicmp(user_input, "scream", 6) == 0)
		{
			printf("\nThrowing a tantrum isn't going to get you anywhere.\n");
			command_accepted = 3;
		}
		if (strnicmp(user_input, "jump", 4) == 0 ||
			strnicmp(user_input, "leap", 4) == 0 ||
			strnicmp(user_input, "hop", 3) == 0)
		{
			printf("\nYou're not a frog, you're a human. Do what humans do... Walk.\n");
			command_accepted = 3;
		}
		if (strnicmp(user_input, "smash", 5) == 0 ||
			strnicmp(user_input, "break", 5) == 0 ||
			strnicmp(user_input, "wreck", 5) == 0 ||
			strnicmp(user_input, "destroy", 7) == 0)
		{
			printf("\nWell aren't we feeling violent today! Your not going to do anything but hurt\n");
			printf("yourself if you keep that up.\n");
			command_accepted = 3;
		}
		if (strnicmp(user_input, "climb", 5) == 0)
		{
			printf("\nThere is nothing to climb here.\n");
			command_accepted = 3;
		}
		if (strnicmp(user_input, "eat", 3) == 0)
		{
			printf("\nYou are a little hungry but you'll have to wait until you get back to your\n");
			printf("village before you can do that. Theres nothing edible around here.\n");
			command_accepted = 3;
		}
		//if the user entered a command that is not a valid command, then command_accepted
		//will still be zero (as it was declared above). So do this:
		if (command_accepted == 0)	printf("\nPlease re-phrase your statement...\n");
		if (command_accepted == 2)	printf("\nYou cant go that way!\n");
	//END OF LOOP! IF THE INPUT ISNT "QUIT" THEN GO BACK UP TO THE TOP
	}while(stricmp(user_input, "quit") != 0);
	//Hello! The input must've equalled "QUIT" cus we're out here now... the end
	return 0;
}
