//
//  AIHandPanel.java
//  cribbage
//
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;

public class AIHandPanel extends HandPanel
{	
	// Constructor
	public AIHandPanel(String name) 
	{
		super(name);
		
		// Setup our layout
		BoxLayout mainLayout = new BoxLayout(this, BoxLayout.Y_AXIS);
		FlowLayout infoLayout = new FlowLayout(FlowLayout.RIGHT,0,0);
		FlowLayout handLayout = new FlowLayout(FlowLayout.CENTER,5,0);
		handFrame.setLayout(handLayout);
		infoFrame.setLayout(infoLayout);
		this.setLayout(mainLayout);
		this.setPreferredSize(new Dimension(320,125));
		scoreArea.setBorder(BorderFactory.createEmptyBorder(4,20,0,0));
		scoreArea.setFont(new Font("Helvitica",Font.PLAIN,12));
		noticeArea.setBorder(BorderFactory.createEmptyBorder(5,0,0,0));
		noticeArea.setFont(new Font("Helvitica",Font.PLAIN,10));
		add(handFrame);
		
		// Put some spacer in there
		Dimension minSize = new Dimension(0, 0);
		Dimension prefSize = new Dimension(0, 100);
		Dimension maxSize = new Dimension(Short.MAX_VALUE, 100);
		add(new Box.Filler(minSize, prefSize, maxSize));
		
		infoFrame.add(noticeArea);
		infoFrame.add(scoreArea);
		add(infoFrame);		
   }
   
	// Mutators
	public void putCard(Card theCard) {
		ImageIcon cardBack = new ImageIcon("./images/_cardback.jpg");
		cards[numCards] = new JLabel(cardBack);
		cards[numCards].setBorder(LineBorder.createBlackLineBorder());
		handFrame.add( cards[numCards] );
		numCards++;
		
		validate();
		repaint();
	}
	
	public void deleteCard(int cardPos) {
		handFrame.remove(cards[cardPos]);
		for (int i=cardPos; i<numCards-1; i++)
			cards[i] = cards[i+1];
		cards[numCards-1] = null;		
		numCards--;
		
		validate();
		repaint();
	}
}