Remove a redundant call to ChessBloc that caused the position to be renewed twice.

Fix a index error (Column started with 0 while rows started with 1).
This commit is contained in:
Marco 2022-12-18 23:43:06 +01:00
parent c9a93dd167
commit aaaf40bb2b
2 changed files with 5 additions and 8 deletions

View File

@ -70,7 +70,7 @@ class ChessBoardState {
ChessColor turnColor = ChessColor.white;
Map<ChessCoordinate, ChessPiece> position = {};
for (int i = 0; i <= 8; i++) {
for (int i = 1; i <= 8; i++) {
position[ChessCoordinate(i, 7)] =
ChessPiece(ChessPieceName.blackPawn, ChessColor.black);
position[ChessCoordinate(i, 2)] =
@ -113,4 +113,8 @@ class ChessBoardState {
return ChessBoardState._(bottomColor, turnColor, position);
}
void logPosition(Map<ChessCoordinate, ChessPiece> pos) {
// for (int i = 0; i < 7; i++)
}
}

View File

@ -91,13 +91,6 @@ class ChessSquare extends StatelessWidget {
if (move.endSquare != move.startSquare) {
ServerConnection.getInstance().send(
'${messageIndex++} mv ${move.startSquare.toString()} ${move.endSquare.toString()}');
context.read<ChessBloc>().add(
PieceMoved(
startSquare: move.startSquare,
endSquare: move.endSquare,
),
);
}
},
);