private void SetChallengeStanding(PlayerResult playerResult, Player foundPlayer)
        {
            var handicap = _dataView.GetPlayerHandicap(foundPlayer);
            var fastestLapWithHandicap  = playerResult.FastestLap + handicap;
            var challengePlayerStanding = new ChallengePlayerStanding(foundPlayer, fastestLapWithHandicap);

            _challengeStandings[playerResult.ChallengeId].SetChallengePlayerStanding(challengePlayerStanding);
        }
Example #2
0
        public void SetChallengePlayerStanding(ChallengePlayerStanding challengePlayerStanding)
        {
            var foundChallengePlayerStanding =
                ChallengePlayerStandings.FirstOrDefault(cps => cps.Player.Id == challengePlayerStanding.Player.Id);

            if (foundChallengePlayerStanding != null)
            {
                ChallengePlayerStandings.Remove(foundChallengePlayerStanding);
            }

            ChallengePlayerStandings.Add(challengePlayerStanding);

            SetPositionAndTimeGapProperties();
            OnPropertyChanged(nameof(ChallengePlayerStandings));
        }
        public int CompareTo(object o)
        {
            ChallengePlayerStanding a = this;
            ChallengePlayerStanding b = (ChallengePlayerStanding)o;

            if (a.FastestLapWithHandicap < b.FastestLapWithHandicap)
            {
                return(-1);
            }

            if (a.FastestLapWithHandicap == b.FastestLapWithHandicap)
            {
                return(0);
            }

            return(1);
        }
Example #4
0
        private void SetPositionAndTimeGapProperties()
        {
            ChallengePlayerStanding previousChallengePlayerStanding = null;
            uint count = 1;

            foreach (var challengePlayerStanding in ChallengePlayerStandings)
            {
                if (previousChallengePlayerStanding != null)
                {
                    TimeSpan deltaToPreviousPlayer =
                        challengePlayerStanding.FastestLapWithHandicap - previousChallengePlayerStanding.FastestLapWithHandicap;

                    challengePlayerStanding.GapToPreviousPlayer = deltaToPreviousPlayer;
                }

                challengePlayerStanding.GapToLeader = challengePlayerStanding.FastestLapWithHandicap - ChallengePlayerStandings.First().FastestLapWithHandicap;

                challengePlayerStanding.Position = count;
                count++;
                previousChallengePlayerStanding = challengePlayerStanding;
            }
        }