Пример #1
0
        static void Main()
        {
            CardSetPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\JoePitt\\Cards\\";

            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += CurrentDomain_UnhandledException;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Running baseUI = new Running();

            baseUI.Show();
            waiting = new Waiting();

            try
            {
                if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData != null)
                {
                    string arg = Uri.UnescapeDataString(AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0].Substring(8));
                    if (File.Exists(arg))
                    {
                        if (arg.EndsWith(".cardset"))
                        {
                            Dealer.InstallCardSet(arg);
                        }
                    }
                }
            }
            catch { }

NewGame:
            if (Setup())
            {
                while (CurrentGame.Playable)
                {
                    LeaderBoard.UpdateScores();
                    CurrentPlayer             = CurrentGame.LocalPlayers[0];
                    CurrentPlayer.NextCommand = "GAMEUPDATE";
                    CurrentPlayer.NewCommand  = true;
                    while (!CurrentPlayer.NewResponse)
                    {
                        Application.DoEvents();
                    }
                    string[] response = CurrentPlayer.LastResponse.Split(' ');
                    CurrentPlayer.NewResponse = false;

                    switch (response[0])
                    {
                    case "WAITING":
                        CurrentGame.Stage = 'W';
                        Wait();
                        break;

                    case "PLAYING":
                        CurrentGame.Stage = 'P';
                        CurrentGame.Round = Convert.ToInt32(response[2]);
                        Play();
                        break;

                    case "VOTING":
                        CurrentGame.Stage = 'V';
                        Vote();
                        break;

                    case "END":
                        CurrentGame.Stage = 'E';
                        if (Replay())
                        {
                            goto NewGame;
                        }
                        else
                        {
                            Exit();
                        }
                        break;

                    default:
                        MessageBox.Show("Unexpected Error! Unknown Game State, Application will exit!", "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        Exit();
                        break;
                    }
                }
                CurrentGame.Stop();
            }
            Exit();
        }