/****************************
*This class creates the hands
*for the different players.
*@author - Bryan Wiseman
*@version - 1
*****************************/
//Date: 3/18/07
//Section: 1
//PA: 2

public class BridgeHand
{
	
	Card[] hand;	//the hand of the player
	int points;		//points value of player's hand
	
	//constructor of hand
	public BridgeHand()
	{
		hand = new Card [13];
		points = 0;
	}
	/*********************
	*Method calculates the 
	*total point value of 
	*the player's hand
	*@return - points of hand
	*********************/
	public int evaluateHand()
	{
		
		int heart;		//number of hearts in hand
		int spade;		//number of spades in hand
		int club;		//number of clubs in hand
		int diamond;	//number of diamonds in hand
		
		heart = 0;
		spade = 0;
		club = 0;
		diamond = 0;
		
		//loop gets points of individual cards
		for(int num = 0; num < 13; num++)
		{
			points = points + hand[num].getPoints();
		}
		//gets number of each suit in hand
		for(int num = 0; num < 13; num++)
		{
			if(hand[num].suit == Suit.HEARTS)
			{
				heart++;
			}
			else if(hand[num].suit == Suit.SPADES)
			{
				spade++;
			}
			else if(hand[num].suit == Suit.DIAMONDS)
			{
				diamond++;
			}
			else if(hand[num].suit == Suit.CLUBS)
			{
				club++;
			}
		}
		//points for void
		if(spade == 0)
		{
			points = points + 3;
		}
		if(heart == 0)
		{
			points = points + 3;
		}
		if(diamond == 0)
		{
			points = points + 3;
		}
		if(club == 0)
		{
			points = points + 3;
		}
		//points for Singleton
		if(spade == 1)
		{
			points = points + 2;
		} 
		if(heart == 1)
		{
			points = points + 2;
		}
		if(diamond == 1)
		{
			points = points + 2;
		}
		if(club == 1)
		{
			points = points + 2;
		}
		//points for Doubleton
		if(spade == 2)
		{
			points = points + 1;
		}
		if(heart == 2)
		{
			points = points + 1;
		}
		if(diamond == 2)
		{
			points = points + 1;
		}
		if(club == 2)
		{
			points = points + 1;
		}
		
		return points;
	}
	/*******************
	*Method puts cards into
	*the players hand
	*@param - Card 
	*@param - index for array
	********************/
	public void putCardInHand(Card card, int index)
	{	
		hand[index] = card;
	}
	/******************
	*Method puts hand together
	*and points for each hand in
	*String value
	*@return - String of hand and points
	********************/
	public String toString()
	{
		String output;
		
		output = "";
		
		for(int num = 0; num < hand.length; num++)
		{
			output = output + hand[num].toString() + "\n";
		} 
		
		output = output + "\nPoints = " + points;
		
		return output;
	}
		
}
	