示例#1
0
文件: TeamStatsData.cs 项目: srog/FMS
 public static void CreateDivisionData(int seasonId, int divisionId)
 {
     foreach (var team in TeamData.GetTeamsByDivisionId(divisionId))
     {
         var teamstat = new TeamStats()
         {
             Id           = GetNextId(),
             DivisionId   = divisionId,
             SeasonId     = seasonId,
             TeamId       = team.Id,
             Played       = 0,
             Won          = 0,
             Drawn        = 0,
             Lost         = 0,
             GoalsFor     = 0,
             GoalsAgainst = 0
         };
         TeamStats.Add(teamstat);
     }
 }
示例#2
0
        public static Match PlayMatch(int id)
        {
            var match = Matches.FirstOrDefault(m => m.Id == id);

            var homeTeam = TeamData.GetTeamById(match.HomeTeamId);
            var awayTeam = TeamData.GetTeamById(match.AwayTeamId);

            // auto-select teams and formation
            TeamData.AutoSelectTeam(match.HomeTeamId);
            TeamData.AutoSelectTeam(match.AwayTeamId);

            var ratingDiff   = homeTeam.TeamRating - awayTeam.TeamRating;
            var homeQuotient = 5
                               + (ratingDiff > 0 ? 1 : 0)
                               + (ratingDiff < 0 ? -1 : 0)
                               + (ratingDiff > 20 ? 1 : 0)
                               + (ratingDiff < -20 ? -1 : 0)
                               + (ratingDiff > 40 ? 1 : 0);

            var awayQuotient = 5
                               + (ratingDiff < 0 ? 1 : 0)
                               + (ratingDiff > 0 ? -1 : 0)
                               + (ratingDiff < 20 ? 1 : 0)
                               + (ratingDiff > -20 ? -1 : 0)
                               + (ratingDiff < 40 ? 1 : 0);

            match.HomeTeamScore = rnd.Next(1, homeQuotient) - 1;
            match.AwayTeamScore = rnd.Next(1, awayQuotient) - 1;

            match.Completed = "Yes";

            MatchEventsData.CreateMatchEvents(match);
            // TODO - Reverse this process so events are generated first
            // use all ratings, fitness, form to determine event flow

            TeamStatsData.UpdateWithMatch(match);
            PlayerStatsData.UpdateWithMatch(match);

            return(match);
        }
示例#3
0
文件: SeasonData.cs 项目: srog/FMS
        private static void PromoteOrRelegateTeams()
        {
            var proNews = "Promoted: ";
            var relNews = "Relegated: ";

            foreach (var prorel in ProRelData.GetProRelInfoForSeason(GameData.CurrentSeason))
            {
                var team = TeamData.GetTeamById(prorel.TeamId);
                if (prorel.Status == "Relegated")
                {
                    team.DivisionId++;
                    relNews += team.Name + ",";
                }
                else
                {
                    team.DivisionId--;
                    proNews += team.Name + ",";
                }
            }
            proNews.TrimEnd(',');
            relNews.TrimEnd(',');
            NewsData.AddNewsItem(proNews);
            NewsData.AddNewsItem(relNews);
        }