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:
parent
c9a93dd167
commit
aaaf40bb2b
@ -70,7 +70,7 @@ class ChessBoardState {
|
|||||||
ChessColor turnColor = ChessColor.white;
|
ChessColor turnColor = ChessColor.white;
|
||||||
Map<ChessCoordinate, ChessPiece> position = {};
|
Map<ChessCoordinate, ChessPiece> position = {};
|
||||||
|
|
||||||
for (int i = 0; i <= 8; i++) {
|
for (int i = 1; i <= 8; i++) {
|
||||||
position[ChessCoordinate(i, 7)] =
|
position[ChessCoordinate(i, 7)] =
|
||||||
ChessPiece(ChessPieceName.blackPawn, ChessColor.black);
|
ChessPiece(ChessPieceName.blackPawn, ChessColor.black);
|
||||||
position[ChessCoordinate(i, 2)] =
|
position[ChessCoordinate(i, 2)] =
|
||||||
@ -113,4 +113,8 @@ class ChessBoardState {
|
|||||||
|
|
||||||
return ChessBoardState._(bottomColor, turnColor, position);
|
return ChessBoardState._(bottomColor, turnColor, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void logPosition(Map<ChessCoordinate, ChessPiece> pos) {
|
||||||
|
// for (int i = 0; i < 7; i++)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,13 +91,6 @@ class ChessSquare extends StatelessWidget {
|
|||||||
if (move.endSquare != move.startSquare) {
|
if (move.endSquare != move.startSquare) {
|
||||||
ServerConnection.getInstance().send(
|
ServerConnection.getInstance().send(
|
||||||
'${messageIndex++} mv ${move.startSquare.toString()} ${move.endSquare.toString()}');
|
'${messageIndex++} mv ${move.startSquare.toString()} ${move.endSquare.toString()}');
|
||||||
|
|
||||||
context.read<ChessBloc>().add(
|
|
||||||
PieceMoved(
|
|
||||||
startSquare: move.startSquare,
|
|
||||||
endSquare: move.endSquare,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user