Bridge Core
Overview
Core bridge game rules, types, and utilities.
@workspace/bridge-core is the shared package for bridge domain logic. Its only runtime dependency is zod (for validation schemas); all other code is pure functions for game rules, type definitions, parsers, and validation.
Quick Start
import { createBridgeEngine } from '@workspace/bridge-core';
const engine = createBridgeEngine({ teachingMode: 'auction', locale: 'fr' });
// Use the engine modules
engine.hands.areComplete(hands);
engine.auction.calculateContract(sequence);
engine.notation.parseRanks("RDV"); // ["K", "Q", "J"]
engine.teaching.areAuctionsEnabled(auctionMode, teachDummy);Sub-path Exports
The package exposes granular sub-path exports for tree-shaking:
| Import Path | Description |
|---|---|
@workspace/bridge-core | Engine factory + all types |
@workspace/bridge-core/engine | BridgeEngine factory and config types |
@workspace/bridge-core/player | Player navigation, rotation, partnerships |
@workspace/bridge-core/card | Card parsing, type guards, sorting |
@workspace/bridge-core/auction | Bidding, contracts, auction state |
@workspace/bridge-core/hands | Hand distribution, validation, queries |
@workspace/bridge-core/play | Trick evaluation, card follow rules |
@workspace/bridge-core/notation | Locale-aware rank parsing, formatting, suit mappings |
@workspace/bridge-core/teaching | Teaching modes and pedagogy |
@workspace/bridge-core/rotation | Deal/hands/auction rotation |
@workspace/bridge-core/format | Display formatting |
@workspace/bridge-core/constants | Game constants and defaults |
@workspace/bridge-core/types | All TypeScript type definitions |
@workspace/bridge-core/errors | Error types and factories |
@workspace/bridge-core/schemas/* | Zod validation schemas |
@workspace/bridge-core/utils | HCP calculation, PBN conversion, random |
@workspace/bridge-core/validation | Full deal validation |
@workspace/bridge-core/parsers/pbn | PBN file parser |
Architecture
The package is organized in layers:
- Foundation — Types, constants, errors
- Primitives — Player, card, format (stateless utilities)
- Domain — Auction, hands, play, teaching (game rules)
- Cross-cutting — Rotation, validation, schemas, utils
- Integration — Engine (composes all modules via
BridgeContext)
Package Structure
index.ts
auction-contract.ts
auction-state.ts
auction-validation.ts
bid-parsing.ts
contract-level.ts
flattenAuction.ts
index.ts
card-parsing.ts
card-sort.ts
index.ts
bids.ts
board-numbering.ts
cards.ts
core-config.ts
defaults.ts
index.ts
players.ts
scoring.ts
engine.ts
index.ts
types.ts
auction-module.ts
constants-module.ts
format-module.ts
hands-module.ts
notation-module.ts
parse-module.ts
pbn-module.ts
play-module.ts
player-module.ts
rotation-module.ts
schemas-module.ts
stats-module.ts
teaching-module.ts
validation-module.ts
factories.ts
index.ts
pbn.ts
types.ts
contract.ts
hands-distribution.ts
hands-queries.ts
hands-transforms.ts
hands-validation.ts
index.ts
bid-label-mappings.ts
format-ranks.ts
index.ts
parse-ranks.ts
player-label-mappings.ts
rank-formatters.ts
rank-mappings.ts
suit-mappings.ts
types.ts
parseContract.ts
parseScoring.ts
parseVulnerability.ts
constants.ts
convert-pbn-deal.ts
create-empty-deal.ts
dup-to-pbn.ts
encoding.ts
generate-pbn-string.ts
handle-pbn-data.ts
parse-pbn-file.ts
parser-state.ts
pbn-notes.ts
pbn-tokenizer.ts
pbn.ts
types.ts
utils.ts
parse-contract.ts
parse-player.ts
parse-result.ts
parse-scoring.ts
parse-teaching.ts
parse-vulnerability.ts
schema.ts
index.ts
player-navigation.ts
player-rotation.ts
player-team.ts
index.ts
play-queries.ts
play-tricks.ts
index.ts
rotation-data.ts
rotation-vulnerability.ts
auction.ts
bid.ts
card.ts
game-params.ts
hands.ts
play.ts
player.ts
scoring.ts
teach-params.ts
vulnerability.ts
index.ts
parse-teaching.ts
teaching-logic.ts
teaching-modes.ts
Analysis.ts
Auction.ts
Bid.ts
Config.ts
Contract.ts
Deal.ts
Hands.ts
Locale.ts
PBN.ts
Play.ts
Player.ts
Scoring.ts
TeachingMode.ts
Vulnerability.ts
index.ts
computeHCP.ts
handsToPBN.ts
index.ts
seededRandom.ts
vulnerability.ts
deal-validation.ts
validation.ts