mchess-client/lib/chess_bloc/chess_events.dart
Marco 8f4cd2266f Handle board status message
This is another step to allow reconnecting after connection loss or
browser closing.

When the game is left with the X button on the bottom right, we will
close the websocket connection, to let the server know, that we are
gone.

The server still has issues that prevent this from working flawlessly.

Remove unused import
2023-12-09 20:48:36 +01:00

69 lines
1.5 KiB
Dart

import 'package:mchess/chess_bloc/chess_position.dart';
import 'package:mchess/utils/chess_utils.dart';
abstract class ChessEvent {}
class ReceivedBoardState extends ChessEvent {
final ChessCoordinate? startSquare;
final ChessCoordinate? endSquare;
final ChessPosition position;
final ChessCoordinate squareInCheck;
ReceivedBoardState({
required this.startSquare,
required this.endSquare,
required this.position,
required this.squareInCheck,
});
}
class OwnPieceMoved extends ChessEvent {
final ChessCoordinate startSquare;
final ChessCoordinate endSquare;
final ChessPiece piece;
OwnPieceMoved(
{required this.startSquare,
required this.endSquare,
required this.piece});
}
class OwnPromotionPlayed extends ChessEvent {
final ChessPieceClass pieceClass;
final ChessMove move;
OwnPromotionPlayed({required this.pieceClass, required this.move});
}
class InitBoard extends ChessEvent {
InitBoard();
}
class ColorDetermined extends ChessEvent {
final ChessColor myColor;
ColorDetermined({required this.myColor});
}
class InvalidMovePlayed extends ChessEvent {
final ChessMove move;
final ChessCoordinate squareInCheck;
InvalidMovePlayed({
required this.move,
required this.squareInCheck,
});
}
class BoardStatusReceived extends ChessEvent {
final ChessPosition pos;
final ChessColor myColor;
final ChessColor whoseTurn;
BoardStatusReceived({
required this.pos,
required this.myColor,
required this.whoseTurn,
});
}