Exemplo n.º 1
0
        private void startBut_Click(object sender, RoutedEventArgs e)
        {
            string typeTournament = ComBoxTournaments.Text;
            int    int_index      = 0;

            if (ComBoxTournaments.Text == "Title")
            {
                string index = TitleTeamIndexTexB.Text;
                if (!int.TryParse(index, out int_index))
                {
                    MessageBox.Show(
                        "You have to choose the Title Team, for this kind of tourament", "Warning",
                        MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }
            }

            if (gameName == "Tic Tac Toe")
            {
                if (!(createdPlayers.Count >= FourInLineGame.ValidNumberOfPlayers))
                {
                    MessageBox.Show("The number of players is not valid, get back to the previus window and fixed", "Error", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                    return;
                }
            }
            else if (gameName == "Four in Line")
            {
                if (!(createdPlayers.Count >= FourInLineGame.ValidNumberOfPlayers))
                {
                    MessageBox.Show("The number of players is not valid, get back to the previus window and fixed", "Error", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                    return;
                }
            }

            Log.StartTournament += LogOn;
            Log.EndTournament   += LogOn;

            if (MatchCheckB.IsChecked == true)
            {
                Log.EndMatch   += LogOn;
                Log.StartMatch += LogOn;
            }

            if (PlaysCheckB.IsChecked == true)
            {
                Log.Play += LogOn;
            }

            if (GamesCheckB.IsChecked == true)
            {
                Log.StartGame += LogOn;
                Log.EndGame   += LogOn;
            }

            if (ComBoxTournaments.SelectedValue != string.Empty)
            {
                AutomaticBut.IsEnabled  = true;
                GameBut.IsEnabled       = true;
                TournamentBut.IsEnabled = true;
                matchBut.IsEnabled      = true;
                PlayBut.IsEnabled       = true;

                TitelLab.IsEnabled           = false;
                TitleTeamIndexTexB.IsEnabled = false;

                GamesCheckB.IsEnabled = false;
                PlaysCheckB.IsEnabled = false;
                MatchCheckB.IsEnabled = false;

                PreviousBut.IsEnabled       = false;
                ComBoxTournaments.IsEnabled = false;
                startBut.IsEnabled          = false;

                if (gameName == "Tic Tac Toe")
                {
                    List <Team <TicTacToe> > teams = CreateTeams <TicTacToe>();

                    if (ComBoxTournaments.Text == "Title")
                    {
                        current_tournament = new Title <TictactoeMatch, TicTacToeGame, TicTacToe>(int_index, teams);
                    }
                    if (ComBoxTournaments.Text == "TwoByTwo")
                    {
                        current_tournament = new TwoByTwo <TictactoeMatch, TicTacToeGame, TicTacToe>(teams);
                    }

                    if (ComBoxTournaments.Text == "Individual Classification")
                    {
                        current_tournament = new IndividualClassification <TictactoeMatch, TicTacToeGame, TicTacToe>(teams);
                    }

                    current_tournament.Start();
                }
                else if (gameName == "Four in Line")
                {
                    List <Team <FourInLine> > teamsFourinline = CreateTeams <FourInLine>();

                    if (ComBoxTournaments.Text == "Title")
                    {
                        current_tournament = new Title <FourInLineMatch, FourInLineGame, FourInLine>(
                            int_index, teamsFourinline);
                    }

                    if (ComBoxTournaments.Text == "TwoByTwo")
                    {
                        current_tournament = new TwoByTwo <FourInLineMatch, FourInLineGame, FourInLine>(teamsFourinline);
                    }

                    if (ComBoxTournaments.Text == "Individual Classification")
                    {
                        current_tournament = new IndividualClassification <FourInLineMatch, FourInLineGame, FourInLine>(teamsFourinline);
                    }


                    current_tournament.Start();
                }
                else
                {
                    MessageBox.Show("The selected game is not available", "Error", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }
            }
        }