private void RearangePiecesLoad(Board curBoard) { int[,] piecePositions = curBoard.GetPiecePositions(); int curPieceNumber = 0; int[] blackCaptured = new int[2] { 1, 1 }; int[] whiteCaptured = new int[2] { 1, 1 }; for (int i = 0; i < 8; i++) { for (int k = 0; k < 8; k++) { curPieceNumber = piecePositions[i, k]; if (curPieceNumber == 0) { continue; } else { Button curPiece = (Button)this.FindName($"p{curPieceNumber}"); //need to check if it is in grid or in captured grid Grid.SetRow(curPiece, i + 1); Grid.SetColumn(curPiece, k + 1); } } } foreach (int piece in curBoard.GetCapturedPieces()) { Button curPiece = (Button)this.FindName($"p{piece}"); if (piece < 17) { Grid.SetRow(curPiece, whiteCaptured[0]); Grid.SetColumn(curPiece, whiteCaptured[1]); getGrid().Children.Remove(curPiece); UIGlobal.getPlayer2Grid().Children.Add(curPiece); if (whiteCaptured[1] == 2) //increments grid location { whiteCaptured[0]++; whiteCaptured[1] = 1; } else { whiteCaptured[1]++; } } else { Grid.SetRow(curPiece, blackCaptured[0]); Grid.SetColumn(curPiece, blackCaptured[1]); getGrid().Children.Remove(curPiece); UIGlobal.getPlayer1Grid().Children.Add(curPiece); if (blackCaptured[1] == 2) //increments grid location { blackCaptured[0]++; blackCaptured[1] = 1; } else { blackCaptured[1]++; } } } if (chessBoard.GetTurn() == 0) //turn = 0 is white, turn = 1 is black { for (int i = 1; i < 17; i++) //sets all the white buttons to an opacity of 1 and enables the buttons { Button curButton = UIGlobal.XAMLpage.FindName($"p{i}") as Button; //gets piece by name if (!curButton.IsEnabled && curButton.Opacity == 1) //checks to see if it is in the captured bank { continue; } curButton.IsEnabled = true; curButton.Opacity = 1; } for (int i = 17; i < 33; i++) //sets all the black buttons to an opacity of .7 and disables the buttons { Button curButton = UIGlobal.XAMLpage.FindName($"p{i}") as Button; //gets piece by name if (!curButton.IsEnabled && curButton.Opacity == 1) //checks to see if it is in the captured bank { continue; } curButton.IsEnabled = false; curButton.Opacity = .7; } } else { for (int i = 1; i < 17; i++) //sets all the white buttons to an opacity of .7 and disables the buttons { Button curButton = UIGlobal.XAMLpage.FindName($"p{i}") as Button; //gets piece by name if (!curButton.IsEnabled && curButton.Opacity == 1) //checks to see if it is in the captured bank { continue; } curButton.IsEnabled = false; curButton.Opacity = .7; } for (int i = 17; i < 33; i++) //sets all the black buttons to an opacity of 1 and enables the buttons { Button curButton = UIGlobal.XAMLpage.FindName($"p{i}") as Button; //gets piece by name if (!curButton.IsEnabled && curButton.Opacity == 1) //checks to see if it is in the captured bank { continue; } curButton.IsEnabled = true; curButton.Opacity = 1; } } }