org.moyoman.util
Class GameRecord

java.lang.Object
  |
  +--org.moyoman.util.GameRecord
All Implemented Interfaces:
Serializable

public class GameRecord
extends Object
implements Serializable

This class stores a record of a game of Go. It stores some descriptive information, such as the date the game was played, the location, and the player. In addition, it stores some redundant information, such as prisoners captured and any kos that arise to make replay simpler.

See Also:
Serialized Form

Field Summary
private  String black
           
static short BLACKTOMOVE
          constant which indicates that it is blacks turn.
private  long date
           
private  String gameId
           
static short GAMEOVER
          constant which indicates that the game has been completed.
private  Handicap handicap
           
private  float komi
           
private  ArrayList kos
          Each element is a NumberedStone object.
private  String location
           
private  ArrayList moves
          Each element is a Move object.
private  ArrayList prisoners
          Each element is a NumberedStone object.
private  Rules rules
           
private  short status
           
private  String white
           
static short WHITETOMOVE
          constant which indicates that it is whites turn.
 
Constructor Summary
GameRecord(Handicap h, String b, String w, Rules r, float k)
          Create a new GameRecord object.
 
Method Summary
 void addBlackPlayer(String p)
          Add the name of the black player to the record.
 void addDate(long d)
          The date that the game was played.
 void addId(String id)
          Set the id of the game.
 void addKo(NumberedStone stone)
          Add a ko to the game record.
 void addLocation(String loc)
          Add the location where the game was played to the record.
 void addMove(Move move)
          Add a move to the game record.
 void addPrisoner(NumberedStone prisoner)
          Add a prisoner to the game record.
 void addWhitePlayer(String p)
          Add the name of the white player to the record.
 String getBlackPlayer()
          Get the name of the black player.
 String getClientLocation()
          Get the location where the game was played.
 long getDate()
          Get the date that the game was played.
 Stone[] getHandicapStones()
          Return the handicap stones.
 String getId()
          Return the game id.
 NumberedStone[] getKos()
          Return all kos that occurred in the game.
 Move getLastMove()
          Get the last move from the game.
 Move[] getMoves()
          Return the moves from the game.
 NumberedStone[] getPrisoners()
          Return the prisoners from the game.
 int getStatus()
          Return the status variable.
 String getWhitePlayer()
          Get the name of the white player.
 void setStatus(short s)
          Set the status of the game.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLACKTOMOVE

public static final short BLACKTOMOVE
constant which indicates that it is blacks turn.

See Also:
Constant Field Values

WHITETOMOVE

public static final short WHITETOMOVE
constant which indicates that it is whites turn.

See Also:
Constant Field Values

GAMEOVER

public static final short GAMEOVER
constant which indicates that the game has been completed.

See Also:
Constant Field Values

handicap

private Handicap handicap

rules

private Rules rules

komi

private float komi

location

private String location

black

private String black

white

private String white

date

private long date

gameId

private String gameId

status

private short status

kos

private ArrayList kos
Each element is a NumberedStone object.


prisoners

private ArrayList prisoners
Each element is a NumberedStone object.


moves

private ArrayList moves
Each element is a Move object.

Constructor Detail

GameRecord

public GameRecord(Handicap h,
                  String b,
                  String w,
                  Rules r,
                  float k)
Create a new GameRecord object.

Parameters:
h - The handicap stones.
b - The name of the black player
w - The name of the white player
r - The rule set, e.g, Japanese.
k - The value of the komi.
Method Detail

addLocation

public void addLocation(String loc)
Add the location where the game was played to the record.

Parameters:
loc - The location where the game was played.

addBlackPlayer

public void addBlackPlayer(String p)
Add the name of the black player to the record.

Parameters:
p - The client player.

addWhitePlayer

public void addWhitePlayer(String p)
Add the name of the white player to the record.

Parameters:
p - The client player.

addDate

public void addDate(long d)
The date that the game was played.

Parameters:
d - The date that the game was played.

addId

public void addId(String id)
Set the id of the game.

Parameters:
id - The game id.

addKo

public void addKo(NumberedStone stone)
Add a ko to the game record.

Parameters:
stone - The move that would illegally retake the ko.

addMove

public void addMove(Move move)
Add a move to the game record.

Parameters:
move - The move to add to the record.

addPrisoner

public void addPrisoner(NumberedStone prisoner)
Add a prisoner to the game record.

Parameters:
prisoner - The stone that was captured.

getClientLocation

public String getClientLocation()
Get the location where the game was played.

Returns:
Return the location where the game was played.

getBlackPlayer

public String getBlackPlayer()
Get the name of the black player.

Returns:
The name of the black player.

getWhitePlayer

public String getWhitePlayer()
Get the name of the white player.

Returns:
The name of the white player.

getDate

public long getDate()
Get the date that the game was played.

Returns:
The date that the game was played.

getHandicapStones

public Stone[] getHandicapStones()
Return the handicap stones.

Returns:
the handicap stones.

getId

public String getId()
Return the game id.

Returns:
The game id.

getKos

public NumberedStone[] getKos()
Return all kos that occurred in the game.

Returns:
The kos that occurred in the game.

getMoves

public Move[] getMoves()
Return the moves from the game.

Returns:
An array of moves from the game.

getPrisoners

public NumberedStone[] getPrisoners()
Return the prisoners from the game.

Returns:
An array of prisoners from the game.

setStatus

public void setStatus(short s)
               throws IllegalArgumentException
Set the status of the game.

Throws:
IllegalArgumentException - Thrown if the status value is out of range.

getStatus

public int getStatus()
Return the status variable.

Returns:
The value of status.

getLastMove

public Move getLastMove()
                 throws NoSuchDataException
Get the last move from the game. It is an error to call this method if no moves have been made, even if there are handicap stones.

Returns:
A Move object representing the last move made in the game.
Throws:
A - NoSuchDataException is thrown if no non-handicap moves have been made.
NoSuchDataException