#ifndef CLIENT_H
#define CLIENT_H
//Client.h
//#include "characterList.h"
#include <string>
using std::string;

class Client
{
		//private:
	public:
		int Id;
		string username;
		string password;
		string client;
		Character CharacterObject;
		bool logedOn;
		int socket;
		//Ip adress
		Client();
		void fromString();
		string toString();
		string Get_username();
		void Set_Client(string);
		string Get_password();
		//bool logon();
		void Set_username(string);
	
		void Set_password(string);

	
};

Client::Client()
{
	Id= 1;
	username = "";
	password = "";
	client = "";
	logedOn = false;
}
string Client::Get_username()
{
	return username;
}
	
string Client::Get_password()
{
	return password;
}
		
void Client::Set_username(string u)
{
	username = u;
}
	
void Client::Set_password(string p)
{
	password = p;
}
void Client::Set_Client(string ch )
{
	client = ch;
}

void Client::fromString()
{	
	int j= 0;
	int i = 0;
//maybey i acn make the conver for sring to char* right in here
	string temps[22]; //arry to hold data
	
	while (client[i]!= '`') //stay in untl you fing the ` at the end
	{
		if (client[i] != ',')//if found , dont add it to the data and move on to next char
		{
			temps[j] += client[i]; //add char to temp spot
			i++;
		}
		else
		{
			i++;
			j++;
		}

	}
username =temps[0];
password =temps[1];
CharacterObject.type=StringToNumber(temps[2]);
	CharacterObject.Set_name(temps[3]) ;
	//race = temps[4];
//sex = temps[5];
	//npcs.insert("ghgh,dfhg,hjh,2060,1594,32,32,3,32,32,0,1,6,4,1,5`");
	CharacterObject.Set_X (StringToNumber(temps[6]));  //move data from temp holder 

	CharacterObject.Set_Y( StringToNumber(temps[7]));
	
	CharacterObject.Set_W(StringToNumber(temps[8]));
	
	CharacterObject.Set_H(StringToNumber(temps[9]));
	
	CharacterObject.Set_layer(StringToNumber(temps[10]));
	
	CharacterObject.Set_source_X(StringToNumber(temps[11]));

	CharacterObject.Set_source_Y ( StringToNumber(temps[12]));
	 //bool collision= StringToNumber(temps[13]);
	
	CharacterObject.Set_frame (StringToNumber(temps[14]));
	CharacterObject.Set_direction(StringToNumber(temps[15]));
	
	CharacterObject.Set_sourcebitmap(StringToNumber(temps[16]));
	
	//dest= StringToNumber(temps[17]);
	CharacterObject.Set_id (StringToNumber(temps[18]));
	
//	textprintf_centre(screen, font, 40, 200, makecol(255, 255, 255),"test source:%d", id);
CharacterObject.Set_inarea (StringToNumber(temps[19]));
CharacterObject.Set_socketid (StringToNumber(temps[20]));
//Sleep(5000);
}



string Client::toString()
{
	
		client = username + "," + password + "," + NumberToString(CharacterObject.type)+ "," +CharacterObject.Get_name()+ "," + CharacterObject.Get_race() + "," + "sex" +
	"," + NumberToString(CharacterObject.Get_X()) + 
	"," + NumberToString(CharacterObject.Get_Y()) + "," + NumberToString(CharacterObject.Get_W()) +"," +NumberToString(CharacterObject.Get_H()) +
	"," + NumberToString(CharacterObject.Get_layer()) + "," + NumberToString(CharacterObject.Get_source_X()) + 
	"," + NumberToString(CharacterObject.Get_source_Y()) + "," + NumberToString(CharacterObject.Is_in_collision()) + 
	"," + NumberToString(CharacterObject.Get_frame()) + "," + NumberToString(CharacterObject.Get_direction()) +
	"," + NumberToString(CharacterObject.Get_sourcebitmap()) + "," + "dest" + 
	"," + NumberToString(CharacterObject.Get_id()) + ","+ NumberToString(CharacterObject.Get_inarea()) +"," + NumberToString(CharacterObject.Get_socketid()) + "`";
//textout(screen,font,client.c_str(),100,50*CharacterObject.Get_id(),makecol(255,255,255));
Sleep(90000);
return client;
}
#endif


