//We use #pragma once to tell the compiler that we onlt want this
//header compiled once and not every time it is included in something
//We do this because the CGame header includes both this header and the
//CWorld header. When they are included in TextGame4.CPP we would
//be recompiling them and this would cause class type redefinition
//errors. Errors are bad.
#pragma once
#include <windows.h>
//We need to include CWorld.h so that some of our functions that
//take the World class as a parameter know what they're accepting
//This is another reason we need #pragma once
#include "CWorld.h"
//NOTE: Go away and read CWorld.h first if you dont understand classes
//		or anything else I'm talking about.
//*** This is our 'CCharacter' class ***
//This class will hold all of our data pertaining to the player
class CCharacter
{
public:
	CCharacter()
	{
		//Our character data is set up by the constructor which
		//we never need to call. This all happens when the instance
		//of CCharacter is created.
		location_x = 1,
		location_y = 2,
		gold = 20;
		for(int loop = 0; loop < 4; loop ++)
			strcpy(spell[loop], "");
	};
	~CCharacter()
	{
		//No need.
	};
	//************************************************************
	//This function checks what the user typed and casts a spell
	//************************************************************
	HRESULT CastSpell(char user_input[30], CWorld * pWorld)
	{
		int command = 0;
		//scan through our list of spells
		for(int 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 = 3;
				}
				//If the spell was PATHFINDER then do this
				if (strnicmp(spell[loop], "Pathfinder", 8) == 0)
				{
					printf("\n");
					//We're using those NORTH, SOUTH, EAST, WEST defines again
					if (pWorld->IsExit(location_x, location_y, NORTH)) printf("There is an exit to the north.\n");
					if (pWorld->IsExit(location_x, location_y, SOUTH)) printf("There is an exit to the south.\n");
					if (pWorld->IsExit(location_x, location_y, EAST)) printf("There is an exit to the east.\n");
					if (pWorld->IsExit(location_x, location_y, WEST)) printf("There is an exit to the west.\n");
					command = 3;
				}
			}//end of (if you have this spell) then use it
		}//end for
		if (command == 0)
			printf("\nYou dont have that spell!\n");
		return S_OK;
	};
	//************************************************************
	//This function displays the players spells
	//************************************************************
	HRESULT SpellList()
	{
		printf("\nYour spells:\n");
		for(int loop = 0; loop < 4; loop ++)
		{
			printf("  - %s\n", spell[loop]);
		}//end for
		printf("\n");
		return S_OK;
	};
	//************************************************************
	//This function learns a spell
	//************************************************************
	HRESULT LearnSpell(char * ThisSpell)
	{
		for(int loop = 0; loop < 4; loop ++)
		{
			if (stricmp(spell[loop], "") == 0)
			{
				printf("You learn %s!\n", ThisSpell);
				strcpy(spell[loop], ThisSpell);
				break;
			}
		}//end for
		return S_OK;
	};
	//These things remain public as they are needed often by
	//the main() and it would be silly to wrap them up with
	//handling stubs.
	int location_x,
		location_y,
		gold;
private:
	char spell[4][30];
};
