Fix green flicker of squares on invalid move

This commit is contained in:
Marco 2023-08-25 12:28:58 +02:00
parent b9d574f2ab
commit f45ec47285
2 changed files with 13 additions and 11 deletions

View File

@ -22,8 +22,9 @@ class ChessBoard extends StatelessWidget {
final piece = boardState.position[ChessCoordinate(column, row)]; final piece = boardState.position[ChessCoordinate(column, row)];
bool squareWasPartOfLastMove = false; bool squareWasPartOfLastMove = false;
if (boardState.lastMove.to == ChessCoordinate(column, row) || if ((boardState.lastMove.to == ChessCoordinate(column, row) ||
boardState.lastMove.from == ChessCoordinate(column, row)) { boardState.lastMove.from == ChessCoordinate(column, row)) &&
boardState.positionAckd) {
squareWasPartOfLastMove = true; squareWasPartOfLastMove = true;
} }

View File

@ -43,6 +43,7 @@ class ChessBloc extends Bloc<ChessEvent, ChessBoardState> {
ChessColor.white, ChessColor.white,
ChessPositionManager.getInstance().currentPosition, ChessPositionManager.getInstance().currentPosition,
ChessMove.none(), ChessMove.none(),
false,
), ),
); );
} }
@ -56,6 +57,7 @@ class ChessBloc extends Bloc<ChessEvent, ChessBoardState> {
state.newTurnColor, state.newTurnColor,
state.position, state.position,
ChessMove.none(), ChessMove.none(),
false,
), ),
); );
} }
@ -76,6 +78,7 @@ class ChessBloc extends Bloc<ChessEvent, ChessBoardState> {
turnColor, turnColor,
event.position, event.position,
ChessMove(from: event.startSquare, to: event.endSquare), ChessMove(from: event.startSquare, to: event.endSquare),
true,
), ),
); );
} }