Exemplo n.º 1
0
        public static Season NewSeason()
        {
            if (Seasons == null)
            {
                Seasons = new List <Season>();
            }

            var newSeason = new Season
            {
                Id = !Seasons.Any() ? 1 : Seasons.Max(s => s.Id) + 1
            };

            for (var division = 1; division <= GameData.Divisions; division++)
            {
                TeamStatsData.CreateDivisionData(newSeason.Id, division);
            }

            GameData.CurrentSeason = newSeason.Id;
            GameData.CurrentWeek   = 1;

            MatchData.CreateSeasonFixtures(newSeason.Id);

            Seasons.Add(newSeason);
            NewsData.AddNewsItem("New Season !!");
            TeamData.AutoSelectAllTeams();

            if (GameData.SkipToLastWeekOfSeason)
            {
                MatchData.PlayAllMatchesForSeason();
                GameData.CurrentWeek = GameData.WeeksInSeason;
                NewsData.AddNewsItem("Last week of season!");
            }

            return(newSeason);
        }
Exemplo n.º 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);
        }