Bridge Training

Notation

Locale-aware rank parsing and formatting, rank and suit mappings, and the pre-configured engine.notation module.

Notation converts between the internal rank letters (A K Q J T 9 … 2) and what a player types or reads in a given locale and variant. The classic variant uses the 13-card deck and locale letters (French R D V, German D B, Swedish E D Kn…). The petit-bridge variant uses a 10-card deck displayed as numbers 10 … 1 in every locale.

Supported locales come from LOCALES in @workspace/bridge/constants: en, fr, es, it, ca, de, pt, el, nl, sv, pl.

Parsing and formatting depend on the variant and the locale, so they are only reachable through engine.notation, which binds both from the BridgeContext. The context-free pieces (rank orders, the rank mapping reader and the suit mapping tables) are exported by @workspace/bridge/card (DEFAULT_RANK_ORDER), @workspace/bridge/notation (PETIT_BRIDGE_RANK_ORDER, the types) and @workspace/bridge/locale (the mappings).

engine.notation

createBridgeEngine exposes the notation operations with the variant and locale already bound from the context. The variant is petit-bridge for the petit-bridge teaching mode and classic otherwise.

MemberTypeDescription
variantSuitVariantActive variant.
localeLocaleActive locale.
parseRanks(input)(string) => Rank[]Reads a typed string into standard ranks. Case-insensitive, ignores whitespace, matches longer tokens first (10, Kn), skips characters that match nothing.
formatRanks(ranks)(readonly Rank[]) => stringSorts the ranks by DEFAULT_RANK_ORDER and joins their preferred display value with a space. Ranks absent from the variant's mapping are dropped.
formatRankRankFormatterFirst display value of the rank mapping (K → "R" in French, A → "10" in petit-bridge); null for a rank outside the variant's deck.
sortRanks(ranks)(readonly Rank[]) => Rank[]Sorter on PETIT_BRIDGE_RANK_ORDER or DEFAULT_RANK_ORDER.
validRanksreadonly Rank[]Ranks of the mode's deck (13 or 10).
notation.ts
const engine = createBridgeEngine(
  createBridgeContext({ teachingMode: "auction", locale: "fr" }),
);

engine.notation.locale; // => "fr"
engine.notation.variant; // => "classic"
engine.notation.parseRanks("RDV"); // => ["K", "Q", "J"]
engine.notation.formatRanks(["K", "Q", "J"]); // => "R D V"
engine.notation.formatRank("K"); // => "R"
engine.notation.sortRanks(["Q", "A", "J"]); // => ["A", "Q", "J"]
engine.notation.validRanks; // => ["A", "K", "Q", "J", "T", "9", "8", "7", "6", "5", "4", "3", "2"]
notation.ts
const petitBridge = createBridgeEngine(
  createBridgeContext({ teachingMode: "petit-bridge", locale: "fr" }),
);

petitBridge.notation.variant; // => "petit-bridge"
petitBridge.notation.formatRank("A"); // => "10"
petitBridge.notation.formatRank("5"); // => "1"
petitBridge.notation.parseRanks("987"); // => ["K", "Q", "J"]
petitBridge.notation.validRanks; // => ["A", "K", "Q", "J", "T", "9", "8", "7", "6", "5"]

Rank orders

Import DEFAULT_RANK_ORDER from @workspace/bridge/card and PETIT_BRIDGE_RANK_ORDER from @workspace/bridge/notation.

ExportSignatureDescription
DEFAULT_RANK_ORDERreadonly Rank[]13 ranks, highest first.
PETIT_BRIDGE_RANK_ORDERreadonly Rank[]10 ranks, A to 5, highest first.
notation.ts
DEFAULT_RANK_ORDER.length; // => 13
PETIT_BRIDGE_RANK_ORDER.length; // => 10

Rank mappings

Import from @workspace/bridge/locale.

ExportSignatureDescription
getRankMapping(variant: SuitVariant, locale: Locale) => RankMappingThe mapping for a variant and locale. Petit-bridge has one numeric mapping, so the locale is ignored there; classic reads the locale's table.

A RankMapping lists, for each rank, the accepted inputs. The first entry is the display value. Only the honours and the ten vary; 9 to 2 are always the digit itself.

Classic mappings

LocaleAKQJT
enAKQJ10, T
frAR, KD, QV, J10, T
esAR, KD, QV, J10, T
itAK, RQ, DJ, F10, T
caAKQJ10, T
deAKD, QB, J10, T
ptAR, KD, QV, J10, T
elΑ, AΡ, KΝ, QΒ, J10, Τ, T
nlAH, KV, QB, J10, T
svE, AKD, QKn, J10, T
plAKD, QW, J10, T

Petit-bridge mapping (all locales)

RankAKQJT98765
Inputs10, T987654321

Suit mappings

Import from @workspace/bridge/locale.

ExportSignatureDescription
CLASSIC_SUIT_MAPPINGSRecord<Locale, Record<string, readonly string[]>>Accepted suit letters per locale, display value first.
PETIT_BRIDGE_SUIT_MAPPINGSRecord<string, readonly string[]>Colour letters: S→R (rouge), H→V (vert), D→J (jaune), C→B (bleu).
LocaleSHDC
enSHDC
frP, SC, HK, DT
esP, SC, HDT
itP, SC, HQ, DF, C
caP, SC, HDT
deP, SHK, DT
ptE, SC, HO, DP
elΠ, SΚ, HΚα, DΣ, C
nlSHR, DK, C
svSHj, HR, DK, C
plP, SK, HK, DT, C
notation.ts
const french: RankMapping = getRankMapping("classic", "fr");
french.K; // => ["R", "K"] — first entry is the display preference

getRankMapping("petit-bridge", "fr").A; // => ["10", "T"] (same mapping in every locale)

CLASSIC_SUIT_MAPPINGS.de; // => { S: ["P", "S"], H: ["H"], D: ["K", "D"], C: ["T"] }
CLASSIC_SUIT_MAPPINGS.pt.S; // => ["E", "S"]

Types

Import from @workspace/bridge/notation.

TypeDefinition
RankMappingPartial<Record<Rank, readonly string[]>> — accepted inputs per rank, first entry is the display preference.
RankFormatter(rank: Rank) => string | null — display string for one rank, null when the rank is not displayable in the variant.

Translated labels for players, bids, vulnerability or scoring are not part of this package. UI packages receive them through a Strings Provider.