#ifndef _PLAYER_H
#define _PLAYER_H


#include "Tile.h"
#include <vector>
#include <qwidget.h>
#include <qvector.h>

using std::vector;

class QKeyEvent;
class QGridLayout;

const int MAX_HUMHAND=7;


//******************************************************************************
//	Player Class
//
//	Purpose:	house info for tiles in player's hand
//
//	the player class is simply a "container" for the tiles that the player is holding
//	There's alot of communication going on, hence the the large # of slots.
//	There is also alot of memory management done here becuase of the large number
//	of pointers
//******************************************************************************
class Player : public QWidget
{
	Q_OBJECT

	private:

		QVector<Tile> InHand;
			//QT's vector, used to hold tiles

		int DisabledTile;
			//gives position of the current disabled tile not on board

		QGridLayout* grid;
			//used to organize tiles in the hand

		vector<int> EmptyPositions;
			//contains the position of empty tiles in the vector

		bool SwapTiles;
			//used to determine if user wants to swap tiles in hand

		void SwapTileAt(int);
			//used in tileClickEvent to swap tile w/ the currently disabledTile

	public:


		Player(QWidget* parent=0, const char* name=0);
		~Player();

		int tilesNeeded();
			//returns no of tiles needed for full hand

		int handValue() const;
			//returns total value of tiles in hand

	public slots:

		void getTile( int );
			//used w/ tilebank to get tiles into hand

		void resetHand();
			//takes hand back to state at beginning of turn
		void updateHand();
			//lets player know that the selected tile was placed ont the board

		void eraseHand();
			//completely erases hand to start game over

		void newHand();
			//gets rid of old tile in hand to make way for new tiles

	private slots:

		void tileClickEvent();
			//handles click events when tile in hand is clicked

	protected slots:

		//for ctrl swapping feature///////
		void keyPressEvent(QKeyEvent*);
		void keyReleaseEvent(QKeyEvent*);


	signals:

		void tileClicked(const Tile*);
			//passes out pointer of tile that was just clicked

};




#endif