예제 #1
0
        private void NextManagerOrContinueDay()
        {
            ManagerAdapter ma = new ManagerAdapter();
            FixtureAdapter fa = new FixtureAdapter();
            WorldAdapter   wa = new WorldAdapter();
            TeamAdapter    ta = new TeamAdapter();

            if (HumanManagers == null)
            {
                // Going to first manager, which means we have to run Start Of Day, unless loading from a savegame
                if (!SaveGameJustLoaded)
                {
                    RunProcesses(false);
                }
                else
                {
                    SaveGameJustLoaded = false;
                }



                HumanManagers       = ma.GetHumanManagers();
                PlayingHumanManager = 0;
                wa.CurrentManagerID = HumanManagers[PlayingHumanManager].UniqueID;

                if (HumanManagers.Count() < 1)
                {
                    throw new Exception("No human managers");
                }
            }
            else
            {
                // Check selections if a matchday
                if (fa.IsTodayAMatchDay(HumanManagers[PlayingHumanManager].CurrentTeam))
                {
                    const int REQUIREDCOUNT = 11;
                    int       PlayerCount   = ta.CountSelectedPlayers(HumanManagers[PlayingHumanManager].CurrentTeam);
                    if (PlayerCount < REQUIREDCOUNT)
                    {
                        UiUtils.OpenDialogBox(UiUtils.MainWindowGrid, LangResources.CurLang.MatchDay,
                                              string.Format(LangResources.CurLang.YouHaveNotSelectedEnoughPlayers, PlayerCount, REQUIREDCOUNT),
                                              new List <DialogButton>()
                        {
                            new DialogButton(LangResources.CurLang.OK, null, null)
                        });

                        return;
                    }
                }

                // Go to next human manager
                PlayingHumanManager++;
                if (PlayingHumanManager >= HumanManagers.Count())
                {
                    HumanManagers       = null;
                    wa.CurrentManagerID = -1;
                }
                else
                {
                    wa.CurrentManagerID = HumanManagers[PlayingHumanManager].UniqueID;
                }
            }

            if (HumanManagers != null)
            {
                // Display home screen for the current manager
                Manager PlayingManager = HumanManagers[PlayingHumanManager];
                ShowHomeScreenForCurrentManager(PlayingManager);

                if (fa.IsTodayAMatchDay(PlayingManager.CurrentTeam))
                {
                    Fixture f          = fa.GetNextFixture(PlayingManager.CurrentTeam, wa.CurrentDate);
                    int     Opposition = (f.TeamIDs[0] != PlayingManager.CurrentTeam ? f.TeamIDs[0] : f.TeamIDs[1]);
                    string  Message    = string.Format(LangResources.CurLang.YouHaveAMatchAgainst, ta.GetTeam(Opposition).Name);

                    UiUtils.OpenDialogBox(UiUtils.MainWindowGrid, LangResources.CurLang.MatchDay, Message,
                                          new List <DialogButton>()
                    {
                        new DialogButton(LangResources.CurLang.OK, null, null)
                    });
                }
            }
            else
            {
                if (fa.IsTodayAMatchDay())
                {
                    ShowGameScreen(new MatchdayMain(), true);
                }
                else
                {
                    RunProcesses(true);
                }
            }
        }