$ show HearthSim/Hearthstone-Deck-Tracker
Hearthstone Deck Tracker is a Windows desktop companion application for the digital card game Hearthstone. It reads the game's log files and memory (via HearthMirror) to reconstruct real-time game state, providing an in-game overlay that displays the player's deck, opponent's known cards, draw probabilities, card generation predictions, and various counters for in-game effects. It also offers deck management (import/export, editing, versioning), match history and statistics, and integration with HSReplay.net for cloud sync, replays, and premium features like mulligan guides and arena drafting assistance. The application follows a custom MVVM (Model-View-ViewModel) architecture using .NET Framework and XAML for the UI. The core game state engine is driven by log watchers and handlers that parse Hearthstone's power log, while memory reading provides additional data like the player's collection and current deck. The overlay system consists of multiple transparent windows that can be configured per game mode (Constructed, Arena, Battlegrounds, Mercenaries). A plugin system allows third-party extensions, and an auto-updater (Squirrel) handles distribution. Key entry points include the main application window (App.xaml.cs), the log watcher manager (LogWatcherManager), the scene handler that transitions between game modes, and the various overlay view models. Data flows from log files and memory into a shared game state object, which is then consumed by counters, effect trackers, and UI components. External dependencies include HearthDb (card database), HearthMirror (memory reading library), HSReplay.net APIs, and the Hearthstone game client itself. The codebase is large and actively maintained, with frequent updates to support new Hearthstone expansions and game modes. However, it carries significant technical debt: heavy use of hardcoded card IDs, brittle regex-based log parsing, a custom UI framework that diverges from standard .NET patterns, and deep coupling to game-specific mechanics. While functional and feature-rich, the architecture shows signs of organic growth rather than deliberate design, making isolated reuse of components challenging without adaptation.
The LLM identified 5 files worth highlighting for reuse:
A generic, type-safe asset downloader with LRU memory cache, disk persistence, ETag-based conditional downloads, and retry logic. It supports any key-asset pair and is used for card images, card definitions, and external tools. The design is cleanly separated from business logic and could be extracted for use in any application requiring cached remote assets.
A generic asynchronous data loader that fetches resources from disk or web with configurable rate limiting and fallback. It encapsulates common patterns for loading remote configuration, game data, and analytics payloads. The interface is simple and the implementation handles concurrency and error states robustly, making it reusable in other .NET projects.
A reflection-based dynamic factory that discovers and instantiates subclasses of a given base type. It uses LINQ-compiled constructor references for fast instantiation and caches them. This pattern is used to create entity-based effects without hardcoding a registry. The approach is generic and could be applied to any plugin or strategy pattern where classes need to be auto-registered.
A thread-safe OAuth token refresher that uses a semaphore to prevent concurrent refresh attempts. It handles token expiration, retries, and race conditions gracefully. The implementation is self-contained and demonstrates a robust pattern for managing access tokens in any application that consumes OAuth-protected APIs.
An abstract base class for in-game counters that track numeric or statistical values based on game events. It provides built-in visibility overrides (auto/enabled/disabled), mirroring support (for effects like Azalina), and format-aware filtering. The design separates counter logic from UI and configuration, making it a reusable template for any event-driven counter system.