Skip to content

fix(cards): resolve glued combined multi-face names in image lookup#5125

Merged
matthewevans merged 1 commit into
phase-rs:mainfrom
JacobWoodson:fix/glued-dfc-image-lookup
Jul 5, 2026
Merged

fix(cards): resolve glued combined multi-face names in image lookup#5125
matthewevans merged 1 commit into
phase-rs:mainfrom
JacobWoodson:fix/glued-dfc-image-lookup

Conversation

@JacobWoodson

Copy link
Copy Markdown
Contributor

Summary

Makes the deck-builder image/type lookup resolve glued combined multi-face names ("Front//Back", no spaces) so they render their art instead of a text-tile fallback.

fetchCardData (via resolveNameLookupKey in scryfall.ts) does a direct key lookup into the local card-data map. That map keys multi-face cards by oracle id, spaced display name ("front // back"), and front-face name — never the glued form. So a card entered as a hand-typed glued combined name missed every key and threw "Card not in local data", falling back to a text tile. (The engine still resolved the card via its own // split, so the deck loaded — only the thumbnail was lost.)

Fix

Add a front-face fallback to resolveNameLookupKey: when a // name isn't a direct or diacritic-folded key, split on // and resolve the front face, which the export always indexes. This mirrors the engine's card_db lookup_key behavior, so the display layer and the engine agree.

A single-faced card whose own printed name contains // (e.g. SP//dr, Piloted by Peni) is itself a primary key and hits the exact-match path first, so it is never mis-split.

Verification

scryfall (vitest): the three new tests pass —

  • a glued combined name ("Peter Parker//The Amazing Spider-Man") resolves to the card entry via the front face;
  • the canonical spaced form still resolves directly;
  • a single-faced //-in-name card ("SP//dr, Piloted by Peni") resolves to itself, not mis-split.

tsc -b --noEmit is clean. (Two unrelated pre-existing tests in this file shell out to gen-scryfall-*.sh and need jq/bash, absent in my local env — they don't touch this code path.)

Relationship to #4790

Independent of, but complementary to, the #4790 deck-parser fix. That PR stops corrupting //-in-name cards during parsing; this PR hardens the display layer so any glued combined name (from old saved decks, unusual paste sources, or a future import source) shows its art. Neither depends on the other.

🤖 Generated with Claude Code

The deck-builder image/type lookup (scryfall.ts) does a direct key lookup
into card-data, which keys multi-face cards by oracle id, spaced display
name, and front-face name — never the glued "Front//Back" form. A card
entered as a hand-typed glued combined name therefore missed every key and
rendered a text-tile fallback instead of its art (the engine still resolved
it via its own "//" split, so it loaded fine — only the thumbnail was lost).

Add a front-face fallback to resolveNameLookupKey: when a "//" name isn't a
direct/folded key, split on "//" and resolve the front face, which the export
always indexes. This mirrors the engine's card_db lookup_key behavior.

A single-faced card whose own printed name contains "//" (e.g. "SP//dr,
Piloted by Peni") is a primary key and hits the exact-match path first, so it
is never mis-split.

Tests: glued and spaced combined names both resolve to the card entry, and a
single-faced "//"-in-name card resolves to itself.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@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!

@matthewevans matthewevans added the defer-fe Frontend/client/UI PR deferred to Matt's direct review label Jul 5, 2026
@matthewevans matthewevans self-assigned this Jul 5, 2026
@matthewevans matthewevans added the bug Bug fix label Jul 5, 2026
@matthewevans

Copy link
Copy Markdown
Member

Thanks for the follow-up in your first contribution set. This neatly closes the display-side case by resolving hand-typed glued multi-face names without regressing real // names like SP//dr, Piloted by Peni.

@matthewevans matthewevans left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maintainer review: ready. The Scryfall lookup fallback is ordered correctly, covered, and CI is green.

@matthewevans matthewevans added this pull request to the merge queue Jul 5, 2026
@matthewevans matthewevans removed their assignment Jul 5, 2026
Merged via the queue into phase-rs:main with commit 6c4924b Jul 5, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bug fix defer-fe Frontend/client/UI PR deferred to Matt's direct review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants