public class Game extends Object
Constructor and Description |
---|
Game(Position position,
String event,
String site,
String whitePlayerName,
String blackPlayerName,
int round) |
Modifier and Type | Method and Description |
---|---|
String |
getBlackPlayerName() |
String |
getDate() |
String |
getEvent() |
Position |
getPosition() |
int |
getRound() |
String |
getSite() |
Position |
getStartPos() |
GameState |
getState() |
String |
getWhitePlayerName() |
boolean |
isWhitesTurn() |
static Game |
parse(String pgn)
Parses a game in PGN notation and returns a game instance.
|
boolean |
play(String move)
Plays a move defined either in PACN or SAN format if legal.
|
void |
setBlackPlayerName(String blackPlayerName) |
void |
setEvent(String event) |
void |
setSite(String site) |
void |
setState(GameState state)
Sets the state of the game in case of draw by agreement, resignation, or time out.
|
void |
setWhitePlayerName(String whitePlayerName) |
String |
toString() |
String |
unplay()
Unmakes the last move and returns it in Pure Algebraic Coordinate Notation.
|
public Game(Position position, String event, String site, String whitePlayerName, String blackPlayerName, int round)
position
- The start position of the game.event
- The name of the event.site
- The site of the event.whitePlayerName
- The white player's name.blackPlayerName
- The black player's name.round
- The round number in case the game is one of a series of games.public static Game parse(String pgn) throws ChessParseException
pgn
- The PGN string.ChessParseException
- If the PGN string cannot be parsed.public Position getStartPos()
public Position getPosition()
public String getEvent()
public String getSite()
public String getDate()
public int getRound()
public String getWhitePlayerName()
public String getBlackPlayerName()
public GameState getState()
public boolean isWhitesTurn()
public void setEvent(String event)
event
- The name of the event at which the game took place.public void setSite(String site)
site
- The site of the event where the game took place.public void setWhitePlayerName(String whitePlayerName)
whitePlayerName
- The name of the white player.public void setBlackPlayerName(String blackPlayerName)
blackPlayerName
- The name of the black player.public void setState(GameState state)
state
- The new state of the game.public boolean play(String move)
move
- The move to make defined either in Pure Algebraic Coordinate Notation or Standard Algebraic Notation.public String unplay()
Copyright © 2020. All rights reserved.