Beispiel #1
0
        private string GetEmailBodyTranslated(Email e, EmailTemplate t)
        {
            EmailTemplate template = GetEmailTemplate(e);
            string        retVal   = template.Body;

            ManagerAdapter ma = new ManagerAdapter();
            TeamAdapter    ta = new TeamAdapter();

            switch (template.Type)
            {
            case EmailType.Welcome:
                retVal = string.Format(retVal,
                                       ma.GetManager(e.Data[0]).DisplayName(PersonNameReturnType.FirstnameLastname),
                                       ta.GetTeam(e.Data[1]).Name);
                break;

            case EmailType.GoodMatch:
            case EmailType.BadMatch:
                retVal = string.Format(retVal,
                                       e.Data[0].ToString(),
                                       e.Data[1].ToString(),
                                       ta.GetTeam(e.Data[2]).Name);
                break;

            default:
                throw new Exception("Unknown email type");
            }


            return(retVal);
        }
        /// <summary>
        /// Returns a fairly nice to use league table, transposing the most important
        /// data into a simple format
        /// </summary>
        /// <param name="LeagueID"></param>
        /// <returns></returns>
        public List <LeagueTableRecord> LeagueTable(int LeagueID)
        {
            List <LeagueTableRecord> Records = new List <LeagueTableRecord>();

            TeamAdapter ta = new TeamAdapter();

            foreach (Team t in ta.GetTeamsByLeague(LeagueID))
            {
                LeagueTableRecord ltr = new LeagueTableRecord();
                ltr.TeamID           = t.UniqueID;
                ltr.Name             = t.Name;
                ltr.SeasonStatistics = t.SeasonStatistics;

                Records.Add(ltr);
                ltr = null;
            }

            List <LeagueTableRecord> retVal = (from ltr in Records
                                               orderby ltr.SeasonStatistics.Points descending,
                                               ltr.SeasonStatistics.GoalDifference descending,
                                               ltr.SeasonStatistics.GoalsScored descending,
                                               ltr.Name ascending
                                               select ltr).ToList();


            return(retVal);
        }
Beispiel #3
0
        private void CreateTeams()
        {
            string[] TeamFirstName = TextResources.TeamList(TeamListResource.Place, ResourceLanguage.en);
            string[] TeamLastName  = TextResources.TeamList(TeamListResource.Suffix, ResourceLanguage.en);

            List <string> AvailableNames = new List <string>();

            Maths         rand    = new Maths();
            LeagueAdapter la      = new LeagueAdapter();
            TeamAdapter   ta      = new TeamAdapter();
            List <League> Leagues = la.GetLeagues();

            foreach (League L in Leagues)
            {
                for (int i = 0; i <= MAXTEAMSPERLEAGUE - 1; i++)
                {
                    if (AvailableNames.Count == 0)
                    {
                        AvailableNames = TeamFirstName.ToList();
                    }

                    int r;

                    Team NewTeam = new Team();
                    NewTeam.SeasonStatistics = new TeamStats();

                    r            = rand.RandomInclusive(0, AvailableNames.Count - 1);
                    NewTeam.Name = AvailableNames[r] + " ";
                    AvailableNames.RemoveAt(r);

                    r                        = rand.RandomInclusive(0, TeamLastName.GetUpperBound(0));
                    NewTeam.Name             = NewTeam.Name + TeamLastName[r];
                    NewTeam.LeagueID         = L.UniqueID;
                    NewTeam.CurrentFormation = rand.RandomInclusive(0, maxFormationID);


                    int NewID = ta.AddTeam(NewTeam);
                    AssignPlayersToTeam(NewID, L.PlayerEffectivenessBase);

                    // TODO: Temporary AI manager assignment needs replacing
                    Manager NewManager = new Manager();
                    NewManager.FirstName   = "Alan";
                    NewManager.LastName    = NewTeam.Name.Split(Convert.ToChar(" "))[0];
                    NewManager.DateOfBirth = new DateTime(1966, 9, 26);
                    NewManager.Reputation  = rand.RandomInclusive(30, 90);

                    ManagerAdapter ma           = new ManagerAdapter();
                    int            NewManagerID = ma.AddManager(NewManager);
                    ma.AssignToTeam(NewManagerID, NewID);
                }
            }
        }