/* * When the user wants to start a new game, checking occurs that 2 different players have * been chosen. If they have been, the game board Form is shown in a Dialog, after which * the ratings in both the player list and combo box lists are updated */ private void btnStart_Click(object sender, EventArgs e) { if (cmbPlayer1.SelectedIndex != -1 && cmbPlayer2.SelectedIndex != -1 && cmbPlayer2.SelectedIndex != cmbPlayer1.SelectedIndex) { Player player1 = this.playerList[cmbPlayer1.SelectedIndex]; player1.Colour = Piece.NOTATION_W; Player player2 = this.playerList[cmbPlayer2.SelectedIndex]; player2.Colour = Piece.NOTATION_B; Form board = new Board2(player1, player2); this.Hide(); board.ShowDialog(); this.Show(); cmbPlayer1.Items[cmbPlayer1.SelectedIndex] = player1; cmbPlayer1.Items[cmbPlayer2.SelectedIndex] = player2; cmbPlayer2.Items[cmbPlayer1.SelectedIndex] = player1; cmbPlayer2.Items[cmbPlayer2.SelectedIndex] = player2; playerList[cmbPlayer1.SelectedIndex] = player1; playerList[cmbPlayer2.SelectedIndex] = player2; } else { MessageBox.Show("Please select 2 different players!"); } }
private void gameFromFENToolStripMenuItem_Click(object sender, EventArgs e) { // Check that 2 different players are selected if (cmbPlayer1.SelectedIndex == -1 || cmbPlayer2.SelectedIndex == -1 || cmbPlayer1.SelectedIndex == cmbPlayer2.SelectedIndex) { MessageBox.Show("Please select 2 unique players!"); } else { FENSpecifier fenRetriever = new FENSpecifier(SerializationModes.Input); // Open dialog to enter FEN string if (fenRetriever.ShowDialog() == DialogResult.OK && !String.IsNullOrEmpty(fenRetriever.Result)) { Game g = new Game((Player)cmbPlayer1.SelectedItem, (Player)cmbPlayer2.SelectedItem); Board2 b = new Board2(g, fenRetriever.Result); b.Show(); } } }