Bridge Training
Bridge Core

Engine

BridgeEngine factory and module composition.

The BridgeEngine is the main entry point for consuming bridge-core. It composes all modules based on a BridgeContext.

import { createBridgeEngine, createBridgeContext } from '@workspace/bridge-core';

const engine = createBridgeEngine({ teachingMode: 'auction', locale: 'fr' });

BridgeContext

The input context that determines how the engine behaves. Both teachingMode and locale are required.

Prop

Type

createBridgeContext

Creates a BridgeContext with defaults for any omitted fields. Defaults to teachingMode: "auction" and locale: "en".

import { createBridgeContext } from '@workspace/bridge-core';

// Full defaults
const ctx = createBridgeContext();
// { teachingMode: "auction", locale: "en" }

// Override specific fields
const ctx2 = createBridgeContext({ locale: 'fr' });
// { teachingMode: "auction", locale: "fr" }

getCtx

The engine exposes a getCtx() method that returns the BridgeContext it was created with:

const engine = createBridgeEngine({ teachingMode: 'auction', locale: 'fr' });

engine.getCtx();
// { teachingMode: "auction", locale: "fr" }

Module Configs

Each module receives a derived configuration from the context:

Prop

Type

Prop

Type

Prop

Type

Prop

Type

Available Modules

The engine exposes these modules:

ModuleDescription
engine.handsHand distribution, validation, queries, transforms
engine.auctionBid parsing, contract calculation, auction state
engine.notationLocale-aware rank parsing, formatting, suit mappings
engine.teachingTeaching mode logic and pedagogy
engine.playerPlayer navigation, rotation, partnerships
engine.playTrick evaluation, card follow rules
engine.rotationHands/auction/vulnerability rotation
engine.pbnPBN format parsing
engine.formatDisplay formatting (contracts)
engine.validationFull deal validation
engine.schemasZod validation schemas
engine.constantsGame constants and defaults
engine.parseCard and bid parsing utilities
engine.statsHand analysis (HCP, distribution)

On this page