Preparing your design workspace

Loading the problem and your saved attempt…

Design and Implement an Extensible Three-Card Hand Evaluator

Model versioned three-card rules that classify, fold, compare, and log a round without coupling rule evolution to orchestration.

Design and implement the core of a two-player three-card game. Each hand has already been dealt from one standard 52-card deck. Ranks are 2 through 14 with Jack, Queen, King, and Ace represented as 11, 12, 13, and 14; suits are clubs, diamonds, hearts, and spades.

Reject a hand that does not contain exactly three distinct physical cards, and reject a round when the two hands share a card. Phase 1 recognizes Three of a Kind, Pair, and High Card in that order.

Three of a Kind compares its repeated rank; Pair compares the pair rank and then its kicker; High Card compares descending ranks lexicographically. Phase 2 adds Flush between Three of a Kind and Pair, and two Flush hands compare descending ranks like High Card.

Phase 3 first classifies both hands, then applies the rule literally that every category other than exactly Pair folds. One active hand wins immediately; two folded hands draw; otherwise the active hands use the phase's normal comparison and a complete comparison-key tie draws.

For this exercise, assume a caller chooses one immutable phase version for the whole round. Resolution must append ordered structured log events for validation, classification evidence, fold decisions, comparison keys, and the final outcome to a caller-supplied sink.

Keep deck construction, shuffling, dealing, betting, persistence, networking, and concurrent round resolution out of scope. Explain the responsibilities and extension boundaries, define focused contracts, walk through phase-three resolution, and implement the bounded classification and comparison core.

Your design should allow later hand categories and round rules without broad edits to the existing flow.