Fix turnColor handling
This commit is contained in:
parent
ba947ae5e4
commit
289ec6db26
@ -27,7 +27,7 @@ class ChessApp extends StatelessWidget {
|
||||
useMaterial3: true,
|
||||
),
|
||||
routerConfig: ChessAppRouter.getInstance().router,
|
||||
title: 'mChess 0.1339',
|
||||
title: 'mChess 0.1.1340',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -75,6 +75,8 @@ class ChessBloc extends Bloc<ChessEvent, ChessBoardState> {
|
||||
.recordMove(event.startSquare, event.endSquare, event.position);
|
||||
}
|
||||
|
||||
turnColor = event.turnColor;
|
||||
|
||||
emit(
|
||||
ChessBoardState(
|
||||
state.bottomColor,
|
||||
|
@ -8,12 +8,14 @@ class ReceivedBoardState extends ChessEvent {
|
||||
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,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -99,13 +99,14 @@ class ServerConnection {
|
||||
if (apiMessage.position != null) {
|
||||
ChessBloc.getInstance().add(
|
||||
ReceivedBoardState(
|
||||
startSquare: move?.from,
|
||||
endSquare: move?.to,
|
||||
position: ChessPositionManager.getInstance()
|
||||
.fromPGNString(apiMessage.position!),
|
||||
squareInCheck: ChessCoordinate.fromApiCoordinate(
|
||||
apiMessage.squareInCheck ?? const ApiCoordinate(col: 0, row: 0)),
|
||||
),
|
||||
startSquare: move?.from,
|
||||
endSquare: move?.to,
|
||||
position: ChessPositionManager.getInstance()
|
||||
.fromPGNString(apiMessage.position!),
|
||||
squareInCheck: ChessCoordinate.fromApiCoordinate(
|
||||
apiMessage.squareInCheck ??
|
||||
const ApiCoordinate(col: 0, row: 0)),
|
||||
turnColor: ChessColor.fromApiColor(apiMessage.turnColor!)),
|
||||
);
|
||||
} else {
|
||||
log('Error: no position received');
|
||||
|
Loading…
Reference in New Issue
Block a user