From dce6f8f2eed22d5eee70e90a5e9d33155da9d2d8 Mon Sep 17 00:00:00 2001 From: Z8MB1E Date: Wed, 16 Sep 2026 19:10:37 -0400 Subject: [PATCH] fix(poker): dev panel card pickers ignored the first selection CardPicker propagated null into onChange when no card was selected yet, so the board picker's parent coerced every first pick to 2 of spades and the hole-card pickers could never hold a value, keeping Queue hand disabled forever. Picks now build a complete card, preserving any already-chosen half, with regression tests on the extracted helper. Co-authored-by: Sisyphus --- .../minigames/poker/PokerDevPanel.tsx | 37 ++++++++++++------- tests/int/poker-dev-controls.int.spec.ts | 13 +++++++ 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/components/frontend/minigames/poker/PokerDevPanel.tsx b/src/components/frontend/minigames/poker/PokerDevPanel.tsx index 2a8421a..be0beac 100644 --- a/src/components/frontend/minigames/poker/PokerDevPanel.tsx +++ b/src/components/frontend/minigames/poker/PokerDevPanel.tsx @@ -58,6 +58,24 @@ function cardLabel(card: Card): string { return `${rank} ${suit}`; } +/** + * Builds a complete card from one picker interaction: an empty selection + * starts from the 2-of-spades baseline for the not-yet-chosen half, and any + * already-chosen half is preserved. Returning a full card (never null) is + * what lets a single pick land; the previous null-propagating version made + * first picks no-ops and hole-card queuing impossible. + */ +export function applyCardPick( + value: Card | null, + part: "rank" | "suit", + next: string, +): Card { + if (part === "rank") { + return { rank: Number(next) as Rank, suit: value?.suit ?? "s" }; + } + return { rank: value?.rank ?? 2, suit: next as Suit }; +} + function CardPicker({ label, value, @@ -67,13 +85,13 @@ function CardPicker({ readonly value: Card | null; readonly onChange: (card: Card | null) => void; }) { + const setRank = (next: string) => onChange(applyCardPick(value, "rank", next)); + const setSuit = (next: string) => onChange(applyCardPick(value, "suit", next)); + return (
{label} - @@ -85,10 +103,7 @@ function CardPicker({ ))} - @@ -191,11 +206,7 @@ export function PokerDevPanel({

Board queue

- setBoardDraft(card ?? { rank: 2, suit: "s" })} - /> +