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
| Property | Type | Description |
|---|---|---|
variant | SuitVariant | Active variant ("classic" or "petit-bridge") |
locale | Locale | Active locale |
parseRanks(input) | (string) => Rank[] | Parse locale-specific input to standard ranks |
formatRanks(ranks) | (Rank[]) => string | Format standard ranks to locale display |
formatRank | RankFormatter | Format a single rank to display string |
sortRanks(ranks) | (string[]) => string[] | Sort ranks by variant-specific order |
validRanks | readonly Rank[] | Valid ranks for the active variant |
getRankMapping() | () => RankMapping | Get 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
| Type | Definition | Description |
|---|---|---|
Locale | "en" | "fr" | "es" | "ca" | "de" | "pt" | "el" | "nl" | "sv" | "pl" | Supported locales |
RankMapping | Partial<Record<Rank, readonly string[]>> | Maps standard ranks to accepted input strings (first = display) |
RankFormatter | (rank: Rank) => string | null | Converts an internal rank to a display string |