private void checkGameState() //checks if the game is over via checkmate or stalemate { int[] kingLoc = game.findKing(turn); if (((King)game.getBoard()[kingLoc[0], kingLoc[1]]).isCheck(kingLoc, game.getBoard(), colorSel)) { if (((King)game.getBoard()[kingLoc[0], kingLoc[1]]).isCheckMate(colorSel, game.getPieces(), game.getBoard(), turn)) //king is in check and no moves can be made "checkmate" { for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { boardButtons[i, j].Enabled = false; //game is over disable all board buttons } } Label gameOverLabel = new Label(); gameOverLabel.Size = new System.Drawing.Size(250, 13); gameOverLabel.Text = "Game Over: Checkmate "; if (turn == 0) //if it was whites turn next and white is checkmated black wins { gameOverLabel.Text += "Black Wins"; } else //the opposite is true so white wins { gameOverLabel.Text += "White Wins"; } gameOverLabel.Location = new Point(150, 420); Controls.Add(gameOverLabel); //display that the one side has been checkmated and tell who the winner is } } else { if (((King)game.getBoard()[kingLoc[0], kingLoc[1]]).isCheckMate(colorSel, game.getPieces(), game.getBoard(), turn)) //king is not in check but no moves can be made "stalemate" { for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { boardButtons[i, j].Enabled = false; //game is over disable all board buttons } } Label gameOverLabel = new Label(); gameOverLabel.Size = new System.Drawing.Size(250, 13); gameOverLabel.Text = "Game Over: Stalemate"; gameOverLabel.Location = new Point(150, 420); Controls.Add(gameOverLabel); //display that the game is a stalemate } } }