InsanichessGame class

Contains all information about the game.

Apart from basic game rules, this class adds information that is usable both to client and server in order to store additional game information.

Implementers

Constructors

InsanichessGame({required String id, required InsanichessPlayer whitePlayer, required InsanichessPlayer blackPlayer, required InsanichessTimeControl timeControl})
Constructs a fresh game with initial position.
InsanichessGame.fromICString(String s)
Returns new InsanichessGame object from ICString representation s.
factory
InsanichessGame.fromJson(Map<String, dynamic> json)
Creates new InsanichessGame object from json.
InsanichessGame.fromPosition({required String id, required InsanichessPlayer whitePlayer, required InsanichessPlayer blackPlayer, required InsanichessTimeControl timeControl, List<Duration>? timesSpentPerMove, Duration? remainingTimeWhite, Duration? remainingTimeBlack, required Position position, GameHistory? gameHistory})
Constructs a game from given position and gameHistory with option to change remainingTimeWhite and remainingTimeBlack.

Properties

blackPlayer InsanichessPlayer
Information for player with black pieces.
final
blackWon bool
Returns true if the game was won by black.
no setterinherited
board → Board
Returns the current _board.
no setterinherited
canGoBackward bool
Is there a move in the past?
no setterinherited
canGoForward bool
Is there a future move?
no setterinherited
canUndo bool
Is there is a move that can be undone?
no setterinherited
hashCode int
hashCode for InsanichessGame is simply id.hashCode.
no setteroverride
id String
The id of the game.
final
inProgress bool
Returns true if the game is currently in progress.
no setterinherited
isGameOver bool
Returns whether the game is over or not.
no setterinherited
legalMoves List<Move>
no setterinherited
movesFromFuture List<PlayedMove>
Returns moves that are in the future. That means they were played but player went backward to explore move history.
no setterinherited
movesPlayed List<PlayedMove>
Returns moves played until current position.
no setterinherited
playerOnTurn → PieceColor
Returns the color of the playerOnTurn.
no setterinherited
remainingTimeBlack Duration
Remaining playing time for black.
getter/setter pair
remainingTimeWhite Duration
Remaining playing time for white.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
status → GameStatus
Returns the current status of the game.
no setterinherited
timeControl InsanichessTimeControl
Time control for the game.
final
timesSpentPerMove List<Duration>
The durations player needed for each move.
final
whitePlayer InsanichessPlayer
Information for player with white pieces.
final
whiteWon bool
Returns true if the game was won by white.
no setterinherited

Methods

backward() → PlayedMove?
Moves one move backward in the _gameHistory.
inherited
blackResigned() → void
Sets the current status to GameStatus.blackResigned.
inherited
draw() → void
Sets the current status to GameStatus.draw.
inherited
flagged([PieceColor? player]) → void
Sets the current status to GameStatus.whiteFlagged or GameStatus.blackFlagged, depending on who the player is.
inherited
forward() → PlayedMove?
Moves one move forward in the _gameHistory.
inherited
move(Move m) → PlayedMove?
Performs a move m on the board and updates _gameStatus.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toICString() String
Creates a String representation of a game. This representation contains in each line a pair of moves of white and black player, separated by ' ' character and game metadata at the start.
toJson() Map<String, Object?>
Converts this object to json representation.
toString() String
A string representation of this object.
inherited
undo() → PlayedMove?
Undoes the last move.
inherited
whiteResigned() → void
Sets the current status to GameStatus.whiteResigned.
inherited

Operators

operator ==(Object? other) bool
Two InsanichessGames are equal if they have the same id.
override