private void button2_Click(object sender, EventArgs e) { try { HandleData.AnalyseData(data[i]); i++; userControl11.ChessBoardState = Board.BoardState; } catch (Exception) { } }
private void button3_Click(object sender, EventArgs e) { data = HandleData.GetData(); }
private void userControl11_MouseDown(object sender, MouseEventArgs e) { // checks if ClickableGame is turned on if (!Board.ClickableGame) { return; } int step = userControl11.Size.Width / 8; int x = e.Location.X / step + 1; int y = e.Location.Y / step + 1; bool movement_click = (Board.PossibleLocations.Count > 0) ? true : false; // player wants to move the piece if (movement_click) { Tuple <int, int> position = new Tuple <int, int>(x, y); //check if movement is possible if (Board.PossibleLocations.Contains(position)) { System.Text.StringBuilder temp_stringBuilder = new System.Text.StringBuilder(Board.BoardState); // first element of possible locations is the location of the selected piece. Piece piece = (Piece)Board.PosToPiece[Board.PossibleLocations[0]]; // change old location to x temp_stringBuilder[(piece.x - 1) + (piece.y - 1) * 8] = 'x'; // and new location to type identifier. temp_stringBuilder[(position.Item1 - 1) + (position.Item2 - 1) * 8] = piece.identifier; // send to analyse data and chage boardstate HandleData.AnalyseData(temp_stringBuilder.ToString()); userControl11.ChessBoardState = Board.BoardState; // empty list } else { } Board.PossibleLocations = new List <Tuple <int, int> >(); } else { if (authentication.checkPosToPiece(x, y)) { Piece piece = (Piece)Board.PosToPiece[new Tuple <int, int>(x, y)]; Board.PossibleLocations.Add(new Tuple <int, int>(x, y)); for (x = 1; x < 9; x++) { for (y = 1; y < 9; y++) { if (piece.check(x, y)) { Board.PossibleLocations.Add(new Tuple <int, int>(x, y)); } } } } } userControl11.LocationsToColour = Board.PossibleLocations; textBox1.AppendText("\n"); textBox1.AppendText(Board.tempData); }