#pragma once

#include <windows.h>
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>

using namespace std;
using std::string;
using std::istringstream;

#include "C:\L\Avatars\Item.h"
#include "C:\L\Avatars\Skill.h"
#include "C:\L\Avatars\Spell.h"
#include "C:\L\Quest\Quest.h"
#define	_AvatarNameLength 32

//These enum's are meant for communication between Server and Client applications-----------//
//Leave them here so when the project migrates to a Networked version they are in place.	//
// - M. White 17 March, 2019																//
enum UserCommands																			//
{																							//
	PC_Move, PC_StopMoving,																	//
	PC_UseSkill, PC_AutoSkill,																//
	PC_TargetTableMem, PC_TargetLocalMob,													//
	PC_VoteForGuide, PC_ShowMeDaMoney, PC_GetMyTreasure,									//
	PC_ShowMeBackpack, PC_ShowMePouch, PC_ShowMeTrans,										//
	PC_ManInven, PC_DropItemOnMap,															//
	PC_ShowMeItemsWorn, PC_ShowMeMarket,													//
	PC_SellMarket, PC_BuyMarket, PC_MarketMessage,											//
	PC_InitTrade, PC_CancelTrade, PC_ShowItemTrade, PC_CompleteTrade,						//
	PC_ReadIt, PC_TookSeat, PC_RemoveASeat, PC_FindTables									//
};																							//
//------------------------------------------------------------------------------------------//
//This group of enum's describe the different locations on the Avatar that Items------------//
//can be assigned. Each slot is allowed to only have one of that particular Item			//
//assigned to it - M. White 17 March, 2019													//
enum EquipSlots																				//
{																							//
	Brow, Earrings, Pendant, Naval, Wrists, RingLeft, RingRight, Pants, Shirt,				//
	Leg_Armor, Waist_Armor, Belt, Shoes, Chest_Armor, Arms_Armor, Gloves,					//
	HandLeft, HandRight, //Hands have special purpose, are isolated like this as reminder	//
	Shoulder_Armor, Sash, Neck_Armor, Cloak, Backpack, Head_Armor,							//
	Transport, Pouch_01, Pouch_02, Pouch_03, Pouch_04, Pouch_05, Pouch_06,					//
	NUM_EQUIP_SLOTS																			//
};																							//
enum InterSlots																				//
{																							//
	intPou01 = NUM_EQUIP_SLOTS, intPou02, intPou03, intPou04, intPou05,						//
	intPou06, intBackpack, intTrans, NUM_TRAN_SLOTS											//
	//Pouchs 1 thr 6, Backpack, and a Type of Wagon (Wheelbarrel, cart, wagon, etc)			//
};																							//
//NOTE: Change the coins so that they take up slots in containers listed above...			//
// - M. White 17 March, 2019																//
enum CoinSlots																				//
{																							//
	PlatCoins = NUM_TRAN_SLOTS, GoldCoins, SilvCoins, CoppCoins								//
};																							//
//------------------------------------------------------------------------------------------//
//These enum's are particular to when a project is Networked and the Server is sending------//
//data down the pipe to modify data - M. White 17 March, 2019								//
enum LoadDataPhases																			//
{																							//
    Personal = 1, ClassAndXP, SkillsAndXP, Location, ItemsWorn, ItemsStored					//
};																							//
enum PVPStatuses { GreenPVP = 0, YellowPVP, RedPVP };										//
//------------------------------------------------------------------------------------------//
//These enum's describe the 'physical' actions an Avatar is currently active in doing-------//
//These values are referenced by the GamePaint() to know what graphics to use				//
// - M. White 17 March, 2019																//
enum AvatarStatus																			//
{																							//
	//No Tick or OffSet changes																//
	STAND_NORMAL = 0, STAND_STAFF, STAND_BOW, STAND_MOUNT, SIT_GROUND, SIT_OBJECT,			//
																							//
	//Has Tick changes only																	//
	CMBT_NORMAL, CMBT_STAFF, CMBT_BOW, HORSE_CMBT_NORMAL, STAND_CAST_SPELL,					//
																							//
	//Has Tick and OffSet changes															//
	WALK_NORMAL, WALK_CMBT_NORMAL, WALK_CMBT_STAFF, WALK_CMBT_BOW, CRAWLING, RUNNING		//
};																							//
enum Speeds { Running = 4, Walking = 8 };													//
//------------------------------------------------------------------------------------------//
#define	MAX_PLAYER_SKILLS	27
enum AvatarSex { MALE, FEMALE, MALEandFEMALE };
const int rNegOne = -1;
//The Mobiles (Mobs) use the same framework as Avatars so-----------------------------------//
//that they too have the same capabilities as the Players									//
//and possesing Items, Casting Spells, etc - M. White 17 March, 2019						//
enum MobList																				//
{																							//
	rNone,																					//
	// A																					//
	rAntelope,																				//
	// B																					//
	rBadger, rBanshee, rBasilisk, rBat, rBear, rBeaver, rBird, rBrownie, rBuffalo, rBugbear,//
	// C																					//
	rCat, rCattle, rCentaur, rChimera, rChipmunk, rCockatrice, rCrocodile,					//
	// D																					//
	rDog, rDolphin, rDragon, rDryad, rDwarf,												//
	// E																					//
	rElf, rErmine,																			//
	// F																					//
	rFerret, rFox,																			//
	// G																					//
	rGargoyle, rGenie, rGhost, rGhoul, rGiant, rGnome, rGoat, rGoblin, rGopher, rGorilla,	//
	rGremlin, rGriffon,																		//
	// H																					//
	rHag, rHalfElf, rHalfling, rHarpy, rHedgehog, rHobgoblin, rHorse, rHuman, rHydra,		//
	// I																					//
	rImp,																					//
	// J																					//
																							//
	// K																					//
																							//
	// L																					//
    rLeprechaun,																			//
	// M																					//
	rMermaid, rMink, rMinotaur, rMole, rMouse, rMummy, rMuskrat,							//
	// N																					//
	rNymph,																					//
	// O																					//
	rOctopus, rOgre, rOpossum, rOtter, rOtterSea,											//
	// P																					//
	rPhantom, rPhoenix, rPigDom, rPigWild, rPoltergeist, rPorcupine,						//
	// Q																					//
																							//
	// R																					//
	rRabbit, rRaccoon, rRat,																//
	// S																					//
	rScorpion, rSheep, rSiren, rSkeleton, rSkunk, rSnake, rSpectre, rSphinx, rSpider,		//
	rSprite, rSquid, rSquirrel, rSquirrelFly,												//
	// T																					//
	rTitan, rTroll,																			//
	// U																					//
	rUnicorn,																				//
	// V																					//
	rVampire,																				//
	// W																					//
	rWarthog, rWeasel, rWildBoar, rWildStag, rWillWisp, rWolverine, rWoodchuck, rWolf,		//
	rWraith,																				//
	// X																					//
																							//
	// Y																					//
	rYeti,																					//
	// Z																					//
	rZombie,																				//
																							//
	MAX_MOBS																				//
};																							//
//These enum's are used to access a Mob database (hard coded) to know the ranges of			//
//data to use to create them on the fly for random creation - M. White 17 March, 2019		//
enum MobDataIndexes																			//
{																							//
	MobLvl,																					//
	MobRStr,	MobBStr,	MobRDex,	MobBDex,	MobRCon,	MobBCon,					//
	MobRInt,	MobBInt,	MobRWis,	MobBWis,	MobRCha,	MobBCha,					//
	MobDmgValu,	MobCmbtLvl,	MobTrea,	MobXPVal,	MOBMAXDATA								//
};																							//
//------------------------------------------------------------------------------------------//
class Character
{
public:		
			Character		();		

	Character*	getThis		();
	const	Character&	operator=	(const Character &other);
	const	Character*	operator=	(const Character *other);
	bool				operator==	(const Character &other);
	void	Reset			();	
	void	setCreated		(bool data);
	bool	getCreated		() const;
//----------------------------------------------------------------------
//	Various Identification Functions
//----------------------------------------------------------------------
	void	setTitle		(int data);
	int		getTitle		() const;
	void	setStrFirstName	(string data);
	string	getStrFirstName	();
	void	setStrLastName	(string data);
	string	getStrLastName	();
	void	setID			(int data);
	int		getID			() const;

	void	setRace			(int i);
	int		getRace			() const;
	string	getRaceName		(int i) const;
	string	getRaceBaseID	() const;
	void	SERVsetRaceViaID(string iRace);
	void	setRaceViaID	(string ir);
//----------------------------------------------------------------------
//	Sex and Weight
//----------------------------------------------------------------------
	void	setSex			(int data); 
	int		getSex			() const;
	void	setHeight		(int data);
	int		getHeight		() const;
	void	setWeight		(int data);
	int		getWeight		() const;
//----------------------------------------------------------------------
//	Statistics
//----------------------------------------------------------------------
	void	setStr			(int data);
	int		getStr			() const;
	void	setDex			(int data);
	int		getDex			() const;
	void	setCon			(int data);
	int		getCon			() const;
	void	setInt			(int data);
	int		getInt			() const;
	void	setWis			(int data);
	int		getWis			() const;
	void	setCha			(int data);
	int		getCha			() const;
	void	setCom			(int data);
	int		getCom			() const;

	void	setTStr			(int i);
	int		getTStr			() const;
	void	setTDex			(int i);
	int		getTDex			() const;
	void	setTCon			(int i);
	int		getTCon			() const;
	void	setTInt			(int i);
	int		getTInt			() const;
	void	setTWis			(int i);
	int		getTWis			() const;
	void	setTCha			(int i);
	int		getTCha			() const;

	void	setHealth		(int data);
	int		getHealth		() const;
	void	setCurHealth	(int data);
	int		getCurHealth	() const;
//----------------------------------------------------------------------
//	Profession Information
//----------------------------------------------------------------------
	void	setClass		(int data);
	int		getClass		() const;
	int		getLevel		() const;
	void	setLevel		(int i);
//----------------------------------------------------------------------
//	Items Worn Information
//----------------------------------------------------------------------
	void	setItemsWorn	(int I, int nI);
	int		getItemWorn		(int Index);
	void	setCountItemW	(int Index, int Quantity);
	int		getCountItemW	(int Index) const;
	int		getCountRHand	();
	int		getCountLHand	();
	void	setCountRHand	(int d);
	void	setCountLHand	(int d);

	void	setItemsBP		(string data);
	void	setItemBP		(int index, int what, int quant);
	bool	addItem_BP		(int what, int num);
	int		getItem_BP		(int index);
	int		getAmount_BP	(int index);
	void	setAmount_BP	(int index, int quant);
	void	deleteItemBP	(int i);

	void	setItemsTra		(string data);
	void	setItemTra		(int index, int what, int quant);
	bool	addItem_Tra		(int what, int num);
	int		getItem_Tra		(int index);
	int		getAmount_Tra	(int index);
	void	setAmount_Tra	(int index, int quant);
	void	deleteItemTr	(int i);

	void	setItemsPou		(int index, string data);
	void	setItemPou		(int which, int index, int what, int quant);
	bool	addItem_Pou		(int which, int what, int num);
	int		getItem_Pou		(int which, int index);
	int		getAmount_Pou	(int which, int index);
	void	setAmount_Pou	(int which, int index, int quant);
	void	deleteItemPo	(int which, int i);

//----------------------------------------------------------------------
//	Location Information
//----------------------------------------------------------------------
	void	setX			(int data);
	int		getX			() const;
	void	setY			(int data);
	int		getY			() const;
	void	setZ			(int data);
	int		getZ			() const;
	void	setCoordinates	(int x, int y, int z);
	void	setWorldMax		(int x, int y, int z);
	void	setFacing		(int data);		
	void	changeFacing	(int data);
	int		getDirection	() const;
	void	CliMoveToCoord	();
	void	setSpeed		(int data);
	int		getSpeed		() const;
	void	setRunTimer		(int data);
	int		getRunTimer		() const;
	void	setCurRunTimer	(int data);
	int		getCurRunTimer	() const;
	bool	getMoving		() const;
	void	setMoving		(bool data);
	int		getOffSetX		() const;
	int		getOffSetY		() const;
	void	setOffsAuto		();
	void	incrementTick	();
	void	setTicks		(int data);
	int		getTicks		() const;
//----------------------------------------------------------------------
// Pictures
//----------------------------------------------------------------------
	void	setPort			(int data);
	int		getPort			() const;
//----------------------------------------------------------------------
// Skills
//----------------------------------------------------------------------
	void	setSkill		(int in, int What);
	void	setXP			(int in, int newData);
	void	setXPClient		(int in, int newData);
	void	setNumSkills	(int Num);
	void	setSkillTimer	(int index, int data);
	void	setUsingSkill	(bool data);
	void	assignSkillLevel();

	int		getSkill		(int i);
	int		getSkillXP		(int i);
	void	setMobSkillLvl	(int lvl);
	int		getSkillLevel	(int i);
	int		getNumSkills	() const;
	int		getXPNextLvl	(int i);
	int		getXPPercent	(int i);
	int		getSkillTimer	(int i);
	bool	getUsingSkill	() const;
	void	setRepeatSkill	(bool a);
	bool	getRepeatSkill	() const;

	bool	addSkill		(int nSkill);
	bool	deleteSkill		(int nSkill);
	void	resetSkills		();
	void	adjustSkillXP	(int index, int amount);
	void	useSkill		(int index);
	void	setLastSkillL	(int i);
	void	setLastSkillR	(int i);
	int		getLastSkillL	() const;
	int		getLastSkillR	() const;

	int		getSkillAssoc	(int index);
	int		getSkillRef		(int index);

	string	getReadibleSkill(int i);
	string	getReadSkillByCount(int i);
	string	getSkillStrID	(int i);
//----------------------------------------------------------------------
// Setting Status Variables
//----------------------------------------------------------------------
	void	setPVP			(int data);
	int		getPVP			() const;
	void	setStanding		(bool data);
	bool	getStanding		() const;
	void	setWarMode		(bool data);
	bool	getWarMode		() const;
	void	setMounted		(int data);
	int		getMounted		() const;
	void	setStatus		(int data);
	int		getStatus		() const;
	void	setOldStatus	(int data);
	int		getOldStatus	() const;
	void	setNPCMode		(bool data);
	bool	getNPCMode		() const;
	void	ManageSelf		();
	void	ServManageSelf	();
//----------------------------------------------------------------------
// Chat Colors
//----------------------------------------------------------------------
	void	setRed			(int data);
	void	setGreen		(int data);
	void	setBlue			(int data);
	int		getRed			() const;
	int		getGre			() const;
	int		getBlu			() const;
//----------------------------------------------------------------------
// Targeting
//----------------------------------------------------------------------
	void	setTargetOcc	(Character *t);
	Character*	getTargetOcc();
	void	setTargetItem	(Item *t);
	Item*	getTargetItem	();

	void	setTargetWMX	(int t);
	int		getTargetWMX	() const;
	void	setTargetWMY	(int t);
	int		getTargetWMY	() const;
	void	setTargetAni	(int t);
	int		getTargetAni	() const;
	void	setTargetType	(int t);
	int		getTargetType	() const;
	void	setSimpleTarget	(int i);
	int		getSimpleTarget	() const;

	void	CheckSelf		();

	void	setPlat			(int amount);
	int		getPlat			();
	void	setGold			(int amount);
	int		getGold			();
	void	setSilv			(int amount);
	int		getSilv			();
	void	setCopp			(int amount);
	int		getCopp			();

	void	setNumSRs		(int data);
	int		getNumSRs		() const;
	int		getStatRollB	() const;

private:
	Item	Body[NUM_EQUIP_SLOTS];	// 31

	//These reflect what is in Either Transport, Backpack, 
	//or the six Pouches (not actual containers).
	Item	mTransport[28];	// 28, 24, 20, 16, 14
	Item	mBackPack[12];	// 12, 10, 8
	Item	mPouches[6][6];	// 2, 4, 6
	Item	mCoinPurse[4];	// Platinum, Gold, Silver, Copper

	char	chrFirstName[_AvatarNameLength];
	char	chrLastName[_AvatarNameLength];
	int		ID;

	Skill		Skills[MAX_PLAYER_SKILLS];
	int			NumSkills, LastSkillLeft, LastSkillRight, Level;//Level is the average of the levels of the skills

	int			X, Y, Z, facing, MyOffSetX, MyOffSetY, Tick, Speed, Mounted;
	int			RunTimer, CurRunTimer;
	int			maxX, maxY, maxZ;
	
	int			Title;//Duke, Baron, etc...
	int			Race, Sex, PortNumber, Height, Weight, Class;				
	int			BirthDay, BirthMonth, BirthYear, Age;
	
	int			Str, Dex, Con, Int, Wis, Cha, Com;
	int			tStr, tDex, tCon, tInt, tWis, tCha, tCom;
	int			Health, CurrentHealth;
	
	int			PVP_Status;
	int 		Status, OldStatus;			
	int 		textRed, textGreen, textBlue;	

	//Targeting stuff--------------
	Character*	TargetOccupant;
	Item*		TargetItem;
	int			TargetWMX;
	int			TargetWMY;
	int			TargetAnimate;
	int			TargetType;

	//This target is for mobs to attack a chair at a table...
	//Or an index in the Customers.
	int			SimpleTarget;
	//-----------------------------

	bool		NPC_Mode;
	bool		Moving;
	bool		WarMode;
	bool		Standing;
	bool		CastingSpell;
	bool		Created;
	bool		SittingTable;
	bool		UsingSkill;
	bool		RepeatSkill;
	string		transferString;

	//Used to compare how many times is "tolerable" for rolling dice - M. White 7 April, 2019
	//See assignment method for further details...
	int			numStatRolls;
	//Making this an integer for each of display in sprintf()...
	//Actual calculation will involve division by 100 to get percentage - M. White 7 April, 2019
	int			intXP_BonusMod;
	double		dblXP_BonusMod;
};