コード例 #1
0
        private async void SaveGame()
        {
            ContentDialogResult result = await _dialogService.ShowContentDialogAsync(new ConfirmDialogViewModel("End Game", "Are you sure you want to quit the game and log the stats?"));

            if (result == ContentDialogResult.Secondary)
            {
                return;
            }

            CalculateScores();

            AchievementService achievementService = new AchievementService(game);

            achievementService.CheckForPersonalScores();
            achievementService.CheckForEverScores();

            try
            {
                _gameRepo.AddGame(game);

                int multiScore = colours.SingleOrDefault(c => c.name == "Multi")?.score ?? 0;

                foreach (Player player in game.players)
                {
                    _playerGameRepo.AddPlayerGame(player, game,
                                                  colours.SingleOrDefault(c => c.name == "Red").score,
                                                  colours.SingleOrDefault(c => c.name == "White").score,
                                                  colours.SingleOrDefault(c => c.name == "Blue").score,
                                                  colours.SingleOrDefault(c => c.name == "Yellow").score,
                                                  colours.SingleOrDefault(c => c.name == "Green").score,
                                                  multiScore);
                }

                achievementService.CheckForFirsts();
                achievementService.CheckForMileStones();

                achievementService.AddAchievements();

                ((App)Application.Current).rootFrame.Navigate(typeof(StandingsView), game);
            }
            catch (SQLiteException)
            {
                await _dialogService.ShowContentDialogAsync(new MessageDialogViewModel("Error", "Something went wrong, please try again"));
            }
        }
コード例 #2
0
        private async void SaveGame()
        {
            if (!CheckForEndOfGame())
            {
                ContentDialogResult result = await _dialogService.ShowContentDialogAsync(new ConfirmDialogViewModel("End Game", "You are about to quit an unfinished game. Are you sure you want to quit the game and log the stats?"));

                if (result == ContentDialogResult.Secondary)
                {
                    return;
                }
            }

            CalculateScores();

            AchievementService achievementService = new AchievementService(game);

            achievementService.CheckForPersonalScores();
            achievementService.CheckForEverScores();

            try
            {
                _gameRepo.AddGame(game);

                foreach (Player player in game.players)
                {
                    _playerGameRepo.AddPlayerGame(player, game.id);
                }

                achievementService.CheckForFirsts();
                achievementService.CheckForMileStones();

                achievementService.AddAchievements();

                ((App)Application.Current).rootFrame.Navigate(typeof(StandingsView), game);
            }
            catch (SQLiteException)
            {
                await _dialogService.ShowContentDialogAsync(new MessageDialogViewModel("Error", "Something went wrong, please try again"));
            }
        }