How hearthsim/hstracker works
Purpose and Runtime
HSTracker is a native macOS automatic Hearthstone deck tracker and deck manager. It is an Xcode Swift/Objective-C app; HSTracker/AppDelegate.swift is the application entry point, with target/build definition in HSTracker.xcodeproj/project.pbxproj. App UI is AppKit/XIB-based and supports persistent overlay windows above Hearthstone.
Live Game Ingestion
The logging subsystem follows Hearthstone log output, parses game-state events, and maintains the canonical live-match model. HSTracker/Logging/LogReaderManager.swift coordinates readers; HSTracker/Logging/Parsers/PowerGameStateParser.swift and HSTracker/Logging/CoreManager.swift translate log lines into entities, players, turns, zones, and game lifecycle events. This is the primary control-flow boundary between external game data and tracker behavior.
Game-State Observation and Native Integration
Watchers infer client UI/mode transitions not covered solely by parsed logs, feeding feature-specific state updates. Key components include HSTracker/HearthWatcher/SceneWatcher.swift, HSTracker/HearthWatcher/BaconWatcher.swift, and HSTracker/HearthWatcher/DeckPickerWatcher.swift. HSTracker/HearthMirror/MirrorHelper.swift and HSTracker/Mono/MonoHelper.swift form lower-level integration boundaries to Hearthstone process/runtime data; Mono proxies and simulation support are isolated under HSTracker/Mono/.
Hearthstone Domain Rules
HSTracker/Hearthstone/Hearthstone.swift connects parsed state to domain features. Rules are decomposed into dynamic counters (HSTracker/Hearthstone/CounterSystem/CounterManager.swift), active enchantment/effect interpretation (HSTracker/Hearthstone/EffectSystem/Factory/EffectFactory.swift), secrets (HSTracker/Hearthstone/Secrets/SecretsManager.swift), and related/generated-card prediction (HSTracker/Hearthstone/RelatedCardsSystem/RelatedCardsManager.swift). These systems consume entity/tag updates and produce displayable derived state.
Storage, Decks, and Imports
Local persistence covers card metadata, decks, and historical game statistics through HSTracker/Database/Database.swift and models such as HSTracker/Database/Models/Deck.swift and HSTracker/Database/Models/GameStats.swift. Deck creation/import paths are separate adapters: HSTracker/Importers/DeckImporter.swift, HSTracker/Importers/ClipboardImporter.swift, and HSTracker/Importers/DeckSerializer.swift. Card lookup and legality depend on the local database rather than the live logging pipeline.
Overlays and Application UI
The presentation layer renders live state into multiple independent AppKit windows/overlays. HSTracker/UIs/Trackers/WindowManager.swift and HSTracker/UIs/Trackers/OverWindowController.swift manage overlay placement/lifetime; deck and card HUDs are in HSTracker/UIs/Trackers/CardHud.swift. Feature screens include deck management (HSTracker/UIs/DeckManager/DeckManager.swift), Battlegrounds overlays (HSTracker/UIs/Battlegrounds/BattlegroundsOverlay.swift), and constructed mulligan guidance (HSTracker/UIs/Constructed/Mulligan/ConstructedMulliganGuide.swift).
External Services and Analytics
HSReplay.net is the principal remote service: HSTracker/HSReplay/HSReplayManager.swift coordinates account/API workflows, HSTracker/HSReplay/HSReplayAPI.swift defines service access, and HSTracker/HSReplay/LogUploader.swift uploads game logs. Shared HTTP transport is under HSTracker/Network/Http.swift. Telemetry/error integrations are represented by HSTracker/Utility/Analytics/Influx.swift and HSTracker/Utility/Analytics/Sentry.swift; remote behavior/config can be mediated by HSTracker/Utility/RemoteConfig.swift.
Specialized Battlegrounds Simulation
Battlegrounds state has dedicated model, watcher, UI, and simulation paths. HSTracker/Hearthstone/BattlegroundsBoardState.swift captures board state; HSTracker/BobsBuddy/BobsBuddyInvoker.swift invokes combat analysis; HSTracker/Mono/SimulationRunner.swift bridges simulation execution. Results flow to HSTracker/UIs/Trackers/BobsBuddyPanel.swift and Battlegrounds overlays rather than the constructed deck HUD.
Main entry points: Hearthstone.swift Hearthstone Domain · CardHud.swift Card HUD · AppDelegate.swift App Delegate · LogReaderManager.swift Log Reader Manager
Components 21
Live Ingestion
Hearthstone data enters through logs and native observation.
- Log Reader Manager · Follows Hearthstone log output.
HSTracker/Logging/LogReaderManager.swift - Power Game Parser
HSTracker/Logging/Parsers/PowerGameStateParser.swift - Core Manager · Maintains entities, players, turns, zones, and lifecycle.
HSTracker/Logging/CoreManager.swift - Scene & Mode Watchers · Infers client UI and mode transitions.
HSTracker/HearthWatcher/SceneWatcher.swift - Hearth Runtime Bridge · Mirror and Mono access to Hearthstone runtime data.
HSTracker/HearthMirror/MirrorHelper.swift
Game Domain
Canonical match state and derived Hearthstone rules.
- Hearthstone Domain · Connects live state to tracker features.
HSTracker/Hearthstone/Hearthstone.swift - Counter Manager
HSTracker/Hearthstone/CounterSystem/CounterManager.swift - Effect Factory
HSTracker/Hearthstone/EffectSystem/Factory/EffectFactory.swift - Secrets & Related Cards · Derives secret and generated-card predictions.
HSTracker/Hearthstone/Secrets/SecretsManager.swift - Battlegrounds Board
HSTracker/Hearthstone/BattlegroundsBoardState.swift - Bob's Buddy Simulation · Invokes Mono-backed combat simulation.
HSTracker/BobsBuddy/BobsBuddyInvoker.swift
Native UI
AppKit screens and persistent game overlays.
- Overlay Windows · Places and manages windows above Hearthstone.
HSTracker/UIs/Trackers/WindowManager.swift - Card HUD
HSTracker/UIs/Trackers/CardHud.swift - Battlegrounds UI · Shows board and combat-analysis results.
HSTracker/UIs/Battlegrounds/BattlegroundsOverlay.swift - Deck Manager
HSTracker/UIs/DeckManager/DeckManager.swift
Data & Services
Local deck data and remote integrations.
- Local Database · Stores card metadata, decks, and game statistics.
HSTracker/Database/Database.swift - Deck Import · Imports and serializes deck lists.
HSTracker/Importers/DeckImporter.swift - HSReplay Manager · Coordinates account and API workflows.
HSTracker/HSReplay/HSReplayManager.swift - Log Uploader
HSTracker/HSReplay/LogUploader.swift - Telemetry & Remote Config
HSTracker/Utility/Analytics/Influx.swift
Other components
- App Delegate
HSTracker/AppDelegate.swift
Connections 28
- App Delegate → Log Reader Manager: starts
- App Delegate → Overlay Windows: launches
- App Delegate → Deck Manager: opens
- Log Reader Manager → Power Game Parser: log lines
- Power Game Parser → Core Manager: state events
- Hearth Runtime Bridge → Scene & Mode Watchers: runtime signals
- Scene & Mode Watchers → Hearthstone Domain: mode updates
- Core Manager → Hearthstone Domain: canonical live state
- Hearthstone Domain → Counter Manager: entity/tag updates
- Hearthstone Domain → Effect Factory: entity/tag updates
- Hearthstone Domain → Secrets & Related Cards: entity/tag updates
- Hearthstone Domain → Battlegrounds Board: Battlegrounds state
- Hearthstone Domain → Card HUD: live deck state
- Counter Manager → Card HUD: display counters
- Effect Factory → Card HUD: active effects
- Secrets & Related Cards → Card HUD: predictions
- Card HUD → Overlay Windows: hosted in
- Battlegrounds Board → Bob's Buddy Simulation: combat state
- Bob's Buddy Simulation → Battlegrounds UI: combat results
- Battlegrounds Board → Battlegrounds UI: board state
- Battlegrounds UI → Overlay Windows: hosted in
- Deck Import → Local Database: saves decks
- Deck Manager → Deck Import: imports decks
- Deck Manager → Local Database: reads and writes
- Hearthstone Domain → Local Database: card lookup and legality
- Log Reader Manager → Log Uploader: game logs
- Log Uploader → HSReplay Manager: uploads via
- App Delegate → Telemetry & Remote Config: reports events