Ejemplo n.º 1
0
        private void HandleTimer()
        {
            if (_mode == ModeEnum.Slowdown && _timer.Interval > MaxSlowdownInterval.TotalMilliseconds) // Winning tile!
            {
                _soundEffects.PlayWinnerSound();
                _timer.Stop();
                _mode = ModeEnum.WinnerSelected;
                OnWinnerSelected?.Invoke(this, new WinnerSelectedEventArgs
                {
                    WinningTile = SelectedTile,
                    WinnerName  = SelectedTile.Name,
                    AttendeeId  = SelectedTile.AttendeeId
                });
                return;
            }

            var rand = new Random();

            var randomTileIndex = rand.Next(0, Tiles.Count);

            SelectedTile = Tiles[randomTileIndex];

            _timer.Interval = GetCurrentTimerInterval();

            _soundEffects.PlayTileChangeSound();
        }
Ejemplo n.º 2
0
        public void SaveWinnerDetails(TileViewModel winningTileViewModel)
        {
            var fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "PrizeDraw", "Winners.txt");

            using (var stream = File.AppendText(fileName))
            {
                stream.WriteLineAsync($"Time: {DateTime.UtcNow}");
                stream.WriteLineAsync($"    Name: {winningTileViewModel.Name}");
                stream.WriteLineAsync($"    Id: {winningTileViewModel.AttendeeId}");
            }
        }