#ifndef _TILE_H
#define _TILE_H


#include <qpushbutton.h>


//used w/ tile constructor to set tile values///////////////////////////////////
const int LetterIDValue[26]= {1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 
	10, 1, 1, 1, 1, 4, 4, 8, 4, 10 };


//******************************************************************************
//	Tile Class
//
//	Purpose:	base class used to contain info about tile properties
//
//	the Tile is what is seen in the player's hand.  the boardspace class inherits
//	it, as they are essentially the same thing, except for how they are displayed
//******************************************************************************
class Tile : public QPushButton
{
	Q_OBJECT

private:

	
	char Letter;
	int LetterID;
		//the letterID is a number representing which letter the tile is
		//0=a, 26=z

	int Value;

	Tile();
		//blank tiles don't make sense...don't do it

public:

	//all the contrustors, can accept letterID or char letter//////////////
	Tile(int LetterNum, QWidget* parent=0, const char* name=0);
	Tile(char LetterChar, QWidget* parent=0, const char* name=0);
	Tile(const Tile &TileToCopy, QWidget* parent=0, const char* name=0);
		//copy constructor
	
	/////////////////////////////////////////////////////////////////////////

	//basic return functions
	char letter() const;
	int letterID() const;
	int value() const;
	////////////////////////

protected slots:

	void SetToDifferent(const Tile& TileToCopy);
		//Set a tile to a different value, should only be implemented in
		//derived classes that can be changed, like boardspace

	void resizeEvent(QResizeEvent*);

	void paintEvent(QPaintEvent*);
		//this is called by QT, it displays the letter and value on the tile

};



//******************************************************************************
//	Boardspace Class
//
//	Purpose:	basic piece of the board class
//
//	similar tile, except can be changed, and has an associated word/letter bonus
//******************************************************************************
class Boardspace : public Tile
{
	Q_OBJECT

private:

	bool Is_Empty;

	int XWordBonus;
	int XLetterBonus;

public:

	Boardspace(QWidget* parent=0, const char* name=0, int LetterValue = 1, int WordValue = 1);

	//change boardspace to whatever tile/boardspace
	Boardspace& setTo(Tile* NewTile);
	Boardspace& setTo(Tile& NewTile);
	/////////////////////////////////////////////////

	//	removes tile from board but does not delete tile from mememory
	void clear();

	//return functions/////////////
	bool is_empty() const;
	char letter() const;
	int value() const;
	int points() const;
	int letterBonus() const;
	int wordBonus() const;
	///////////////////////////////

public slots:

	void setTo(int);
		//change boardspace using letterID

protected slots:

	void resizeEvent(QResizeEvent*);
		//called everytime boardspace is resized, used to keep fontsize correct

signals:

	//easy enough////////////
	void valueChanged(int);
	void letterChanged(char);
	void letterIDChanged(int);
	void isEmpty(bool);

};




#endif