fix bug where chessbloc had wrong colors

This commit is contained in:
Marco 2024-05-19 21:44:05 +02:00
parent 809a459c8c
commit ed9fa79a79
3 changed files with 11 additions and 6 deletions

View File

@ -51,10 +51,12 @@ class ChessBloc extends Bloc<ChessEvent, ChessBoardState> {
void flipBoard(ColorDetermined event, Emitter<ChessBoardState> emit) {
log("My Color is $myColor");
myColor = event.myColor;
myColor = event.playerColor;
emit(
ChessBoardState(
event.myColor,
event.playerColor,
state.newTurnColor,
state.position,
ChessMove.none(),
@ -74,9 +76,12 @@ class ChessBloc extends Bloc<ChessEvent, ChessBoardState> {
.recordMove(event.startSquare, event.endSquare, event.position);
}
myColor = event.playerColor;
turnColor = event.turnColor;
emit(
ChessBoardState(
event.playerColor,
myColor,
event.turnColor,
event.position,
move,

View File

@ -40,9 +40,9 @@ class InitBoard extends ChessEvent {
}
class ColorDetermined extends ChessEvent {
final ChessColor myColor;
final ChessColor playerColor;
ColorDetermined({required this.myColor});
ColorDetermined({required this.playerColor});
}
class InvalidMovePlayed extends ChessEvent {

View File

@ -119,7 +119,7 @@ class ServerConnection {
ConnectionCubit.getInstance().opponentConnected();
ChessBloc.getInstance().add(InitBoard());
ChessBloc.getInstance().add(ColorDetermined(
myColor: ChessColor.fromApiColor(apiMessage.playerColor!)));
playerColor: ChessColor.fromApiColor(apiMessage.playerColor!)));
}
void handleInvalidMoveMessage(ApiWebsocketMessage apiMessage) {