Bridge Training

LIN

Serialize a Deal to the single-line LIN format used by Bridge Base Online.

Import from @workspace/bridge/lin.

LIN is the pipe-delimited, single-line deal format of Bridge Base Online (BBO): a sequence of tag|value| pairs that BBO's hand viewer and movie player read. This package only writes LIN; there is no LIN parser.

ExportSignatureDescription
serializeDealToLIN(deal: Deal, options?: LINSerializeOptions) => stringOne LIN line for the deal.
LINSerializeOptionstypeBoard number and player names.

Prop

Type

lin.ts
const deal = makeDeal((d) =>
  d
    .withHands((h) => h.fromCompact("AKQ2.KQ3.A54.K32 JT98.JT9.KQJ.QJ9 7654.A87.T98.AT8 3.6542.7632.7654"))
    .withMetadata((m) => m.withDealer("N").withVulnerable("NS").withResult("9"))
    .withAuction((a) => a.fromCompact("N / 1NT pass 3NT AP"))
    .withContract(new ContractBuilder().fromCompact("N / 3NT").build())
);

const options: LINSerializeOptions = {
  boardNumber: 5,
  playerNames: ["South", "West", "North", "East"],
};

const lin = serializeDealToLIN(deal, options);
// lin starts with "qx|o5|pn|South,West,North,East|st||md|3..." and contains
// "sv|n|" and "mb|1N|mb|p|mb|3N|mb|p|mb|p|mb|p|" then "mc|9|pg||"

What is written

Tags are emitted in this order:

TagContent
qx|o<n>|Board number (1 by default).
pn|S,W,N,E|Player names in South, West, North, East order (empty by default).
st||Fixed.
md|<dealer><S>,<W>,<N>,|Dealer code (1 S, 2 W, 3 N, 4 E; 3 when unknown) then the South, West and North hands as S…H…D…C…, each suit's rank string reversed (lowest to highest for a sorted hand). East is omitted, BBO infers it.
rh||ah|Board <n>|Board label.
sv|<v>|Vulnerability: o none, n NS, e EW, b both; o when unset.
mb|<bid>|…Each auction move: p pass, d double, r redouble, bids with NT shortened to N (3N). An empty auction writes three passes.
pg||pc|<card>|…Play grouped per trick, cards as lowercase suit plus rank (hA); ** and - placeholders become pc|**|. An empty play writes |pg|.
mc|<tricks>|pg||Claimed trick count resolved from metadata.result and the contract; omitted when it cannot be resolved.

What is not written

  • East's hand (implied), the contract and declarer tags (BBO derives them from the auction).
  • Auction alerts and comments, play comments, the review, and PBN notes.
  • Scoring mode, teaching mode, custom tags, board metadata other than the number.