public void Handle(LogLine logLine, IHsGameState gameState, IGame game) { var match = LogConstants.GameModeRegex.Match(logLine.Line); if (match.Success) { game.CurrentMode = GetMode(match.Groups["curr"].Value); game.PreviousMode = GetMode(match.Groups["prev"].Value); if ((DateTime.Now - logLine.Time).TotalSeconds < 5) { if (_lastAutoImport < logLine.Time && game.CurrentMode == Mode.TOURNAMENT) { _lastAutoImport = logLine.Time; var decks = DeckImporter.FromConstructed(); if (decks.Any() && (Config.Instance.ConstructedAutoImportNew || Config.Instance.ConstructedAutoUpdate)) { DeckManager.ImportDecks(decks, false, Config.Instance.ConstructedAutoImportNew, Config.Instance.ConstructedAutoUpdate); } } if (game.PreviousMode == Mode.COLLECTIONMANAGER || game.CurrentMode == Mode.COLLECTIONMANAGER || game.PreviousMode == Mode.PACKOPENING) { CollectionHelper.UpdateCollection().Forget(); } if (game.CurrentMode == Mode.HUB && !_checkedMirrorStatus) { CheckMirrorStatus(); } } if (game.PreviousMode == Mode.GAMEPLAY && game.CurrentMode != Mode.GAMEPLAY) { gameState.GameHandler.HandleInMenu(); } if (game.CurrentMode == Mode.DRAFT) { Watchers.ArenaWatcher.Run(); } else { Watchers.ArenaWatcher.Stop(); } if (game.CurrentMode == Mode.PACKOPENING) { Watchers.PackWatcher.Run(); } else { Watchers.PackWatcher.Stop(); } if (game.CurrentMode == Mode.TAVERN_BRAWL) { Core.Game.CacheBrawlInfo(); } if (game.CurrentMode == Mode.BACON) { Core.Game.CacheBattlegroundRatingInfo(); } if (game.CurrentMode == Mode.ADVENTURE || game.PreviousMode == Mode.ADVENTURE && game.CurrentMode == Mode.GAMEPLAY) { Watchers.DungeonRunWatcher.Run(); } else { Watchers.DungeonRunWatcher.Stop(); } if (game.CurrentMode == Mode.PVP_DUNGEON_RUN || game.PreviousMode == Mode.PVP_DUNGEON_RUN && game.CurrentMode == Mode.GAMEPLAY) { Watchers.PVPDungeonRunWatcher.Run(); } else { Watchers.PVPDungeonRunWatcher.Stop(); } if (game.PlayerChallengeable && Config.Instance.ChallengeAction != Enums.HsActionType.None) { Watchers.FriendlyChallengeWatcher.Run(); } else { Watchers.FriendlyChallengeWatcher.Stop(); } API.GameEvents.OnModeChanged.Execute(game.CurrentMode); } else if (logLine.Line.Contains("Gameplay.Start")) { gameState.Reset(); gameState.GameHandler.HandleGameStart(logLine.Time); } }
public void InvalidUrlTest() { var found = DeckImporter.Import(@"http://hsdecktracker.net").Result; Assert.IsNull(found); }
public async Task StartArenaImporting() { ProgressDialogController controller = null; if (!Core.Game.IsRunning) { Log.Info("Waiting for game..."); var result = await this.ShowMessageAsync("Importing arena deck", "Start Hearthstone and enter the 'Arena' screen.", MessageDialogStyle.AffirmativeAndNegative, new MessageDialogs.Settings() { AffirmativeButtonText = "Start Hearthstone", NegativeButtonText = "Cancel" }); if (result == MessageDialogResult.Negative) { return; } Helper.StartHearthstoneAsync().Forget(); controller = await this.ShowProgressAsync("Importing arena deck", "Waiting for Hearthstone...", true); while (!Core.Game.IsRunning) { if (controller.IsCanceled) { await controller.CloseAsync(); return; } await Task.Delay(500); } } if (Core.Game.CurrentMode != Mode.DRAFT) { if (controller == null) { controller = await this.ShowProgressAsync("Importing arena deck", "", true); } controller.SetMessage("Enter the 'Arena' screen."); Log.Info("Waiting for DRAFT screen..."); while (Core.Game.CurrentMode != Mode.DRAFT) { if (controller.IsCanceled) { await controller.CloseAsync(); return; } await Task.Delay(500); } } var deck = DeckImporter.FromArena()?.Deck; while (deck == null || deck.Cards.Sum(x => x.Count) < 30) { if (controller == null) { controller = await this.ShowProgressAsync("Importing arena deck", "", true); } if (controller.IsCanceled) { await controller.CloseAsync(); return; } controller.SetMessage($"Waiting for complete deck ({deck?.Cards.Sum(x => x.Count) ?? 0}/30 cards)..."); await Task.Delay(1000); deck = DeckImporter.FromArena(false)?.Deck; } if (controller != null) { await controller.CloseAsync(); } var recentArenaDecks = DeckList.Instance.Decks.Where(d => d.IsArenaDeck && d.Cards.Sum(x => x.Count) == 30).OrderByDescending(d => d.LastPlayedNewFirst).Take(15); var existing = recentArenaDecks.FirstOrDefault(d => d.Cards.All(c => deck.Cards.Any(c2 => c.Id == c2.Id && c.Count == c2.Count))); if (existing != null) { var result = await this.ShowMessageAsync("Deck already exists", "You seem to already have this deck.", MessageDialogStyle.AffirmativeAndNegative, new MessageDialogs.Settings() { AffirmativeButtonText = "Use existing", NegativeButtonText = "Import anyway" }); if (result == MessageDialogResult.Affirmative) { SelectDeck(existing, true); return; } } ImportArenaDeck(deck); }
public void HearthArena() { Deck found = DeckImporter.Import(@"http://www.heartharena.com/arena-run/i2s8ht").Result; Assert.IsTrue(AreDecksEqual(arena, found)); }
public void Handle(LogLine logLine, IHsGameState gameState, IGame game) { var match = LogConstants.GameModeRegex.Match(logLine.Line); if (match.Success) { game.CurrentMode = GetMode(match.Groups["curr"].Value); game.PreviousMode = GetMode(match.Groups["prev"].Value); if ((DateTime.Now - logLine.Time).TotalSeconds < 5 && _lastAutoImport < logLine.Time && game.CurrentMode == Mode.TOURNAMENT) { _lastAutoImport = logLine.Time; var decks = DeckImporter.FromConstructed(); if (decks.Any() && (Config.Instance.ConstructedAutoImportNew || Config.Instance.ConstructedAutoUpdate)) { DeckManager.ImportDecks(decks, false, Config.Instance.ConstructedAutoImportNew, Config.Instance.ConstructedAutoUpdate); } } if (game.PreviousMode == Mode.GAMEPLAY && game.CurrentMode != Mode.GAMEPLAY) { gameState.GameHandler.HandleInMenu(); } if (game.CurrentMode == Mode.HUB && !_checkedMirrorStatus && (DateTime.Now - logLine.Time).TotalSeconds < 5) { CheckMirrorStatus(); if (CollectionHelper.IsAwaitingUpdate) { CollectionHelper.TryUpdateCollection().Forget(); } } if (game.CurrentMode == Mode.DRAFT) { Watchers.ArenaWatcher.Run(); } else { Watchers.ArenaWatcher.Stop(); } if (game.CurrentMode == Mode.PACKOPENING) { Watchers.PackWatcher.Run(); } else { Watchers.PackWatcher.Stop(); } if (game.CurrentMode == Mode.TAVERN_BRAWL) { Core.Game.CacheBrawlInfo(); } } else if (logLine.Line.Contains("Gameplay.Start")) { gameState.Reset(); gameState.GameHandler.HandleGameStart(logLine.Time); } }
private async Task <object> CommandImportExecute(object param) { await DeckImporter.ImportFromText(ImportData); //results of this cass will be handled in deckpreviewdatamodel return(null); }
private void CommandCancelExecute(object obj) { DeckImporter.CancelImport(); }
public ImportTextViewModel(ITrackerFactory trackerFactory) { this.trackerFactory = trackerFactory; DeckImporter = new DeckImporter(this.trackerFactory); }
public ArenaInfo GetArenaInfo() => DeckImporter.FromArena(false);