InsanichessLiveGame class Null safety

Extends InsanichessGame with data that a server needs for bookkeeping and player's client needs to update UI accordingly.

This extension adds capabilities to InsanichessGame that are important only for games currently being played.

Inheritance

Constructors

InsanichessLiveGame({required bool undoAllowed, required String id, required InsanichessPlayer whitePlayer, required InsanichessPlayer blackPlayer, required InsanichessTimeControl timeControl})
Constructs new InsanichessLiveGame object.
InsanichessLiveGame.fromJson(Map<String, dynamic> json)
Creates new InsanichessLiveGame from json representation.

Properties

blackPlayer InsanichessPlayer
Information for player with black pieces.
finalinherited
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-onlyinherited
id String
The id of the game.
finalinherited
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
playerOfferedDraw PieceColor?
The color of the player that offered draw. If there is no player currently offering a draw, this field is null.
read / write
playerOnTurn PieceColor
Returns the color of the playerOnTurn.
read-onlyinherited
playerRequestedUndo PieceColor?
The color of the player that offered draw. If there is no player currently requesting undo, this field is null.
read / write
remainingTimeBlack Duration
Remaining playing time for black.
read / writeinherited
remainingTimeWhite Duration
Remaining playing time for white.
read / writeinherited
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.
finalinherited
timeOfLastMove DateTime?
The time when the last move has been played. Comparing this field to current time the time a player needed for a move is calculated.
read / write
timesSpentPerMove List<Duration>
The durations player needed for each move.
finalinherited
undoAllowed bool
Undo is allowed in this game if both players have set the "allow undo" setting to true in their InsanichessLiveGameSettings.
final
whitePlayer InsanichessPlayer
Information for player with white pieces.
finalinherited
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.
inherited
toJson() Map<String, Object?>
Converts this object to json representation.
override
toString() String
A string representation of this object.
inherited
undo() PlayedMove?
Undoes the move on the board, removes last element of timesSpentPerMove and updated either remainingTimeWhite or remainingTimeBlack accordingly.
override
updateTime(Duration timeSpentForMove, PieceColor player) → void
Deducts timeSpentForMove from remaining time of the player and adds timeControl.incrementPerMove to it.
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.
inherited