fix bug where chessbloc had wrong colors
This commit is contained in:
parent
809a459c8c
commit
ed9fa79a79
@ -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,
|
||||
|
@ -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 {
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user