Skip to content

fix(client): count wire-format mana shard variant names in dominant color#5181

Closed
jeffrey701 wants to merge 1 commit into
phase-rs:mainfrom
jeffrey701:fix/dominant-color-shard-names
Closed

fix(client): count wire-format mana shard variant names in dominant color#5181
jeffrey701 wants to merge 1 commit into
phase-rs:mainfrom
jeffrey701:fix/dominant-color-shard-names

Conversation

@jeffrey701

Copy link
Copy Markdown
Contributor

Problem

getDominantManaColor / getDeckDominantColor (client/src/viewmodel/dominantColor.ts) tint a deck by its dominant mana color. countColors looked up each shard in SHARD_TO_COLOR, a table keyed by abbreviations ("W", "U", …). But ManaCost.shards on the wire are the Rust variant names"White", "WhiteBlue", … (see SHARD_ABBREVIATION in costLabel.ts, and fixtures like shards: ["White","Blue"]). So SHARD_TO_COLOR["White"] is undefined: every colored spell contributed nothing to the count, and the tint was driven by lands alone.

Fix

Normalize each shard through SHARD_ABBREVIATION ("White"→"W", "WhiteBlue"→"W/U") before splitting hybrids. A ?? shard fallback keeps already-abbreviated inputs working, so nothing that previously counted stops counting.

Tests

Adds two cases to the existing dominantColor suite using the real wire-format variant names: a mono-color spell (["White","White"]) and a hybrid (["WhiteBlue"]). Both fail before the fix (dominant color comes back null) and pass after. The whole file stays green (the pre-existing abbreviated-form tests still pass via the fallback).

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

Model: claude-opus-4-8

…olor

getDominantManaColor/getDeckDominantColor tint decks by their dominant color, but countColors looked up mana shards in a table keyed by abbreviations ("W", "U", …) while the adapter emits Rust variant names ("White", "WhiteBlue", …). Every colored spell therefore contributed nothing and the tint was driven by lands alone. Normalize each shard through SHARD_ABBREVIATION before splitting hybrids; a `?? shard` fallback keeps already-abbreviated inputs working.
@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!

@jeffrey701 jeffrey701 requested a review from matthewevans as a code owner July 6, 2026 05:18
@jeffrey701

Copy link
Copy Markdown
Contributor Author

Closing as a duplicate of #5065, which fixes the same issue. Apologies for the noise.

@jeffrey701 jeffrey701 closed this Jul 6, 2026
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