InsanichessGame class Null safety

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.

Inheritance
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.
read-onlyinherited
board Board
Returns the current _board.
read-onlyinherited
canGoBackward bool
Is there a move in the past?
read-onlyinherited
canGoForward bool
Is there a future move?
read-onlyinherited
canUndo bool
Is there is a move that can be undone?
read-onlyinherited
hashCode int
hashCode for InsanichessGame is simply id.hashCode.
read-onlyoverride
id String
The id of the game.
final
inProgress bool
Returns true if the game is currently in progress.
read-onlyinherited
isGameOver bool
Returns whether the game is over or not.
read-onlyinherited
legalMoves List<Move>
read-onlyinherited
movesFromFuture List<PlayedMove>
Returns moves that are in the future. That means they were played but player went backward to explore move history.
read-onlyinherited
movesPlayed List<PlayedMove>
Returns moves played until current position.
read-onlyinherited
playerOnTurn PieceColor
Returns the color of the playerOnTurn.
read-onlyinherited
remainingTimeBlack Duration
Remaining playing time for black.
read / write
remainingTimeWhite Duration
Remaining playing time for white.
read / write
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
status GameStatus
Returns the current status of the game.
read-onlyinherited
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.
read-onlyinherited

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 non-existent 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