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(); }