mchess-client/lib/chess_bloc/chess_events.dart
Marco 2a4da9a1af Implement moves by tapping the squares
This adds an option to dragging-and-dropping which is slightly hard on
smaller screens.

Fix promotions when tapping and fix handling of subsequently tapping two pieces of your color

Cancel tap if a drag is started (tapped square will not stay red in case a drag is started)

Change url strategy back to the hashtag thing

Change version

Fix bug that would not allow a piece move if you tried to take an opponents piece.

Fix the coloring of the last move after an invalid move was played.
2024-01-09 19:11:56 +01:00

55 lines
1.2 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;
final ChessColor turnColor;
ReceivedBoardState({
required this.startSquare,
required this.endSquare,
required this.position,
required this.squareInCheck,
required this.turnColor,
});
}
class OwnPieceMoved extends ChessEvent {
final ChessCoordinate startSquare;
final ChessCoordinate endSquare;
OwnPieceMoved({required this.startSquare, required this.endSquare});
}
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,
});
}