/**
 * @(#)Player.java	11/03/05
 * 
 * Copyright 2005 3GP01, KCL.  All unmodified code is copyright of its respective owner.
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * The GNU General Public Licence should be contained within licence.txt;
 * if not, write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA  02110-1301, USA.
 */

/**
 * This abstract class outlines a Player.
 * A Player has a name, a Rack, a score, a skipCounter and a boolean isLockedOut reporting whether
 * the player is still in the game. 
 * 
 * @author 3GP01 - Hardev Bhamra, Deepak Chandarana, James Tompkin
 * @version 2.0
 * @see LocalScrabble
 * @see Game
 */
public abstract class Player 
{
	private String name;

	private Rack rack;

	private int score = 0;

	private int skipCounter = 0; //if person skips twice in a row, they should be locked out until game completion

	private boolean isLockedOut = false; //if person is locked out

	public Player(String nme) 
	{
		name = nme;
		rack = new Rack();
	}

	public String getName() 
	{
		return name;
	}

	public Rack getRack() 
	{
		return rack;
	}

	public void setRack(Rack r) 
	{
		rack = r;
	}

	public int getScore() 
	{
		return score;
	}

	public int getSkipCounter() 
	{
		return skipCounter;
	}

	public boolean isLockedOut() 
	{
		return isLockedOut;
	}

	public void addScore(int x) 
	{
		score += x;
	}

	public void setIsLockedOut() 
	{
		isLockedOut = true;
	}

	public void incrementSkipCounter() 
	{
		skipCounter++;
	}

	public void resetSkipCounter() 
	{
		skipCounter = 0;
	}

	public String toString() 
	{
		return name;
	}

	public String toXml() 
	{
		String res = "  <player>\n    <name>" + name + "</name>\n"
				+ "    <score>" + score + "</score>\n  </player>\n";
		return res;
	}
}

/**
 * Class defines a human player as a super of Player. 
 * 
 * @author 3GP01 - Hardev Bhamra, Deepak Chandarana, James Tompkin
 * @version 2.0
 * @see Player
 */
class HumanPlayer extends Player 
{	// to make a move, user enters each letter move
	public HumanPlayer(String nme) 
	{
		super(nme);
	}
}

/**
 * Class defines a computer player as a super of Player. 
 * 
 * @author 3GP01 - Hardev Bhamra, Deepak Chandarana, James Tompkin
 * @version 2.0
 * @see Player
 */
class ComputerPlayer extends Player 
{	// calculates optimal move
	public ComputerPlayer(String nme) 
	{
		super(nme);
	}
}

