Skip to content

fix(client): accept lowercase set codes in MTGA deck lines#5191

Merged
matthewevans merged 1 commit into
phase-rs:mainfrom
jeffrey701:fix/mtga-lowercase-set-code
Jul 9, 2026
Merged

fix(client): accept lowercase set codes in MTGA deck lines#5191
matthewevans merged 1 commit into
phase-rs:mainfrom
jeffrey701:fix/mtga-lowercase-set-code

Conversation

@jeffrey701

Copy link
Copy Markdown
Contributor

Problem

parseDeckEntryLine matches MTGA-style printing lines (<count> <name> (<set>) <collector#>) with:

/^(\d+)x?\s+(.+?)\s+\(([A-Z0-9]*)\)\s+(\S+)(?:\s+.*)?$/

The set-code group is [A-Z0-9]*uppercase only. MTGA_LINE_PATTERN (used for format detection) has the same restriction. A decklist line whose set code is lowercase (Scryfall-style — e.g. 2xm, mh2, m21, fdn, which several exporters emit) fails the MTGA match, falls through to the simple (\d+)x?\s+(.+) matcher, and the set code + collector number get swallowed into the card name:

"1 Lightning Bolt (2xm) 123"  ->  { count: 1, name: "Lightning Bolt (2xm) 123" }   // no sourcePrinting; name won't resolve

Fix

Widen the set-code class to [A-Za-z0-9]* in both the parse regex and MTGA_LINE_PATTERN. setCode.toLowerCase() already normalizes case downstream, so a lowercase code yields exactly the same sourcePrinting an uppercase one would. Card names never contain a parenthesized (...) <token> run, so widening the class can't misclassify a real name line.

Tests

Adds two cases to the existing deckParser suite: a lowercase set code ((2xm) 123) now parses to { name: "Lightning Bolt", sourcePrinting: { setCode: "2xm", collectorNumber: "123" } } (fails before — the name is garbled and there's no printing), and lowercase vs uppercase set codes produce identical results. The full existing 73-test suite still passes.

Self-contained: only deckParser.ts + its test; no engine/Rust/protocol changes.

Model: claude-opus-4-8

@jeffrey701 jeffrey701 requested a review from matthewevans as a code owner July 6, 2026 05:51
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

The MTGA printing-line matcher and MTGA_LINE_PATTERN captured the set code with [A-Z0-9]* (uppercase only). A decklist line with a lowercase Scryfall-style set code (e.g. '1 Lightning Bolt (2xm) 123' — several exporters emit these) failed the MTGA match, fell through to the simple count+name matcher, and the set code + collector number were swallowed into the card name, producing an unresolvable name and no sourcePrinting. Widen the class to [A-Za-z0-9]*; setCode.toLowerCase() already normalizes case, and card names never contain parenthesized runs so this can't misclassify a real line.
@jeffrey701 jeffrey701 force-pushed the fix/mtga-lowercase-set-code branch from 96dda40 to c3b5a23 Compare July 6, 2026 12:06
@matthewevans matthewevans added the defer-fe Frontend/client/UI PR deferred to Matt's direct review label Jul 6, 2026
@matthewevans matthewevans self-assigned this Jul 9, 2026
@matthewevans matthewevans removed the defer-fe Frontend/client/UI PR deferred to Matt's direct review label Jul 9, 2026
@matthewevans matthewevans added this pull request to the merge queue Jul 9, 2026
@matthewevans matthewevans removed their assignment Jul 9, 2026
Merged via the queue into phase-rs:main with commit d2aefef Jul 9, 2026
11 checks passed
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.

2 participants