Skip to content

Add forge-scryfall-uuid-map CLI tool for patching edition files#10937

Open
phughk wants to merge 3 commits into
Card-Forge:masterfrom
phughk:fix-10413-scryfall-uuid-cli
Open

Add forge-scryfall-uuid-map CLI tool for patching edition files#10937
phughk wants to merge 3 commits into
Card-Forge:masterfrom
phughk:fix-10413-scryfall-uuid-cli

Conversation

@phughk

@phughk phughk commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Problem

To use Scryfall's rate-free CDN for card images, we need a UUID for every (set, collector-number, language) combination. Those UUIDs aren't in Forge's existing data. Scryfall publishes bulk-data exports with all of them, but they need to be processed into per-set JSON files that the runtime can fetch on demand.

This tool is the offline generator — run it once (or after each Scryfall data update) to produce the files that go in the forge-extras repository.

What it does

flowchart LR
    A[Scryfall bulk-data\nall_cards JSON] --> B[BulkDataFetcher\ndownloads & streams]
    B --> C[CardStreamParser\nreads UUID + set + cn + lang]
    C --> D["CdnUuidJsonWriter\nwrites cdn_uuid/{set}.json"]
    D --> E[~1,041 set files\nready for forge-extras]
Loading

Output — one JSON file per Scryfall set code:

cdn_uuid/neo.json
{
  "1":   {"pt":"…uuid…","de":"…uuid…","ja":"…uuid…","en":"…uuid…"},
  "2":   {"en":"…uuid…"},
  "A-40":{"en":["front-uuid","back-uuid"]}
}

DFCs with distinct face UUIDs store an array for the affected language.

Usage

Run from the repo root. No full Forge build required.

# Full multi-language output — downloads all_cards from Scryfall (~2.5 GB)
mvn -pl forge-scryfall-uuid-map exec:java \
  -Dexec.args="--output-dir /path/to/forge-extras/cdn_uuid"

# English-only, faster — downloads default_cards (~100 MB)
mvn -pl forge-scryfall-uuid-map exec:java \
  -Dexec.args="--output-dir /path/to/forge-extras/cdn_uuid --default-cards"

# Use a pre-downloaded bulk file (auto-detected if named all-cards-*.json or default-cards-*.json)
mvn -pl forge-scryfall-uuid-map exec:java \
  -Dexec.args="--output-dir /path/to/forge-extras/cdn_uuid --bulk-file all-cards-20260608.json"

The default (all_cards) includes every language variant and produces a complete multi-language UUID map. --default-cards is faster to regenerate but only covers English — the runtime falls back to the Scryfall API for non-English cards when a UUID is absent.

New module

forge-scryfall-uuid-map/ — standalone Maven module, not included in the game distribution. Added to the root pom.xml modules list.

Class Role
Main Entry point; arg parsing, wires components together
BulkDataFetcher Fetches the bulk-data index from Scryfall and downloads the dataset
CardStreamParser Streams the large JSON array card-by-card (low memory)
CardRecord Holds parsed UUID, set code, collector number, lang
CdnUuidJsonWriter Writes the per-set JSON files

Depends on

The output files belong in the forge-extras repository ( Card-Forge/forge-extras#33 ). The runtime code that reads them is in PR #10928 (Card-Forge/forge).

Reads a Scryfall bulk data export and writes one JSON file per card print:
  cdn_uuid/{setCode}/{collectorNumber}.json  ->  {"en":"uuid","ja":"uuid",...}

Defaults to all_cards (~2.5 GB) so every language print is included in each
file. Pass --default-cards for a faster English-only run (~100 MB). This is
the root cause of single-language files: using default_cards only yields one
entry per card. all_cards is required for multi-language UUID maps.

Usage: java -jar forge-scryfall-uuid-map.jar --output-dir path/to/res/cdn_uuid

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@phughk phughk force-pushed the fix-10413-scryfall-uuid-cli branch from a15ffbb to 4001da1 Compare June 9, 2026 22:03
Hugh Kaznowski and others added 2 commits June 10, 2026 01:31
Remove the unused parquet-floor dependency (the tool writes JSON, not Parquet)
and pre-configure exec-maven-plugin with the mainClass so callers only need
-Dexec.args instead of -Dexec.mainClass and the broken -- separator.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The runtime now fetches a single set file on demand and caches it locally,
so there is no need to ship ~115k individual files with the game.

Output: {outputDir}/{setCode}.json → {"cn": {"lang": "uuid", ...}, ...}

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant