Exemplo n.º 1
0
 internal static void Stop()
 {
     ArenaWatcher.Stop();
     PackWatcher.Stop();
     DungeonRunWatcher.Stop();
     FriendlyChallengeWatcher.Stop();
 }
 internal static void Stop()
 {
     ArenaWatcher.Stop();
     PackWatcher.Stop();
     DungeonRunWatcher.Stop();
 }
Exemplo n.º 3
0
        private async void LoadingScreenParser_OnModeChanged(ModeChangedEventArgs args)
        {
            if (args.PreviousMode >= Mode.LOGIN && !_game.Account.IsLoaded)
            {
                _game.OnHearthstoneLoaded();
                var battleTag = await Retry(_gameData.GetBattleTag);

                var account = await Retry(_gameData.GetAccountId);

                if (battleTag != null && account != null)
                {
                    _game.Account.Update(account.Hi, account.Lo, battleTag.Name, battleTag.Number);
                    _game.Region = (BnetRegion)((account.Hi >> 32) & 0xFF);
                }
            }

            if (ShouldUpdateCollection(args.PreviousMode, args.PreviousMode))
            {
                var collection = await Retry(_gameData.GetFullCollection);

                if (collection != null)
                {
                    var cards = collection.Cards
                                .GroupBy(x => x.Id)
                                .Select(g => new CollectionCard(g.Key,
                                                                g.FirstOrDefault(x => !x.Premium)?.Count ?? 0,
                                                                g.FirstOrDefault(x => x.Premium)?.Count ?? 0
                                                                )).ToList();
                    var favoriteHeroes = collection.FavoriteHeroes.Values.Select(x =>
                                                                                 new CollectionCard(x.Id, x.Premium ? 0 : 1, x.Premium ? 1 : 0))
                                         .ToList();
                    _game.Collection.Update(cards, collection.CardBacks, favoriteHeroes,
                                            collection.FavoriteCardBack, collection.Dust, collection.Gold);
                }
            }

            if (args.CurrentMode == Mode.DRAFT)
            {
                _arenaWatcher.Run();
            }
            else
            {
                _arenaWatcher.Stop().Forget();
            }

            if (args.CurrentMode == Mode.PACKOPENING)
            {
                _packWatcher.Run();
            }
            else
            {
                _packWatcher.Stop().Forget();
            }

            if (args.CurrentMode == Mode.ADVENTURE || args.PreviousMode == Mode.ADVENTURE && args.CurrentMode == Mode.GAMEPLAY)
            {
                _dungeonRunWatcher.Run();
            }
            else
            {
                _dungeonRunWatcher.Stop().Forget();
            }

            if (args.CurrentMode == Mode.TAVERN_BRAWL)
            {
                var brawlInfo = _gameData.GetBrawlInfo();
                if (brawlInfo != null)
                {
                    _game.TavernBrawl.Update(brawlInfo);
                }
            }

            if (args.CurrentMode == Mode.FATAL_ERROR)
            {
                _game.OnHearthstoneExited();
            }
        }