Example #1
0
        public void HandleInMenu()
        {
            if (_game.IsInMenu)
            {
                return;
            }

            Log.Info("Game is now in menu.");
            _game.IsInMenu = true;

            TurnTimer.Instance.Stop();
            Core.Overlay.HideTimers();
            Core.Overlay.HideSecrets();
            Core.Overlay.Update(true);
            DeckManager.ResetIgnoredDeckId();
            Core.Windows.CapturableOverlay?.UpdateContentVisibility();

            SaveAndUpdateStats();

            if (Config.Instance.AutoArchiveArenaDecks && (DeckList.Instance.ActiveDeck?.IsArenaRunCompleted ?? false))
            {
                Core.MainWindow.ArchiveDeck(DeckList.Instance.ActiveDeck, true);
            }

            _game.ResetStoredGameState();

            if (_arenaRewardDialog != null)
            {
                _arenaRewardDialog.Show();
                _arenaRewardDialog.Activate();
            }

            if (_game.CurrentGameStats != null && _game.CurrentGameStats.GameMode == Arena)
            {
                ArenaStats.Instance.UpdateArenaRuns();
                ArenaStats.Instance.UpdateArenaStats();
                ArenaStats.Instance.UpdateArenaStatsHighlights();
            }

            if (!_game.IsUsingPremade)
            {
                _game.DrawnLastGame =
                    new List <Card>(_game.Player.RevealedEntities.Where(x => !x.Info.Created && !x.Info.Stolen && x.Card.Collectible &&
                                                                        x.IsPlayableCard).GroupBy(x => x.CardId).Select(x =>
                {
                    var card   = Database.GetCardFromId(x.Key);
                    card.Count = x.Count();
                    return(card);
                }));
            }

            if (!Config.Instance.KeepDecksVisible)
            {
                Core.Reset().Forget();
            }
            GameEvents.OnInMenu.Execute();
        }