public void SquareClicked(IGridLocation clickedLocation) { ISquare clickedSquare = CurrentBoard[clickedLocation]; // If a piece is selected, try to move to the chosen location. if (SquareSelected) { Move attemptedMove = new Move(SelectedSquare.Location, clickedLocation); // If this is a possible move, execute the move. Then clear the selection either way. foreach (Move move in AvailableMoves.Where(move => move.Equals(attemptedMove))) { Execute(move); SendMoveMade(); return; } } if (clickedSquare.Type != PieceType.None && clickedSquare.Colour == PlayingColour) { SelectedSquare = clickedSquare; SquareSelected = true; SendHighlightsRequested(CurrentBoard.AvailableDestinations(SelectedSquare)); return; } }