Example #1
0
        /// <summary>
        /// Run all the matches for the current game date
        /// </summary>
        /// <param name="MatchCallback"></param>
        public void Run(IMatchCallback MatchCallback)
        {
            MatchPlayer    mp = new MatchPlayer();
            WorldAdapter   wa = new WorldAdapter();
            FixtureAdapter fa = new FixtureAdapter();
            TeamAdapter    ta = new TeamAdapter();
            ManagerAdapter ma = new ManagerAdapter();

            foreach (Fixture f in fa.GetFixtures(wa.CurrentDate))
            {
                mp.Fixture     = f;
                mp.Interactive = false;

                for (int t = 0; t <= 1; t++)
                {
                    if (ma.GetManager(ta.GetTeam(f.TeamIDs[t]).ManagerID).Human)
                    {
                        mp.Interactive = true;
                        break;
                    }
                }

                mp.MatchCallback = MatchCallback;
                mp.StartMatch();
            }

            MatchCallback.MatchdayComplete();
        }
Example #2
0
        /// <summary>
        /// Loop round all AI teams, and select a team appropriate to play the fixture.
        /// </summary>
        public void SelectTeamIfPlaying()
        {
            FixtureAdapter fa = new FixtureAdapter();
            WorldAdapter   wa = new WorldAdapter();
            TeamAdapter    ta = new TeamAdapter();
            ManagerAdapter ma = new ManagerAdapter();

            List <Fixture> AllFixtures = fa.GetFixtures(wa.CurrentDate);

            int TESTf = 0;

            foreach (Fixture f in AllFixtures)
            {
                TESTf++;
                Debug.Print("Fixture " + f.ToString());

                for (int t = 0; t <= 1; t++)
                {
                    Team    ThisTeam = ta.GetTeam(f.TeamIDs[t]);
                    Manager M        = ma.GetManager(ThisTeam.ManagerID);


                    if (!M.Human)
                    {
                        Team          Opposition = ta.GetTeam(f.TeamIDs[1 - t]);
                        PlayerAdapter pa         = new PlayerAdapter();
                        int[,] PlayerGridPositions = new int[5, 8]; // TODO: Maybe not hard code these...
                        for (int x = 0; x <= PlayerGridPositions.GetUpperBound(0); x++)
                        {
                            for (int y = 0; y <= PlayerGridPositions.GetUpperBound(1); y++)
                            {
                                PlayerGridPositions[x, y] = -1;
                            }
                        }


                        Formation TeamFormation      = new FormationAdapter().GetFormation(ThisTeam.CurrentFormation);
                        List <AvailablePlayer> avail = GetEligiblePlayers(ThisTeam, f);

                        foreach (Point2 point in TeamFormation.Points)
                        {
                            AvailablePlayer SelPlayer = FindBestPlayerForPosition(point, avail);
                            if (SelPlayer == null)
                            {
                                throw new Exception("Unable to find a player for this position");
                            }

                            PlayerGridPositions[point.X, point.Y] = SelPlayer.PlayerID;
                            avail.Remove(SelPlayer);
                        }

                        ta.SavePlayerFormation(ThisTeam.UniqueID, TeamFormation.UniqueID, PlayerGridPositions);
                    }
                }
            }
        }
        public ScreenReturnData MainButtonClick(int buttonId)
        {
            if (!MatchdayComplete)
            {
                Thread rm = new Thread(this.RunMatchday);
                rm.IsBackground = true;
                rm.Start();

                return(new ScreenReturnData(ScreenReturnCode.None));
            }
            else
            {
                FixtureAdapter fa = new FixtureAdapter();
                WorldAdapter   wa = new WorldAdapter();

                SetupData.Parent.ShowResultsScreen(fa.GetFixtures(wa.CurrentDate));
                return(new ScreenReturnData(ScreenReturnCode.None));
            }
        }