Пример #1
0
        private static Match ParseMatch(dynamic json)
        {
            var blueParticipation = new MatchParticipation
            {
                Side    = Side.Blue,
                TeamId  = json.opponents[0].opponent.id,
                MatchId = json.id
            };
            var redParticipation = new MatchParticipation
            {
                Side    = Side.Red,
                TeamId  = json.opponents[1].opponent.id,
                MatchId = json.id
            };
            var match = new Match
            {
                Id        = json.id,
                BlueScore = json.results[0].team_id == blueParticipation.TeamId
                    ? json.results[0].score
                    : json.results[1].score,
                RedScore = json.results[0].team_id == redParticipation.TeamId
                    ? json.results[0].score
                    : json.results[1].score,
                BestOf         = json.number_of_games,
                Participations = new List <MatchParticipation> {
                    blueParticipation, redParticipation
                },
                StartDateTime = json.begin_at
            };

            return(match);
        }
Пример #2
0
        public ActionResult OptimiseKFactor()
        {
            var eloFixtures = new List <Contest <Player> >();

            foreach (var match in _matchService.GetMatches())
            {
                var matchParticipationsList = match.MatchParticipations.ToList();
                var player1mp = matchParticipationsList[0];
                MatchParticipation player2mp = matchParticipationsList[1];

                eloFixtures.Add(new Contest <Player>
                {
                    Player1 = player1mp.Player,
                    Player2 = player2mp.Player,
                    Result  = player1mp.Winner ? ContestResult.Player1Won : ContestResult.Player2Won
                });
            }

            KFactorCalculator <Player> calculator = new KFactorCalculator <Player>(eloFixtures, 25);

            return(View(calculator.GetResults()));
        }
Пример #3
0
        private MatchParticipation CreateMatchParticipation(int playerId, int opponentId, bool winner, DateTime matchDate, int playerLadderRank, int opponentLadderRank)
        {
            var matchParticipation = new MatchParticipation()
            {
                PlayerID = playerId, Winner = winner
            };

            foreach (var comp in db.Competitions.ToList())
            {
                if (comp.GetType() == typeof(AllTimeCompetition))
                {
                    matchParticipation.AllTimeCompetition       = comp;
                    matchParticipation.AllTimeCompetitionResult = CalculateEloRatings(playerId, opponentId, winner, (AllTimeCompetition)comp);
                }
                else
                {
                    matchParticipation.MonthlyCompetition       = comp;
                    matchParticipation.MonthlyCompetitionResult = CalculateLadderRankings(
                        playerId, opponentId, winner, (MonthlyCompetition)comp, matchDate, playerLadderRank, opponentLadderRank);
                }
            }

            return(matchParticipation);
        }