示例#1
0
        private static void EnterGame(Tuple <PasswordOAuthContext, string> loginContext)
        {
            Console.Clear();

            var gameClient         = ApiHelper.GetGameClient(loginContext.Item1);
            var gr                 = new GameRunner(loginContext.Item2, loginContext.Item1, gameClient);
            var adminManagerClient = ApiHelper.GetAdminClient(loginContext.Item1);
            var ac                 = new AdminConsole(loginContext.Item2, _userPassword, loginContext.Item1, adminManagerClient, _serverInfo, _serverPort);
            var gameData           = gr.GetGameData();

            gr.DisplayGameData(gameData);
            ConsoleKeyInfo keyInfo;

            while ((keyInfo = Console.ReadKey(true)).Key != ConsoleKey.Escape)
            {
                try
                {
                    if (keyInfo.Key == ConsoleKey.Enter)
                    {
                        gr.PerformManualStep();
                    }
                    else if ((int)keyInfo.Key >= 65 && (int)keyInfo.Key <= 90)
                    {
                        gr.BuyFundDriver(keyInfo);
                    }
                    else if (keyInfo.Key == ConsoleKey.Multiply)
                    {
                        gr.FightAgainstCorruption();
                    }
                    else if (keyInfo.Key == ConsoleKey.Add)
                    {
                        gr.PerformFiveYearPlan();
                    }
                    else if (keyInfo.Key == ConsoleKey.F5)
                    {
                        gr.DisplayGameData(gr.GetGameData());
                    }
                    else if (keyInfo.Key == ConsoleKey.F2)
                    {
                        ac.StartMenu();

                        gr.Invalidate();
                    }
                    else if (keyInfo.Key == ConsoleKey.F3)
                    {
                        ErrorCode = ApiHelper.UserLogout(gr.ServerContext);
                        _userName = null;
                        break;
                    }

                    if (gr.ErrorCode != null)
                    {
                        if (gr.ErrorCode == ErrorCodes.InvalidSessionError || gr.ErrorCode == ErrorCodes.OtherError)
                        {
                            gr.Invalidate();
                            return;
                        }
                    }
                }

                catch (Exception)
                {
                }
            }
        }