/*
 * Created on Nov 22, 2004
 *
 * Utilizes Java Power Tools (JPT)
 * http://www.ccs.neu.edu/jpt/
 * 
 */

/**
 *Authored by Brandon Schory
 *
 *With help, inspiration, and code from Richard Rasala, Mike Battista, Ken Eimer, and Matt DeGennaro
 *
 */

import edu.neu.ccs.gui.*;

public class Player extends Person{
    
    //variable declarations
	static int total;
	int NumberOfAces;
	int NumberOfCards;
	
	/** Keeps track of all aspects of the Player's Cards including:
	 * - Number of Aces
	 * - Number of Cards
	 * - Calls the Total() function
	 * - Tests for a "soft hand" (posession of aces)
	 * - If there is an ace, subtracts 10 points from the Player's total to keep from busting
	 * - Places the total into the PlayerTotal text field
	 * - Calls the ReturnCardImage() function
	 * - Automatically stays when player has 21
	 * - Checks if Player Busts
	 *
	 */
	protected void PlayerCards(Card c){
		if(c.value == 11){
			NumberOfAces++;
		}
		NumberOfCards += 1;
		total = Total(c.value, total);
		if(total > 21 && NumberOfAces > 0){
			total -= 10;
			NumberOfAces--;}
		BlackJack.PlayerTotal.setViewState(total + "");
		ReturnCardImage(c, BlackJack.PlayerCards, NumberOfCards);
		if(total == 21 && BlackJack.ok == true){BlackJack.dealer.DealerAI();}
		else if(total > 21){BlackJack.EndGame2();}
	}
	
	/** Creates a new Player*/
	public Player() {
		total = 0;
		NumberOfAces = 0;
		NumberOfCards = 0;
	}
	

}
