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) {
|
void flipBoard(ColorDetermined event, Emitter<ChessBoardState> emit) {
|
||||||
log("My Color is $myColor");
|
log("My Color is $myColor");
|
||||||
myColor = event.myColor;
|
|
||||||
|
myColor = event.playerColor;
|
||||||
|
|
||||||
emit(
|
emit(
|
||||||
ChessBoardState(
|
ChessBoardState(
|
||||||
event.myColor,
|
event.playerColor,
|
||||||
state.newTurnColor,
|
state.newTurnColor,
|
||||||
state.position,
|
state.position,
|
||||||
ChessMove.none(),
|
ChessMove.none(),
|
||||||
@ -74,9 +76,12 @@ class ChessBloc extends Bloc<ChessEvent, ChessBoardState> {
|
|||||||
.recordMove(event.startSquare, event.endSquare, event.position);
|
.recordMove(event.startSquare, event.endSquare, event.position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
myColor = event.playerColor;
|
||||||
|
turnColor = event.turnColor;
|
||||||
|
|
||||||
emit(
|
emit(
|
||||||
ChessBoardState(
|
ChessBoardState(
|
||||||
event.playerColor,
|
myColor,
|
||||||
event.turnColor,
|
event.turnColor,
|
||||||
event.position,
|
event.position,
|
||||||
move,
|
move,
|
||||||
|
@ -40,9 +40,9 @@ class InitBoard extends ChessEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ColorDetermined extends ChessEvent {
|
class ColorDetermined extends ChessEvent {
|
||||||
final ChessColor myColor;
|
final ChessColor playerColor;
|
||||||
|
|
||||||
ColorDetermined({required this.myColor});
|
ColorDetermined({required this.playerColor});
|
||||||
}
|
}
|
||||||
|
|
||||||
class InvalidMovePlayed extends ChessEvent {
|
class InvalidMovePlayed extends ChessEvent {
|
||||||
|
@ -119,7 +119,7 @@ class ServerConnection {
|
|||||||
ConnectionCubit.getInstance().opponentConnected();
|
ConnectionCubit.getInstance().opponentConnected();
|
||||||
ChessBloc.getInstance().add(InitBoard());
|
ChessBloc.getInstance().add(InitBoard());
|
||||||
ChessBloc.getInstance().add(ColorDetermined(
|
ChessBloc.getInstance().add(ColorDetermined(
|
||||||
myColor: ChessColor.fromApiColor(apiMessage.playerColor!)));
|
playerColor: ChessColor.fromApiColor(apiMessage.playerColor!)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleInvalidMoveMessage(ApiWebsocketMessage apiMessage) {
|
void handleInvalidMoveMessage(ApiWebsocketMessage apiMessage) {
|
||||||
|
Loading…
Reference in New Issue
Block a user