fix(client): enforce colorless color identity for colorless commanders#5186
Open
jeffrey701 wants to merge 1 commit into
Open
fix(client): enforce colorless color identity for colorless commanders#5186jeffrey701 wants to merge 1 commit into
jeffrey701 wants to merge 1 commit into
Conversation
isInColorIdentity short-circuited 'if (identity.length === 0) return true', so a genuinely colorless commander (e.g. Kozilek, color identity []) allowed any card — a red card passed as legal, violating CR 903.5c (a colorless commander permits only colorless cards). The short-circuit doubled as a 'commander data not loaded' guard, so simply dropping it would flag every colored card during the load window. Move that guard to getColorIdentityViolations (skip until all commanders are cached) and let [].every() enforce the colorless case correctly.
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
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
isInColorIdentity(client/src/components/deck-builder/commanderUtils.ts) began withif (identity.length === 0) return true;. For a genuinely colorless commander (e.g. Kozilek, Butcher of Truth — color identity[]), the combined identity is empty, so every card was treated as legal. A red card like Lightning Bolt passed the color-identity check, but CR 903.5c permits only colorless cards in a colorless commander's deck.The subtlety (and why a naive fix is wrong): that same empty-identity short-circuit also absorbed the "commander card data hasn't loaded yet" case — a cache miss yields an empty identity too. Dropping the short-circuit outright would flag every colored card in the deck during the async card-data load window (false positives on a fresh open).
Fix
identity.length === 0 -> trueshort-circuit fromisInColorIdentity;card.color_identity.every(c => set.has(c))already does the right thing —[].every()istrue(colorless card legal), a colored card isfalse(violation).getColorIdentityViolations: return[]until every commander's data is cached, so a cache miss can't masquerade as "colorless commander."Behavior for colored commanders and for the loading window is unchanged; only the genuinely-colorless-commander case is corrected.
Tests
Adds
commanderUtils.test.ts: a colorless commander (Kozilek) now flags an off-color card and allows a colorless one (fails before the fix — no violation reported); a colored commander still flags only off-color cards; and an unloaded commander yields no violations (no false positives mid-load).Self-contained: only
commanderUtils.ts+ a new test; no engine/Rust/protocol changes.Model: claude-opus-4-8