de.htwdd.rosenkoenig.game
Class Player

java.lang.Object
  extended by de.htwdd.rosenkoenig.game.Player
Direct Known Subclasses:
HumanPlayer, NeuroPlayer

public abstract class Player
extends java.lang.Object

Abstract class for all players. Not an interface, as we need members. All player types must derive from this class.


Field Summary
protected  boolean canMove
           
protected  java.util.ArrayList<Card> cards
           
protected  Game game
           
protected  boolean hasMoved
           
protected  int highscore
           
protected  int knights
           
protected  java.lang.String name
           
protected  int score
           
 
Constructor Summary
Player()
          Ctor, does nothing.
 
Method Summary
abstract  org.jdom.Element createXml()
           
 boolean equals(java.lang.Object other)
          This function compares two players.
protected abstract  void extractPlayer(org.jdom.Element xmlPlayer)
           
 boolean getCanMove()
          Getter of the property canMove
 java.util.ArrayList<Card> getCards()
          Getter of the property cards
 Game getGame()
          Getter of the property game
 boolean getHasMoved()
          Getter of the property hasMoved
 int getHighscore()
          Getter of the property highscore
 int getKnights()
          Getter of the property knights
 java.lang.String getName()
          Getter of the property name
 int getNumberOfCards()
          Return the number of cards of this player.
 int getScore()
          Getter of the property score
abstract  boolean isInteractive()
          If you derive from player and implement some kind of AI-player, return false here.
static Player loadFromFile(java.io.File file)
          Load a saved player from file.
 void saveToDir(java.lang.String directoryName)
          Save a player to directoryName.
 void setCanMove(boolean canMove)
          Setter of the property canMove
 void setCards(java.util.ArrayList<Card> cards)
          Setter of the property cards
 void setGame(Game game)
          Setter of the property game
 void setHasMoved(boolean hasMoved)
          Setter of the property hasMoved
 void setHighscore(int highscore)
          Setter of the property highscore
 void setKnights(int knights)
          Setter of the property knights
 void setName(java.lang.String name)
          Setter of the property name
 void setScore(int score)
          Setter of the property score
abstract  void turn()
          Deriving classes must do something in the turn function.
 void updateHighscore()
          Update the player's highscore.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hasMoved

protected boolean hasMoved

canMove

protected boolean canMove

name

protected java.lang.String name

cards

protected java.util.ArrayList<Card> cards

knights

protected int knights

score

protected int score

highscore

protected int highscore

game

protected Game game
Constructor Detail

Player

public Player()
Ctor, does nothing.

Method Detail

getHasMoved

public boolean getHasMoved()
Getter of the property hasMoved

Returns:
Returns the hasMoved.

setHasMoved

public void setHasMoved(boolean hasMoved)
Setter of the property hasMoved

Parameters:
hasMoved - The hasMoved to set.

getCanMove

public boolean getCanMove()
Getter of the property canMove

Returns:
Returns the canMove.

setCanMove

public void setCanMove(boolean canMove)
Setter of the property canMove

Parameters:
canMove - The canMove to set.

getName

public java.lang.String getName()
Getter of the property name

Returns:
Returns the name.

setName

public void setName(java.lang.String name)
Setter of the property name

Parameters:
name - The name to set.

getCards

public java.util.ArrayList<Card> getCards()
Getter of the property cards

Returns:
Returns the cards.

getKnights

public int getKnights()
Getter of the property knights

Returns:
Returns the knights.

setKnights

public void setKnights(int knights)
Setter of the property knights

Parameters:
knights - The knights to set.

getScore

public int getScore()
Getter of the property score

Returns:
Returns the score.

setScore

public void setScore(int score)
Setter of the property score

Parameters:
score - The score to set.

getHighscore

public int getHighscore()
Getter of the property highscore

Returns:
Returns the highscore.

setHighscore

public void setHighscore(int highscore)
Setter of the property highscore

Parameters:
highscore - The highscore to set.

updateHighscore

public void updateHighscore()
Update the player's highscore. As the name suggests, this is only done if player's score is higher than highscore.


getNumberOfCards

public int getNumberOfCards()
Return the number of cards of this player.

Returns:
number of player's cards

turn

public abstract void turn()
Deriving classes must do something in the turn function.


setCards

public void setCards(java.util.ArrayList<Card> cards)
Setter of the property cards

Parameters:
cards - The cards to set.

getGame

public Game getGame()
Getter of the property game

Returns:
Returns the game.

setGame

public void setGame(Game game)
Setter of the property game

Parameters:
game - The game to set.

equals

public boolean equals(java.lang.Object other)
This function compares two players. This is the case if they belong to the same class and have the same name.

Overrides:
equals in class java.lang.Object

isInteractive

public abstract boolean isInteractive()
If you derive from player and implement some kind of AI-player, return false here.

Returns:
false if some kind of AI-player, true otherwise.

loadFromFile

public static Player loadFromFile(java.io.File file)
Load a saved player from file.

Parameters:
file - The file the player is trapped in.
Returns:
The freed player.

extractPlayer

protected abstract void extractPlayer(org.jdom.Element xmlPlayer)
Parameters:
xmlPlayer - The xml portion of the player. Implement this function, if you choose to save your player with several properties to be loaded from an XML-file

saveToDir

public final void saveToDir(java.lang.String directoryName)
Save a player to directoryName.

Parameters:
directoryName - The obvious thing.

createXml

public abstract org.jdom.Element createXml()
Returns:
an xml element that you want this class to save for you. Implement this function, if you choose to save your player with several properties to be saved in an XML-file.