CribbageGametype
A GAME OF CRIBBAGE: its table and moves (what is kept, KeptCardGame), and
everything the moves make, read again from them whenever the game is. Two
seats; size is the score that wins, 61 or 121.
Import it
import type { CribbageGame } from "@johnmorrisdotca/toranpu/cribbage";
Definition
type CribbageGame = KeptCardGame<CribbageMove> & {
deal: number;
phase: CribbagePhase;
hands: CardId[][];
kept: CardId[][];
crib: CardId[];
cut: CardId;
starter: CardId | null;
count: number;
run: CribbagePlay[];
pegged: CribbagePlay[];
peg: CribbagePeg | null;
toPlay: number | null;
scores: [
number,
number
];
results: CribbageHandScore[];
};
Members
| Name | Type | Description |
|---|---|---|
size | number | |
players | readonly string[] | |
computers | readonly boolean[] | |
seed | number | |
moves | readonly CribbageMove[] | |
deal | number | Which hand this is, from 0: the deal goes to the other player each time. |
phase | CribbagePhase | |
hands | string[][] | The cards each seat still holds: six dealt, four kept, then played away in the pegging. |
kept | string[][] | The four cards each seat kept, as they will be shown. |
crib | string[] | |
cut | string | The card to be cut once the crib is laid: face down until then, so never shown. |
starter | string | null | The starter, once cut. |
count | number | The pegging count, 0 to 31. |
run | CribbagePlay[] | The cards played since the count last went back to nought. |
pegged | CribbagePlay[] | Every card played in the pegging this hand. |
peg | CribbagePeg | null | What the last card played scored, if it scored. |
toPlay | number | null | |
scores | [number, number] | |
results | CribbageHandScore[] | Each hand shown, one row a hand. |
Examples
import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu";
import type { CribbageGame } from "@johnmorrisdotca/toranpu/cribbage";
const names = Array.from({ length: CARD_GAME_TABLES.cribbage.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`);
const game = newGame("cribbage", { players: names, seed: 42 })!;
const value: CribbageGame = game;
console.log(value.phase);cribWhat it prints (run when this page was built)