コード例 #1
0
        public static decimal CalculateTeamStrength(sakilaEntities4 db, int teamId, string homeOrAway, int competitionId, DateTime date)
        {
            var marketValue = db.team.First(x => x.TeamID == teamId).MarketValue;

            var seasonalBalance    = PointsCalculator.GetTeamBalance(db, teamId, competitionId, 50, date);
            var seasonalPointsPace = PointsCalculator.CalculatePointPace(seasonalBalance);

            var latestBalance    = PointsCalculator.GetTeamBalance(db, teamId, competitionId, 3, date);
            var latestPointsPace = PointsCalculator.CalculatePointPace(latestBalance);


            var homeOrAwayBalance = new TeamBalance();

            if (homeOrAway == "Home")
            {
                homeOrAwayBalance = PointsCalculator.GetTeamBalanceHome(db, teamId, competitionId, 50, date);
            }
            else
            {
                homeOrAwayBalance = PointsCalculator.GetTeamBalanceAway(db, teamId, competitionId, 50, date);
            }

            var homeOrAwayPointsPace = PointsCalculator.CalculatePointPace(homeOrAwayBalance);

            return(CalculateTeamStrength(marketValue.Value, seasonalPointsPace, latestPointsPace, homeOrAwayPointsPace));
        }
コード例 #2
0
        public static decimal CalculatePointPace(TeamBalance balance)
        {
            var games       = balance.Win + balance.Lost + balance.Draw;
            var totalPoints = balance.Win * 3 + balance.Draw;

            if (games == 0)
            {
                return(0);
            }
            return(Math.Round((decimal)totalPoints / games, 2));
        }
コード例 #3
0
 public TeamOverallBalance(team team, int competitionId, bool isHometeam, List <competitionmatch> relevantMatches)
 {
     TeamSeasonalBalance  = PointsCalculator.GetTeamBalance(relevantMatches, team.TeamID, competitionId);
     TeamLastGamesBalance = PointsCalculator.GetTeamBalance(relevantMatches, team.TeamID, competitionId, 3);
     if (isHometeam)
     {
         TeamHomeOrAwayBalance = PointsCalculator.GetTeamBalanceHome(relevantMatches, team.TeamID, competitionId);
     }
     else
     {
         TeamHomeOrAwayBalance = PointsCalculator.GetTeamBalanceAway(relevantMatches, team.TeamID, competitionId);
     }
 }