Bridge Training
Bridge Core

Notation

Locale-aware rank parsing, formatting, and suit mappings.

Import from @workspace/bridge-core/notation.

The notation module handles locale-specific display and parsing of card ranks and suit symbols. It supports 10 locales and both the classic and petit-bridge variants.

Engine Module

When using the engine, notation is available as engine.notation with variant and locale pre-configured from the BridgeContext:

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

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

// Parse locale-specific input to standard ranks
engine.notation.parseRanks("RDV");   // ["K", "Q", "J"]

// Format standard ranks to locale-specific display
engine.notation.formatRanks(["K", "Q", "J"]); // "R D V"

// Format a single rank
engine.notation.formatRank("K"); // "K"

// Sort ranks by variant-specific order
engine.notation.sortRanks(["Q", "A", "J"]); // ["A", "Q", "J"]

// Get valid ranks for the variant
engine.notation.validRanks; // ["A", "K", "Q", "J", "T", "9", "8", "7", "6", "5", "4", "3", "2"]

Petit-bridge

In petit-bridge mode, ranks are remapped to a 1–10 scale (10 cards per hand):

const pb = createBridgeEngine({ teachingMode: 'petit-bridge', locale: 'fr' });

// Standard ranks are displayed as numbers
pb.notation.formatRank("A");  // "10"
pb.notation.formatRank("K");  // "9"
pb.notation.formatRank("5");  // "1"

// Parse and format use the remapped values
pb.notation.parseRanks("987");              // ["K", "Q", "J"]
pb.notation.formatRanks(["K", "Q", "J"]);   // "9 8 7"

pb.notation.validRanks; // ["A", "K", "Q", "J", "T", "9", "8", "7", "6", "5"]

Module API

PropertyTypeDescription
variantSuitVariantActive variant ("classic" or "petit-bridge")
localeLocaleActive locale
parseRanks(input)(string) => Rank[]Parse locale-specific input to standard ranks
formatRanks(ranks)(Rank[]) => stringFormat standard ranks to locale display
formatRankRankFormatterFormat a single rank to display string
sortRanks(ranks)(string[]) => string[]Sort ranks by variant-specific order
validRanksreadonly Rank[]Valid ranks for the active variant
getRankMapping()() => RankMappingGet the full rank mapping for current variant+locale
getSuitMappings()() => Record<...>Get suit symbol mappings for current variant+locale
getBidLabelMapping()() => Record<string, string>Get locale-specific bid label mappings (e.g. Pass, Double)
getPlayerLabelMapping()() => Record<string, string>Get locale-specific player label mappings (e.g. North, South)

Types

TypeDefinitionDescription
Locale"en" | "fr" | "es" | "ca" | "de" | "pt" | "el" | "nl" | "sv" | "pl"Supported locales
RankMappingPartial<Record<Rank, readonly string[]>>Maps standard ranks to accepted input strings (first = display)
RankFormatter(rank: Rank) => string | nullConverts an internal rank to a display string

On this page