Example #1
0
        protected virtual async Task <NascarEvent> GenerateNewEvent(int trackId, int seriesId)
        {
            NascarTrack track = await _trackRepository.GetAsync(trackId);

            NascarSeries series = await _seriesRepository.GetAsync(1);

            return(await _eventGenerator.GenerateEventAsync(track, series));
        }
Example #2
0
        public VehicleLapService(NascarTrack track)
        {
            if (track == null)
            {
                throw new ArgumentNullException(nameof(track));
            }

            LapTimeService = new LapTimeService(track);
        }
Example #3
0
        public async Task <NascarEvent> GenerateEventAsync(NascarTrack track, NascarSeries series)
        {
            try
            {
                var vehicles = await _vehicleRepository.GetListAsync();

                var newEvent = new NascarEvent(track, series, vehicles.Take(50).ToList());

                newEvent = await _eventRepository.Save(newEvent);

                return(newEvent);
            }
            catch (Exception ex)
            {
                return(await Task.FromException <NascarEvent>(ex));
            }
        }
Example #4
0
        public LapTimeService(NascarTrack track)
        {
            if (track == null)
            {
                throw new ArgumentNullException(nameof(track));
            }

            if (track.Falloff < 0 || track.Falloff > 1)
            {
                throw new ArgumentOutOfRangeException(nameof(track.Falloff), $"Value: {track.Falloff}");
            }

            BaseLapTime  = track.BaseLapTime;
            _trackLength = track.Length;
            _falloff     = track.Falloff;
            _pitWindow   = track.PitWindow;

            _lapTimeRange = (int)(BaseLapTime * DefaultLapTimeRangePercent);

            _random = new Random(DateTime.Now.Millisecond);
        }