#ifndef GLOBLE_H
#define GLOBLE_H

extern bool playpick = true;
extern int unitpicked = 0;
extern int unitpickedleft = 0;
extern int tospawunit = 1;
extern int nimitems = 0;
extern int mousePointer=0;

extern bool spawunit=false;
//extern bool debugmode=false;
extern bool debugmode=true;
extern bool nimend=false;
extern string nimstring = "";
extern bool	nimstringflag = false;
extern bool startgameofnim = false;
extern bool clicked = false;
extern bool useitemflag=false;
extern string usesitem="";
extern bool equiped=false;
extern bool miniMapon=false;
extern bool miniMaponc=false;
extern bool invnetomenu=false;
extern bool trademenu=false;
extern bool text = false;
extern int csock =-1;
extern int current_area = 1;
extern int ch_current_area = 0;
extern socketcl=-1;
extern int inputConter=0;
extern bool done=false;
extern int loding = 0;
extern int targget = -1;
extern bool swing= false;
extern string username = "";
extern string password = "";
extern string serverIP = "127.0.0.1:25000";
extern string battler = "";
extern string traderName="NimMaster";

extern string newclientstring = "";
extern bool newclientflag = false;
extern string clientloginstring = "";
extern bool clientloginflag = false;
extern string clientlogoffstring = "";
extern bool clientlogoffflag = false;

extern string startTradestring = "";
extern bool	startTradestringflag = false; //find other trade user and send yes/no menu
extern bool yesNOstringflag = false;
extern string yesNOstring = "";///genorate menu
extern bool	yesNOAnserstringflag = false;
extern string yesNOAnserstring ="";///genorate menu

extern int computerId =1;
extern int smsglife =0;
extern string serverdiolog="";
extern bool onesecpased = true;

//there is a problem when it come to reading two packets
extern string inboxbuffer = "";//"0|5|004|none`~";// "0|0|003|2,what the fuck....`~";
//we are going to put a fountion say that if we dont find 0 >= at inboxbuffer.length() that mean it not emtey so do something
extern string outboxbuffer =""; //"0001|0002|001|ghgh,dfhg,hjh,2060,1594,32,32,3,32,32,0,1,3,4,1,5,0`~";

extern bool untstringflag = false; //if flag is 1 crate unit in untstring
extern string untstring = "";

extern bool untItemliststringflag = false; //if flag is 1 crate unit in untstring
extern string untItemliststring = "";

extern bool untStatstringflag = false; //if flag is 1 crate unit in untstring
extern string untStatstring = "";



extern bool sendlistflag=false;
extern string sendliststring="";
			
extern string deletetring ="";
extern bool	deleteflag = false;

//computerId
extern int StringToNumber(string MyString)
{
	istringstream converter(MyString);
	int result;
	converter >> result;
	return result;
}
extern string NumberToString(int Number)
{
	ostringstream converter;
	converter << Number;
	return converter.str();
}
extern int selected_Id=-2;
extern bool show_comands=false;
extern int maptimer=1;
extern int mapconter=0;
extern bool logicsec = true;
extern int logontrys=0;
extern int netId = 0;
extern int charnetId = 0;

extern bool movestringflag = false;
extern string movestring = "";
extern bool talkstringflag = false;
extern string talkstring = "";
extern bool graphic = false;

extern int input(int min,int sides)
{
  static bool seeded;

  int val;

  if (!seeded)              // Initialize random number generator..
  {
    srand(time(NULL));   // ..giving a seed value based on system time
    seeded=true;
  }
//2020824
//91065865
  //val = rand() % (100000);  // rand() is truly random only for..
                            // ..relatively high numbers
  val = min +(int)((sides - min) * (rand() / (double)(100000)));      // downsample the random number to the number of sides
  return (val);		//makes the number smaller
}
// draw a rectangle
// since we use it three times in the editor, it would be nice to have
// a function for it.
extern void drawRectangle(BITMAP *bmp,int x, int y, int w,int h,int color, int style, int bgcolor)
{
	w--;
	h--;
	if (style==0)
	{
		vline(bmp,x,y,y+h,color);
		vline(bmp,x+w,y,y+h,color);
		hline(bmp,x,y,x+w,color);
		hline(bmp,x,y+h,x+w,color);
	}
	if (style==1)
	{
		rectfill(bmp,x,y,x+w,y+h,bgcolor);
		vline(bmp,x,y,y+h,color);
		vline(bmp,x+w,y,y+h,color);
		hline(bmp,x,y,x+w,color);
		hline(bmp,x,y+h,x+w,color);
	}


	// this is for our dialog. This draws a box with rounded corners.
	if (style==2)
	{									
		arc(bmp,x+10,y+10,itofix(64),itofix(128),10,255);
		arc(bmp,x+10,y+h-10,itofix(128),itofix(192),10,255);
		arc(bmp,x+w-10,y+10,itofix(0),itofix(64),10,255);
		arc(bmp,x+w-10,y+h-10,itofix(192),itofix(256),10,255);


		hline(bmp,x+10,y,x+w-10,255);
		hline(bmp,x+10,y+h,x+w-10,255);
		vline(bmp,x,y+10,y+h-10,255);
		vline(bmp,x+w,y+10,y+h-10,255);
	
		floodfill(bmp,x+w/2,y+h/2,255);

		arc(bmp,x+10,y+10,itofix(64),itofix(128),8,bgcolor);
		arc(bmp,x+10,y+h-10,itofix(128),itofix(192),8,bgcolor);
		arc(bmp,x+w-10,y+10,itofix(0),itofix(64),8,bgcolor);
		arc(bmp,x+w-10,y+h-10,itofix(192),itofix(256),8,bgcolor);


		hline(bmp,x+10,y+2,x+w-10,bgcolor);
		hline(bmp,x+10,y+h-2,x+w-10,bgcolor);
		vline(bmp,x+2,y+10,y+h-10,bgcolor);
		vline(bmp,x+w-2,y+10,y+h-10,bgcolor);

		floodfill(bmp,x+w/2,y+h/2,bgcolor);
	}
}


#endif