/*
 *** TXTGAME3.CPP ***
 VERSION 3.0 OF TEXTGAME
 Written by lightatdawn
 This a completly new edition. This version show a whole bunch of new concepts
 that will be neccessary for a larger world and more complicated applications.
 Since there will be a whole lot more stuff i'll be removing some old comments,
 so make sure you understand everything from the previous versions before tackling
 this one.
 ADDITIONS from version 2:
 -Structs to contain and organise all our map data
 -Loading of World maps from file
 -Saving and Loading of Game
 -A couple of minor additions, touchups, changes
*/
//******************************************************************************
//* INCLUDE FILES                                                              *
//******************************************************************************
#include <windows.h> //this is new and used for type 'BOOL'
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
#define MAXITEMS 6 //Maximum items allowed
//These are our defines for how big we want our map to be
//Its becoming important to remember the exact size now so if we ever want to
//change it we'll just do it here instead of searching our code for all times
//when we use it
#define MAP_WIDTH 3
#define MAP_HEIGHT 3
//*** This is our 'World' struct ***
//1) This will make it easier to easily recognise our world data and keep it
//		separate from any other data.
//2) structs are accessed just as easily as any other variables:
//		'StructName.VarName' instead of 'VarName'.
//3) We're making this struct a 3x3 array. This is easier and more intuitive
//		than having all the variables contained in it as arrays. This means it
//		will be accessed a little differently: 'StructName[x][y].VarName'.
struct
{
	char text[5][100];
	//Variables of type 'BOOL' may be either 'TRUE' or 'FALSE'
	BOOL
		exit_n,
		exit_s,
		exit_e,
		exit_w;
} World[MAP_WIDTH][MAP_HEIGHT];
//*** This is our 'Character' struct ***
//This struct will hold all of our data pertaining to the player
struct
{
	int location_x,
		location_y,
		gold;
	char
		spell[4][30]; //changed from pointer to multi-dimensional array
} Character;
//*** This is our 'Game' struct ***
//This struct will hold all of our data pertaining to game play
struct
{
	//This struct in turn holds the item struct which contains all the item data
	//for each item in the game. There are '[MAXITEM]' items in the game and thus
	//we give ourselves '[MAXITEM]' elements of our array. One per item.
	struct
	{
		char name[30];
		int location_x,
			location_y;
	} Item[MAXITEMS];
} Game;
//******************************************************************************
//* MAIN PROCEDURE                                                             *
//******************************************************************************
int main(void)
{
	//***************************************************************************
	//* MISCLANIOUS VARIABLE DECLARATION                                        *
	//***************************************************************************
	FILE * fp; //our file pointer for loading files
	int
		command_accepted = 0,
		loop = 0,
		in_loop = 0;
	char
		user_input[30],
		linebuf[100];
	//MAP OF THE WORLD
	//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 VARIABLES                                                    *
	//***************************************************************************
	//Right. Heres where it gets different. We're going to load up our World from
	//a file now instead of just hard coding it as we had done before. We're going
	//to have to set up some sort of basic script for reading our file first.
	//Our file MUST be set up in this format and may repeat indefinatly until
   //the NewSegmentTag is set to "-EOF-" (End Of File)
	/*
	NewSegementTag			<--- Tells us about what we're about to read
	World Description Lines	<--- We may have any number of these from 0-5
	End Of Segment Tag		<--- "-DoneText-" tells us to stop reading description lines
								 "-EOF-" tells us the script is done
	Exits Tags				<--- In the form of "EXITS: xxxx" where 'xxxx' is any
								 combination of N, S, W, or E.
	*/
	//****************************************************************************
	//IMPORTANT: Make sure you have downloaded 'TextData.Map' as well as this file
	//			 or this isn't going to work.
	//****************************************************************************
	//NOTE: Also you can download a small application on the same page you found
	//		this (lightatdawn.cprogramming.com). It demonstrates a simple way to
	//		create a MAP file in the format used here without much effort on your
	//		part. Its useful for creating a default MAP template of your world
	//		without having to do one hell of a lot of typing. Check it out.
	//****************************************************************************
	if ((fp = fopen("TEXTDATA.MAP", "r")) != NULL)
	{
		//this will hold our tag for our description of what we're about to read
		char NewSegmentTag[100];
		//This will keep track of what x and y we're loading currently
		//We start at the tope left and read across then down a line just like a book
		int
			x = 0,
			y = 0;
		//*******************************************************************
		//We're going to read this file until we reach the tag ("-EOF-") that
		//tells us we're finished reading. We will also stop reading if we've
		//filled up all of our rooms with data.
		//*******************************************************************
		do
		{
			//1) Load NewSegmentTag from the file.
			//2) Keep loading lines until we reach a line that has something on it.
			//3) This allows up to put spaces between our room descriptions if we want
			//   and it will still load fine. This will help keep our MAP file organised.
			do
			{
				fgets(NewSegmentTag, sizeof(NewSegmentTag), fp);
			}while(strncmp(NewSegmentTag, "\n", 1) == 0);
			//only proceed with loading a room description if this isn't the End of File
			if (strncmp(NewSegmentTag, "-EOF-", 5) != 0)
			{
				//do this loop until we get the command to stop reading lines
				loop = 0;
				do
				{
					//load a line from the file
					fgets(linebuf, sizeof(linebuf), fp);
					//if the line is a room description line then load it into our
					//World[][].text[] variable that will hold that data
					//ONLY do this if we havent exceeded our limit for description lines (5)
					if (strncmp(linebuf, "-DoneText-", 10) != 0 && loop < 5)
					{
						strcpy(World[x][y].text[loop], linebuf);
						loop ++; //proceed to next element of World[][].text
					}
				}while (strncmp(linebuf, "-DoneText-", 10) != 0);
				//load the EXITS line
				//The line we load here should look like "EXITS: xxxx"
				fgets(linebuf, sizeof(linebuf), fp);
				//default value for exits in all directions is FALSE (none)
				World[x][y].exit_n = FALSE;
				World[x][y].exit_s = FALSE;
				World[x][y].exit_w = FALSE;
				World[x][y].exit_e = FALSE;
				//only if theres at least 8 characters is there an exit to this room
				//since "EXITS: " is 7 characters all by itself.
				loop = 0;
				do
				{
					if ( strlen(linebuf) > unsigned int(8 + loop) )
					{
						//if we're reading in a 'N'
						if (linebuf[7 + loop] == 'N')
							World[x][y].exit_n = TRUE;
						//if we're reading in a 'S'
						if (linebuf[7 + loop] == 'S')
							World[x][y].exit_s = TRUE;
						//if we're reading in a 'W'
						if (linebuf[7 + loop] == 'W')
							World[x][y].exit_w = TRUE;
						//if we're reading in a 'E'
						if (linebuf[7 + loop] == 'E')
							World[x][y].exit_e = TRUE;
					}
					loop ++;
				}while(loop < 4 );
				//move to the next square
				x ++;
				if (x >= MAP_WIDTH)
				{
					y ++;
					x = 0;
				}
			}//end if (!EOF)
		}while (strncmp(NewSegmentTag, "-EOF-", 5) != 0 && y < MAP_HEIGHT);
		fclose(fp);
	}
	else
	{
		printf("\nLoad failed.\n");
		printf("Make sure that you have downloaded the TextData.MAP file\n");
		printf("from lightatdawn.cprogramming.com and that you have\n");
		printf("placed the file in the same directory as this file.\n");
		return -1; //exit the program cuz we've got an error we cant recover from
	}
	//Items are loaded the same as always. Alternatly you could use a system simular
	//to the one used to load the world descriptions to load up Items. I'm too lazy
	//to implement it right now but it wouldnt be hard once you understand whats
	//happening in the World loading script
	strcpy(Game.Item[0].name, "Iron Key");
	Game.Item[0].location_x = 1;
	Game.Item[0].location_y = 2;
	strcpy(Game.Item[1].name, "Book of FireBall");
	Game.Item[1].location_x = 1;
	Game.Item[1].location_y = 1;
	strcpy(Game.Item[2].name, "Bag of Gold");
	Game.Item[2].location_x = 2;
	Game.Item[2].location_y = 0;
	strcpy(Game.Item[3].name, "Whistle");
	Game.Item[3].location_x = 0;
	Game.Item[3].location_y = 1;
	//We're going to use this slot later
	strcpy(Game.Item[4].name, "");
	Game.Item[4].location_x = -2; //We're going to say that -2 is NON-EXISTANT. This is better than
	Game.Item[4].location_y = -2; //   the 0 we had before because 0 is a room... (-1 is the player)
	strcpy(Game.Item[5].name, "Book of PathFinder");
	Game.Item[5].location_x = 0;
	Game.Item[5].location_y = 2;
	//*** set up the character data ***
	Character.location_x = 1,
	Character.location_y = 2,
	Character.gold = 20;
	for(loop = 0; loop < 4; loop ++)
		strcpy(Character.spell[loop], "");
	//***************************************************************************
	//* MAIN LOOP                                                               *
	//***************************************************************************
	command_accepted = 1; //So that the text is printed the first time around...
	do
	{
		printf("\n\n");
		//If you try to walk in a direction you cannot: command_accepted is declared = 2;
		//And if you typed in nonsense then it = 0; Now the rooms text wont re-print unless
		//you actually move!
		if (command_accepted == 1)
		{
			//Notice that we no longer want the newline character '\n' anymore
			//as the newline is loaded from the MAP file already.
			for(loop = 0; loop < 5; loop ++)
				printf("%s", World[Character.location_x][Character.location_y].text[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 (Game.Item[loop].location_x == Character.location_x && Game.Item[loop].location_y == Character.location_y &&
					(Character.location_x != 2 || Character.location_y != 0))
						printf("There is a %s here...\n", Game.Item[loop].name);
		}//end if
		//************************************************************************
		//* GET INPUT FROM USER                                                  *
		//************************************************************************
		gets(user_input);
		printf("\n\n");
		//************************************************************************
		//* EXECUTE THE INPUT (DO STUFF)                                         *
		//************************************************************************
		command_accepted = 0;
		//This checks to see if the player wishes to go NORTH
		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 (World[Character.location_x][Character.location_y].exit_n)
				Character.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 (Character.location_x == 1 && Character.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 (World[Character.location_x][Character.location_y].exit_s)
				Character.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 (World[Character.location_x][Character.location_y].exit_e)
				Character.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 (World[Character.location_x][Character.location_y].exit_w)
				Character.location_x --;
			else
				command_accepted = 2;
		}//END OF "GO WEST"
		//************************************************************************
		//* GET ITEMS                                                            *
		//************************************************************************
		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 ++)
				{
					if (strnicmp(&user_input[in_loop], Game.Item[loop].name, strlen(Game.Item[loop].name)) == 0 &&
						Game.Item[loop].location_x == Character.location_x && Game.Item[loop].location_y == Character.location_y)
					{
						Game.Item[loop].location_x = -1; //Remember that -1 is your characters inventory...
						Game.Item[loop].location_y = -1;
						printf("You get the %s.\n", Game.Item[loop].name);
						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
							Character.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...
							Game.Item[loop].location_x = -2; //Kill Bag of Gold
							Game.Item[loop].location_y = -2;
							strcpy(Game.Item[loop].name, "");
						}//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)
		{
			for(loop = 0; loop < MAXITEMS; loop ++) //scan through our list of items
			{
				for(in_loop = 3; in_loop < 12; in_loop ++) //scan the string from 3 digits left up to 12
				{
					if (strnicmp(&user_input[in_loop], Game.Item[loop].name, strlen(Game.Item[loop].name)) == 0 &&
						Game.Item[loop].location_x == -1 && Game.Item[loop].location_y == -1)
					{
						//---
						//USING THE IRON KEY
						//---
						if (loop == 0 && Character.location_x == 1 && Character.location_y == 2)
						{
							printf("You unlock the door!\n");
							World[1][2].exit_n = TRUE; //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(Character.spell[in_loop], "") == 0)
								{
									strcpy(Character.spell[in_loop], "FireBall");
									break; //Exits the "for loop" so that ALL the blank slots dont get
											 //filled up...
								}
							}//end for
							//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.
							Game.Item[loop].location_x = -2; //Kill Book
							Game.Item[loop].location_y = -2;
							strcpy(Game.Item[loop].name, "");
							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(Character.spell[in_loop], "") == 0)
								{
									strcpy(Character.spell[in_loop], "PathFinder");
									//Exits the loop so ALL the blank slots dont get filled
									break;
								}
							}//end for
							Game.Item[loop].location_x = -2; //Kill Book
							Game.Item[loop].location_y = -2;
							strcpy(Game.Item[loop].name, "");
							command_accepted = 3;
						}//end of if (loop == 5)
						//---
						//USING THE WHISTLE
						//---
						if (loop == 3 &&
							Character.location_x == 2 &&
							Character.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(World[2][2].text[0], "The air here is unnaturally cold. A pile of dust and bone slivers lies");
							strcpy(World[2][2].text[1], "on a great oaken throne.");
							strcpy(World[2][2].text[2], "");
							strcpy(World[2][2].text[3], "");
							strcpy(World[2][2].text[4], "");
							//Now we use that blank item slot. Now there is a sword on the floor!
							strcpy(Game.Item[4].name, "Sword of Kings");
							Game.Item[4].location_x = 2;
							Game.Item[4].location_y = 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 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], Game.Item[loop].name, strlen(Game.Item[loop].name)) == 0 &&
						Game.Item[loop].location_x == -1 && Game.Item[loop].location_y == -1)
					{
						Game.Item[loop].location_x = Character.location_x;
						Game.Item[loop].location_y = Character.location_y;
						printf("You drop your %s.\n", Game.Item[loop].name);
						command_accepted = 1;
					}
				}//end for
			}//end for
			//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], Character.spell[loop], strlen(Character.spell[loop])) == 0)
				{
					//If the spell was FIREBALL then do this
					if (strnicmp(Character.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(Character.spell[loop], "Pathfinder", 8) == 0)
					{
						printf("\n");
						if (World[Character.location_x][Character.location_y].exit_n) printf("There is an exit to the north.\n");
						if (World[Character.location_x][Character.location_y].exit_s) printf("There is an exit to the south.\n");
						if (World[Character.location_x][Character.location_y].exit_e) printf("There is an exit to the east.\n");
						if (World[Character.location_x][Character.location_y].exit_w) 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)
		{
			//This is to tell us whether we found anything in this room so we can
			//display a message after if we found nothing
			BOOL FoundSomething = FALSE;
			for(loop = 0; loop < MAXITEMS; loop ++)
			{
				if (Game.Item[loop].location_x == Character.location_x && Game.Item[loop].location_y == Character.location_y)
				{
					printf("There is a %s here...\n", Game.Item[loop].name);
					//Tell us that an item was found in this room
					FoundSomething = TRUE;
				}
			}//end for
			//If we didnt find anything then display this message
			if (!FoundSomething)
				printf("There is nothing here.\n");
			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", Character.gold); //Display our money
			for(loop = 0; loop < MAXITEMS; loop ++) //scan through our list of items
			{
				if (Game.Item[loop].location_x == -1 && Game.Item[loop].location_y == -1)
					printf("  - %s\n", Game.Item[loop].name);
			}//end for
			printf("\n");
			command_accepted = 3;
		}//END OF "INVEN"
		//************************************************************************
		//* SPELLS LIST                                                          *
		//************************************************************************
		//Works almost the same as in INVENTORY list but it checks spells[] not Game.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", Character.spell[loop]);
			}//end for
			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;
		}
		//************************************************************************
		//* SAVE THE GAME                                                        *
		//************************************************************************
		if (stricmp(user_input, "save") == 0)
		{
			//we want to open our file for write and in binary
			fp = fopen("SAVEGAME.BIN", "wb");
			
			if (fp != NULL)
			{
				//Now we just write all of our relevant data to the file "SAVEGAME.BIN"
				//that we just opened for binary write. This is where its great that we
				//have all our data in structs because now we have just three lines of
				//to write all our information. Without such a system we would have had
				//to write each variable individually. That would suck.
				fwrite(&Character, sizeof(Character), 1, fp);
				fwrite(&Game, sizeof(Game), 1, fp);
				fwrite(&World, sizeof(World), 1, fp);
				fclose(fp);
			}
			else
				printf("\nError writing to file!\nGame not saved!\n");
			command_accepted = 1;
		}
		//************************************************************************
		//* LOAD THE GAME                                                        *
		//************************************************************************
		if (stricmp(user_input, "load") == 0)
		{
			fp = fopen("SAVEGAME.BIN", "rb");
			if (fp != NULL)
			{
				fread(&Character, sizeof(Character), 1, fp);
				fread(&Game, sizeof(Game), 1, fp);
				fread(&World, sizeof(World), 1, fp);
				fclose(fp);
			}
			else
				printf("\nError loaded to file!\nGame not loaded!\n");
			command_accepted = 1;
		}
		//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:
		//We now check here to see if the user typed QUIT so now we dont get that
		//"Please re-phrase your statement..." when we quit that we did before
		if (command_accepted == 0 && stricmp(user_input, "quit") != 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;
}