Types
Core domain types for bridge game modeling.
All types are available from @workspace/bridge-core/types or from the root export.
Player & Position
type Player = "N" | "E" | "S" | "W";
type Partnership = "NS" | "EW";
type PlayerSide = "attack" | "defense";Cards
type Suit = "S" | "H" | "D" | "C";
type Rank = "A" | "K" | "Q" | "J" | "T" | "9" | "8" | "7" | "6" | "5" | "4" | "3" | "2";
/** Suit followed by rank, e.g. "SA" (Ace of Spades), "H7" (Seven of Hearts) */
type Card = `${Suit}${Rank}`;Hands
Hand
A single player's hand organized by suit.
Hands
All four hands at the table, keyed by player position.
type HandData<TCard extends string = string> = Record<Suit, TCard[]>;
type HandsData<TCard extends string = string> = Record<Player, HandData<TCard>>;Bids
type BidLevel = 1 | 2 | 3 | 4 | 5 | 6 | 7;
type BidSuit = Suit | "NT";
type SpecialBid = "Pass" | "X" | "XX" | "Alert";
/** e.g. "1H", "3NT", "7S" */
type RegularBid = `${BidLevel}${BidSuit}`;
type Bid = RegularBid | SpecialBid;
type CounterStatus = "none" | "X" | "XX";
/** The level and suit extracted from a regular bid. */
type RegularBidParts = { level: BidLevel; suit: BidSuit };Bid Composites
RegularBidComposite
A regular bid with full context in the auction sequence.
SpecialBidComposite
A special bid with full context in the auction sequence.
type BidComposite = RegularBidComposite | SpecialBidComposite;Contract
Contract
Final contract determined after the auction.
DisplayContract
Contract for display purposes (without declarer information).
ContractResult
Result of calculating the contract from a bid sequence.
type ContractLevel = "partial" | "game" | "small_slam" | "grand_slam";Auction
BidInfo
Information about a single bid in the auction sequence.
AuctionState
Complete auction state tracking the bidding sequence.
type Auction = { N: Bid[]; E: Bid[]; S: Bid[]; W: Bid[] };
type AuctionSequence = BidComposite[];Deal
Deal
A complete deal with identifier.
DealMetadata
Complete deal metadata (event info, results, annotations, technical data).
DealAuction
Auction data in deal format.
DealPlay
Card play data in deal format.
type PlayerHand = Record<Suit, string>;
type AllHands = Record<Player, PlayerHand>;Play
PlayEntry
A single card played by a player.
Trick
A complete trick (4 cards played, one per player).
TrickEntry
Generic trick entry with card as string (flexible for form data).
GenericTrick
Generic trick structure (flexible for form data).
PlayState
State of the card play phase.
PlayAnnotation
An annotation on a specific point in the card play.
Configuration
type AuctionMode = "trump" | "goal" | "contract" | "sequence" | "interactive";
type SuitVariant = "classic" | "petit-bridge";CoreConfig
Minimal configuration for core services (game rules). Discriminated union: validBidSuits only exists when auctions is not false.
ParsingConfig
Minimal configuration for parsing functions.
Other Types
type Vulnerability = "ALL" | "NS" | "EW" | "NONE" | "UNSET";
/** Resolved vulnerability status for a specific player. */
type VulnerabilityStatus = "vulnerable" | "non-vulnerable" | "unset";
type ScoringMode = "UNSET" | "TPP" | "IMP";
type TeachingMode =
| "auction"
| "show-trump-goal"
| "no-auction"
| "show-trump"
| "show-contract"
| "h"
| "hd"
| "hld"
| "sequence"
| "petit-bridge"
| "no-dummy";Analysis
HandAnalysis
HCP and distribution analysis for a single hand.
type SuitCount = Record<Suit, number>;
type DealAnalysis = Record<Player, HandAnalysis>;HandCardCounts
HCP and suit distribution counts for a single hand.
/** HCP and suit distribution counts for all hands. */
type CardCounts = Record<Player, HandCardCounts>;PBN
/** e.g. "N:AKQ.JT.9876.5432 AKQ.JT.9876.5432 AKQ.JT.9876.5432 AKQ.JT.9876.5432" */
type PBN<TPlayer extends Player = Player> =
`${TPlayer}:${string}.${string}.${string}.${string} ${string}.${string}.${string}.${string} ${string}.${string}.${string}.${string} ${string}.${string}.${string}.${string}`;Utilities
/** Deterministic pseudo-random number generator based on a seed. */
type SeededRandom = {
next(): number;
};