From aaaf40bb2ba94e3cfd551f0ab99f6e3fc3bf57c4 Mon Sep 17 00:00:00 2001 From: Marco Date: Sun, 18 Dec 2022 23:43:06 +0100 Subject: [PATCH] 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). --- lib/chess_bloc/chess_bloc.dart | 6 +++++- lib/chessapp/chess_square.dart | 7 ------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/chess_bloc/chess_bloc.dart b/lib/chess_bloc/chess_bloc.dart index 9fd421c..8259099 100644 --- a/lib/chess_bloc/chess_bloc.dart +++ b/lib/chess_bloc/chess_bloc.dart @@ -70,7 +70,7 @@ class ChessBoardState { ChessColor turnColor = ChessColor.white; Map 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 pos) { + // for (int i = 0; i < 7; i++) + } } diff --git a/lib/chessapp/chess_square.dart b/lib/chessapp/chess_square.dart index 9352684..7889856 100644 --- a/lib/chessapp/chess_square.dart +++ b/lib/chessapp/chess_square.dart @@ -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().add( - PieceMoved( - startSquare: move.startSquare, - endSquare: move.endSquare, - ), - ); } }, );