fix(client): count spell colors in dominant-color detection (shard variant names)#5411
Open
boskodev790 wants to merge 1 commit into
Open
fix(client): count spell colors in dominant-color detection (shard variant names)#5411boskodev790 wants to merge 1 commit into
boskodev790 wants to merge 1 commit into
Conversation
…riant names)
The battlefield/deck dominant-color helpers keyed their shard lookup by MTG
symbols (W/U/B/R/G), but the engine serializes ManaCost shards as Rust variant
names ("White", "WhiteBlue", "PhyrexianRed"). Every shard lookup therefore
missed, so no nonland card's mana cost ever contributed a color — only land
subtypes counted, collapsing the tint to a lands-only signal.
Bridge shards through the canonical SHARD_ABBREVIATION map (variant name ->
symbol) before splitting hybrid/Phyrexian halves on '/', matching how
keywordProps and costLabel already interpret shards.
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
🚨 Contributor flagged. Click here for more info: Superagent Dashboard |
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.
Problem
The dominant-color helpers in
viewmodel/dominantColor.ts(getDominantManaColor,getDeckDominantColor) key their shard→color lookup by MTG symbols (W/U/B/R/G) and split each shard on"/"to catch hybrids like"W/U".But the engine does not serialize
ManaCostshards as symbols — it serializes them as Rust variant names:"White","Red","WhiteBlue","PhyrexianRed", etc. This is the same conventioncostLabel.tsdocuments onSHARD_ABBREVIATION("Converts Rust ManaCostShard variant names to MTG abbreviations") and thatkeywordProps.tsrelies on, and it's the format used by the sharedgameObjectFactoryand every other viewmodel/game test (shards: ["Red"],["White"],["WhiteBlue"]).Because
"White".split("/")is["White"]andSHARD_TO_COLOR["White"]isundefined, no nonland card's mana cost ever contributed a color. Dominant-color detection collapsed to a lands-only signal, socomponents/board/BattlefieldBackground.tsxignored spell colors entirely (a mono-red spellslinger deck with basic Islands would tint blue).The previous
dominantColor.test.tsmasked this: its two spell-cost cases fed the fake["W","W"]/["R"]format — the lone place in the repo disagreeing with the factory and every other test.Fix
Bridge each shard through the canonical
SHARD_ABBREVIATIONmap (variant name → symbol) before splitting on"/", then look up each colored half — mirroring exactly howkeywordProps/costLabelalready interpret shards. This makes mono, hybrid (WhiteBlue→W/U→ White + Blue), and Phyrexian (PhyrexianRed→R/P→ Red) shards all count correctly, while colorless/snow/X halves are ignored.Tests
viewmodel/__tests__/dominantColor.test.ts:["White","White"],["Red"]). With the pre-fix symbol-keyed lookup these now returnnull/wrong color — proven fail-before, pass-after.["WhiteBlue"]+["Blue"]→ Blue wins (hybrid contributes to both White and Blue).Verified with vitest: all 11 tests pass after the fix; reverting only the source change fails exactly the 3 spell-color tests (discriminating).
Model: claude-opus-4-8