antichess
Class GameReader
java.lang.Object
antichess.GameReader
public class GameReader
- extends Object
The GameReader class reads XML game files for antichess games.
- Specification Fields
-
-
board
: AntichessBoard // The Board as of when the game was saved
-
timed
: boolean // Indicates whether the game was times
-
whiteTimer
: Timer // White's Timer as of when the game was saved
-
blackTimer
: Timer // Black's Timer as of when the game was saved
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
GameReader
public GameReader(InputStream stream)
throws InvalidGameFileException,
IOException
- Throws:
InvalidGameFileException
- if the stream is not a valid game (e.g. it does not validate)
IOException
- Effects:
- constructs a new GameReader containing the data in the
given XML stream
GameReader
public GameReader(File gameFile)
throws InvalidGameFileException,
IOException
- Throws:
IOException
- if there is an IO error reading the file
InvalidGameFileException
- if the file is not valid game file (e.g. it does not validate)- Effects:
- constructs a new GameReader containing the data in the
given XML file
GameReader
public GameReader(String xmlData)
throws InvalidGameFileException
- Throws:
InvalidGameFileException
- if the file is not valid game file (e.g. it does not validate)- Effects:
- constructs a new GameReader by reading the given string of XML
loadBoard
public static void loadBoard(ChessBoard board,
String xml,
Player player)
throws InvalidGameFileException
- Throws:
InvalidGameFileException
- if the XML is invalid- Effects:
- Load the given board with the data parsed from an XML
<pieces> tag, including both the start and end tags, and
set the specified player.
parseMove
public static ChessMove parseMove(String value,
ChessBoard board)
- Returns:
- a ChessMove by parsing the string description of a move
(e.g e2-e4) on the given board.
- Throws:
IllegalArgumentException
- if the move is ill-formed, or
tries to move a piece that doesn't exist
getBoard
public AntichessBoard getBoard()
- Returns:
- this.board
isTimed
public boolean isTimed()
- Returns:
- this.timed
getWhiteTimer
public GameTimer getWhiteTimer()
- Returns:
- this.whiteTimer
getBlackTimer
public GameTimer getBlackTimer()
- Returns:
- this.blackTimer