Read card database from Arena's on-disk SQLite files#1
Open
dan-blanchard wants to merge 1 commit intomtgatool:mainfrom
Open
Read card database from Arena's on-disk SQLite files#1dan-blanchard wants to merge 1 commit intomtgatool:mainfrom
dan-blanchard wants to merge 1 commit intomtgatool:mainfrom
Conversation
4 tasks
Arena ships its card database as a SQLite file (Raw_CardDatabase_*.mtga) in Downloads/Raw/. New pure-JS reader auto-discovers and reads it: ~27K cards with names, set codes, collector numbers, localization for 8+ languages. No native code, no process attachment, no sudo. Dependency: sql.js (pure JS SQLite) 10 tests included. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
9437bce to
1ac3e59
Compare
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Arena ships its card database as a SQLite file (
Raw_CardDatabase_*.mtga) in the game'sDownloads/Raw/directory. This PR adds a pure-JS reader that finds it and exposes all ~27K cards with English names, set codes, collector numbers, rarity, types, colors, power/toughness, and localized names for 8+ languages.No native code, no process attachment, no elevated privileges. It just reads a file that's already on disk.
What it does
findCardDatabasePath()auto-discovers the.mtgafile on Windows (Program Files/Wizards of the Coast/MTGA/), with fallback support for macOS and Linux Wine prefixesreadCardDatabase()opens it withsql.js, joinsCardswithLocalizations_enUSto resolveTitleId→ card name, and returns abyGrpIdlookup maparenaPathoption for non-standard installs and alocaleoption for Japanese, Portuguese, etc.Why
This makes it possible to resolve
grpId→ card name without Scryfall (which hasnullarena_idfor ~1500 recent cards). The database is static per Arena build (same for all players), so reading it from disk is simpler and more reliable than extracting it from live process memory.Combined with the existing
readDatawalker or thereadMtgaCardscollection scanner, this gives the full pipeline:grpId → quantity + card name + set + collector number.Testing
All 10 new tests pass (
npm test). Verified on a Windows Arena install (version2026.58.0.324, 27,189 cards):arenaPathreturns null (no fallback to platform defaults)byGrpId.get(75452)→ "Inspiring Commander" (ANB #11)Dependency:
sql.js(pure JS SQLite, no native compilation needed)🤖 Generated with Claude Code