//
//  HandPanel.java
//  cribbage
//
//  Created by Nathan Haug on Sun Apr 25 2004.
//  Copyright (c) 2004 __MyCompanyName__. All rights reserved.
//
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;

public abstract class HandPanel extends JPanel
{
	JLabel cards[] = new JLabel[6];
	JPanel handFrame;
	JPanel infoFrame;
	JLabel scoreArea;
	JLabel noticeArea;
	int numCards;
	int score;
	
	// Constructor
	public HandPanel(String name) {
		super();
		setBorder( BorderFactory.createTitledBorder( name ) );
		
		handFrame = new JPanel();
		infoFrame = new JPanel();
		scoreArea = new JLabel("Score: 0");
		noticeArea = new JLabel();
		numCards = 0;
		score = 0;
	}
   
	// Mutators
	public abstract void putCard(Card newCard);
	
	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--;
	}
	
	public void notify (String notice) {
		noticeArea.setText(notice);
	}
	
	public void addScore (int score) {
		this.score += score;
		this.scoreArea.setText("Score: "+this.score);
	}
	
	public void show(Hand showHand) {	
		// Inserts the contents of showHand into the players HandPanel
		for (int i = 0; i < showHand.numCards(); i++) {
			ImageIcon cardImage = CardGraphics.getCardGraphic(showHand.getCard(i));
			cards[numCards] = new JLabel(cardImage);
			cards[numCards].setBorder(LineBorder.createBlackLineBorder());
			handFrame.add( cards[numCards] );
			numCards++;
		}
	}
	
	public void clearHand () {
		JLabel cards[] = new JLabel[6];
		numCards = 0;
		noticeArea.setText("");
		handFrame.removeAll();
	}
	
	public void disableCards() {
		;
	}
	
	public void enableCards() {
		;
	}

}
