Exemplo n.º 1
0
        public void HandleInMenu()
        {
            if (_game.IsInMenu)
            {
                return;
            }

            if (Config.Instance.RecordReplays && _game.Entities.Count > 0 && !_game.SavedReplay && _game.CurrentGameStats != null &&
                _game.CurrentGameStats.ReplayFile == null && RecordCurrentGameMode)
            {
                _game.CurrentGameStats.ReplayFile = ReplayMaker.SaveToDisk();
            }

            SaveAndUpdateStats();

            _game.IsInMenu = true;
            TurnTimer.Instance.Stop();
            Helper.MainWindow.Overlay.HideTimers();
            Helper.MainWindow.Overlay.HideSecrets();
            if (Config.Instance.KeyPressOnGameEnd != "None" && Helper.MainWindow.EventKeys.Contains(Config.Instance.KeyPressOnGameEnd))
            {
                SendKeys.SendWait("{" + Config.Instance.KeyPressOnGameEnd + "}");
                Logger.WriteLine("Sent keypress: " + Config.Instance.KeyPressOnGameEnd, "GameEventHandler");
            }
            if (!Config.Instance.KeepDecksVisible)
            {
                var deck = DeckList.Instance.ActiveDeckVersion;
                if (deck != null)
                {
                    _game.SetPremadeDeck((Deck)deck.Clone());
                }
            }
            if (!_game.IsUsingPremade)
            {
                _game.DrawnLastGame = new List <Card>(_game.PlayerDrawn);
            }
            HsLogReaderV2.Instance.ClearLog();
            if (!Config.Instance.KeepDecksVisible)
            {
                _game.Reset(false);
            }
            if (_game.CurrentGameStats != null && _game.CurrentGameStats.Result != GameResult.None)
            {
                _game.CurrentGameStats = null;
            }
            if (_game.CurrentGameMode == GameMode.Spectator)
            {
                SetGameMode(GameMode.None);
            }
            GameEvents.OnInMenu.Execute();
        }
Exemplo n.º 2
0
 private void CheckboxRemoveCards_Checked(object sender, RoutedEventArgs e)
 {
     if (!_initialized || !_game.IsUsingPremade)
     {
         return;
     }
     Config.Instance.RemoveCardsFromDeck = true;
     SaveConfig(false);
     _game.Reset();
     if (DeckList.Instance.ActiveDeck != null)
     {
         _game.SetPremadeDeck((Deck)DeckList.Instance.ActiveDeck.Clone());
     }
     HsLogReaderV2.Instance.Reset(true);
     Helper.MainWindow.Overlay.Update(true);
 }
Exemplo n.º 3
0
        private async void CheckboxRemoveCards_Checked(object sender, RoutedEventArgs e)
        {
            if (!_initialized || !_game.IsUsingPremade)
            {
                return;
            }
            Config.Instance.RemoveCardsFromDeck = true;
            SaveConfig(false);
            _game.Reset();
            if (DeckList.Instance.ActiveDeck != null)
            {
                _game.SetPremadeDeck((Deck)DeckList.Instance.ActiveDeck.Clone());
            }
            await LogReaderManager.Restart();

            Core.Overlay.Update(true);
        }
Exemplo n.º 4
0
        public void HandleGameStart(DateTime timestamp)
        {
            if (_game.CurrentGameMode == Practice && !_game.IsInMenu && !_handledGameEnd &&
                _lastGameStartTimestamp > DateTime.MinValue && timestamp > _lastGameStartTimestamp)
            {
                HandleAdventureRestart();
            }
            _lastGameStartTimestamp = timestamp;
            if (DateTime.Now - _lastGameStart < new TimeSpan(0, 0, 0, 5))            //game already started
            {
                return;
            }
            _handledGameEnd = false;
            _lastGameStart  = DateTime.Now;
            Log.Info("--- Game start ---");

            if (Config.Instance.FlashHsOnTurnStart)
            {
                User32.FlashHs();
            }
            if (Config.Instance.BringHsToForeground)
            {
                User32.BringHsToForeground();
            }
            _lastTurnStart[0]  = _lastTurnStart[1] = 0;
            _arenaRewardDialog = null;
            _showedNoteDialog  = false;
            _game.IsInMenu     = false;
            _savedReplay       = false;
            _game.Reset();
            _game.CacheMatchInfo();
            _game.CacheGameType();
            _game.CacheSpectator();
            _game.MetaData.ServerInfo = Reflection.GetServerInfo();
            if (!string.IsNullOrEmpty(_game.MetaData.ServerInfo?.Address))
            {
                var region = Helper.GetRegionByServerIp(_game.MetaData.ServerInfo.Address);
                if (_game.CurrentRegion == Region.UNKNOWN || region == Region.CHINA)
                {
                    _game.CurrentRegion = region;
                    Log.Info("Set current region to" + region);
                }
            }
            TurnTimer.Instance.Start(_game).Forget();

            var selectedDeck = DeckList.Instance.ActiveDeckVersion;

            if (selectedDeck != null)
            {
                _game.IsUsingPremade = true;
            }
            Core.Windows.CapturableOverlay?.UpdateContentVisibility();
            GameEvents.OnGameStart.Execute();
            LiveDataManager.WatchBoardState();
        }
        public void HandleGameStart(DateTime timestamp)
        {
            if (_game.CurrentGameMode == Practice && !_game.IsInMenu && !_handledGameEnd &&
                _lastGameStartTimestamp > DateTime.MinValue && timestamp > _lastGameStartTimestamp)
            {
                HandleAdventureRestart();
            }
            _lastGameStartTimestamp = timestamp;
            if (DateTime.Now - _lastGameStart < new TimeSpan(0, 0, 0, 5))            //game already started
            {
                return;
            }
            _handledGameEnd = false;
            _lastGameStart  = DateTime.Now;
            Log.Info("--- Game start ---");

            switch (Config.Instance.TurnStartAction)
            {
            case HsActionType.Flash:
                User32.FlashHs();
                break;

            case HsActionType.Popup:
                User32.BringHsToForeground();
                break;
            }
            _lastTurnStart[0]  = _lastTurnStart[1] = 0;
            _arenaRewardDialog = null;
            _showedNoteDialog  = false;
            _game.IsInMenu     = false;
            _savedReplay       = false;
            _game.Reset();
            _game.CacheMatchInfo();
            _game.CacheGameType();
            _game.CacheSpectator();
            _game.MetaData.ServerInfo = Reflection.GetServerInfo();
            TurnTimer.Instance.Start(_game).Forget();

            var selectedDeck = DeckList.Instance.ActiveDeckVersion;

            if (selectedDeck != null)
            {
                _game.IsUsingPremade = true;
            }
            Core.Windows.CapturableOverlay?.UpdateContentVisibility();
            GameEvents.OnGameStart.Execute();
            LiveDataManager.WatchBoardState();
        }