Пример #1
0
        public void Handle(ParticipantGameCompleted e)
        {
            var participant = Participants.Single(x => x.Id == e.ParticipantId);
            var game        = participant.Scores.SingleOrDefault(x => x.MatchId == e.Id);

            if (game != null)
            {
                //Adjust Totals
                participant.NationalTotal     = participant.NationalTotal - game.Scratch;
                participant.NationalTotalPOA -= game.POA;
                participant.NationalGames    -= 1;
                participant.NationalWins     -= (game.WinLossTie == "W" ? 1M : game.WinLossTie == "T" ? .5M : 0M);
                participant.OpponentTotal    -= game.OpponentScratch;
                participant.OpponentTotalPOA -= game.OpponentPOA;

                //Remove old game
                participant.Scores.Remove(game);
            }

            participant.Scores.Add(new Score
            {
                MatchId    = e.Id,
                Number     = e.Number,
                Scratch    = e.Score,
                POA        = e.POA,
                WinLossTie = e.IsPOA
                    ? (e.POA > e.OpponentPOA ? "W" : e.POA < e.OpponentPOA ? "L" : "T")
                    : (e.Score > e.OpponentScore ? "W" : e.Score < e.OpponentScore ? "L" : "T"),
                Lane             = e.Lane,
                Centre           = e.Centre,
                OpponentId       = e.OpponentId,
                OpponentProvince = e.Opponent,
                OpponentName     = e.OpponentName,
                OpponentScratch  = e.OpponentScore,
                OpponentPOA      = e.OpponentPOA,
                IsPOA            = e.IsPOA
            });

            participant.Name               = e.Name;
            participant.Division           = e.Division;
            participant.Province           = e.Contingent;
            participant.NationalGames     += 1;
            participant.NationalTotal     += e.Score;
            participant.NationalAverage    = participant.NationalTotal / participant.NationalGames;
            participant.NationalWins      += e.Points > 0M ? (e.Points % 1M == 0M ? 1M : .5M) : 0M;
            participant.NationalTotalPOA  += e.POA;
            participant.NationalAveragePOA = participant.NationalTotalPOA / participant.NationalGames;
            participant.OpponentTotal     += e.OpponentScore;
            participant.OpponentTotalPOA  += e.OpponentPOA;
            participant.OpponentAverage    = participant.OpponentTotal / participant.NationalGames;
            participant.OpponentAveragePOA = participant.OpponentTotalPOA / participant.NationalGames;

            participant.HighScore = participant.Scores.Max(x => x.Scratch);
            participant.HighPOA   = participant.Scores.Max(x => x.POA);
        }
Пример #2
0
        public void Handle(ParticipantGameCompleted e)
        {
            var divisionName = SimplifyDivision(e.Division);
            var year         = "2014";

            if (MatchYearLookup.ContainsKey(e.Id))
            {
                year = MatchYearLookup[e.Id];
            }

            var division = Divisions.SingleOrDefault(x => x.Name == divisionName && x.Year == year);

            if (division == null)
            {
                division = new Division
                {
                    Name = divisionName,
                    Year = year
                };

                Divisions.Add(division);
            }

            var participant = division.Participants.SingleOrDefault(x => x.ParticipantId == e.ParticipantId);

            if (participant == null)
            {
                participant = new Participant
                {
                    ParticipantId = e.ParticipantId,
                    Scores        = new List <Score>()
                };
                division.Participants.Add(participant);
            }

            participant.Scores.RemoveAll(x => x.MatchId == e.Id);
            participant.Name   = e.Name;
            participant.Gender = e.Gender;
            participant.Scores.Add(new Score {
                MatchId = e.Id, Scratch = e.Score, Wins = e.IsPOA
                    ? (e.POA > e.OpponentPOA ? 1M : e.POA < e.OpponentPOA ? 0M : .5M)
                    : (e.Score > e.OpponentScore ? 1M : e.Score < e.OpponentScore ? 0M : .5M),
            });

            participant.Total   = participant.Scores.Sum(x => x.Scratch);
            participant.Wins    = participant.Scores.Sum(x => x.Wins);
            participant.Average = 1.0M * participant.Total / participant.Scores.Count;
        }
Пример #3
0
        public void Handle(ParticipantGameCompleted e)
        {
            var match = Matches[e.Id];
            var team  = (match.Home.Province == e.Contingent) ? match.Home : match.Away;

            team.Bowlers.RemoveAll(x => x.Id == e.ParticipantId);
            team.Bowlers.Add(new Bowler
            {
                Id       = e.ParticipantId,
                Name     = e.Name,
                Position = e.Position,
                Score    = e.Score,
                POA      = e.POA,
                Points   = e.Points
            });
        }
Пример #4
0
        public void Handle(ParticipantGameCompleted e)
        {
            var divisionName = SimplifyDivision(e.Division);
            var year         = "2014";

            if (Matches.ContainsKey(e.Id))
            {
                year = Matches[e.Id];
            }

            var division = Divisions.SingleOrDefault(x => x.Name == divisionName && x.Year == year);

            if (division == null)
            {
                division = new Division
                {
                    Name = divisionName,
                    Year = year
                };

                Divisions.Add(division);
            }

            division.Scores.RemoveAll(x => x.MatchId == e.Id && x.ParticipantId == e.ParticipantId);

            if (divisionName.Equals("Tournament", StringComparison.OrdinalIgnoreCase) && e.Score < 275)
            {
                return;
            }
            if (!divisionName.Equals("Tournament", StringComparison.OrdinalIgnoreCase) && e.POA < 75)
            {
                return;
            }

            division.Scores.Add(new Score
            {
                Gender        = e.Gender,
                MatchId       = e.Id,
                Name          = e.Name,
                ParticipantId = e.ParticipantId,
                POA           = e.POA,
                Scratch       = e.Score,
                Year          = year
            });
        }
Пример #5
0
 public void Apply(ParticipantGameCompleted e)
 {
     //TODO:
 }