Fix that only allows the correct pieces to be allowed to move.
This commit is contained in:
parent
0356268b32
commit
bff46e6f3d
@ -101,21 +101,21 @@ class ChessBoardState {
|
||||
ChessPiece(ChessPieceName.blackRook, ChessColor.black);
|
||||
|
||||
position[ChessCoordinate(1, 1)] =
|
||||
ChessPiece(ChessPieceName.whiteRook, ChessColor.black);
|
||||
ChessPiece(ChessPieceName.whiteRook, ChessColor.white);
|
||||
position[ChessCoordinate(2, 1)] =
|
||||
ChessPiece(ChessPieceName.whiteKnight, ChessColor.black);
|
||||
ChessPiece(ChessPieceName.whiteKnight, ChessColor.white);
|
||||
position[ChessCoordinate(3, 1)] =
|
||||
ChessPiece(ChessPieceName.whiteBishop, ChessColor.black);
|
||||
ChessPiece(ChessPieceName.whiteBishop, ChessColor.white);
|
||||
position[ChessCoordinate(4, 1)] =
|
||||
ChessPiece(ChessPieceName.whiteQueen, ChessColor.black);
|
||||
ChessPiece(ChessPieceName.whiteQueen, ChessColor.white);
|
||||
position[ChessCoordinate(5, 1)] =
|
||||
ChessPiece(ChessPieceName.whiteKing, ChessColor.black);
|
||||
ChessPiece(ChessPieceName.whiteKing, ChessColor.white);
|
||||
position[ChessCoordinate(6, 1)] =
|
||||
ChessPiece(ChessPieceName.whiteBishop, ChessColor.black);
|
||||
ChessPiece(ChessPieceName.whiteBishop, ChessColor.white);
|
||||
position[ChessCoordinate(7, 1)] =
|
||||
ChessPiece(ChessPieceName.whiteKnight, ChessColor.black);
|
||||
ChessPiece(ChessPieceName.whiteKnight, ChessColor.white);
|
||||
position[ChessCoordinate(8, 1)] =
|
||||
ChessPiece(ChessPieceName.whiteRook, ChessColor.black);
|
||||
ChessPiece(ChessPieceName.whiteRook, ChessColor.white);
|
||||
|
||||
return ChessBoardState._(bottomColor, turnColor, position);
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import 'package:mchess/chess_bloc/chess_events.dart';
|
||||
import 'package:mchess/chess_bloc/chess_bloc.dart';
|
||||
|
||||
import '../connection/ws_connection.dart';
|
||||
@ -73,7 +72,15 @@ class ChessSquare extends StatelessWidget {
|
||||
if (ChessBloc.myColor == null) {
|
||||
allowDrags = 0;
|
||||
} else {
|
||||
allowDrags = ChessBloc.myColor == state.newTurnColor ? 1 : 0;
|
||||
if (containedPiece == null) {
|
||||
allowDrags = 0;
|
||||
} else if (containedPiece!.color == ChessBloc.myColor) {
|
||||
if (ChessBloc.myColor == state.newTurnColor) {
|
||||
allowDrags = 1;
|
||||
} else {
|
||||
allowDrags = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Draggable<ChessMove>(
|
||||
|
Loading…
Reference in New Issue
Block a user