Beispiel #1
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);
        }
Beispiel #2
0
        public static void AddNewPlayer(string name, int teamId, int rating,
                                        PlayerPositionsEnum pos, int value, int age, int contract)
        {
            var newPlayer = new Player
            {
                Id       = GetNextId(),
                Status   = PlayerStatusEnum.Active,
                Age      = age,
                Name     = name,
                Position = pos,
                Value    = value,
                Rating   = rating,
                Selected = false,
                TeamId   = teamId,
                Contract = contract
            };

            Players.Add(newPlayer);

            PlayerAttributesData.AddPlayerAttributesForPlayer(newPlayer);
            PlayerStatsData.AddPlayerStatsForPlayer(newPlayer);
        }