HeartsViewtype
What the seat to move can see: its own hand and the table.
Import it
import type { HeartsView } from "@johnmorrisdotca/toranpu/hearts";
Definition
type HeartsView = {
seat: number;
seats: number;
hand: readonly CardId[];
phase: HeartsGame["phase"];
trick: readonly HeartsPlay[];
seen: ReadonlySet<CardId>;
playable: readonly CardId[];
};
Members
| Name | Type | Description |
|---|---|---|
seat | number | |
seats | number | |
hand | readonly string[] | |
phase | HeartsPhase | |
trick | readonly HeartsPlay[] | |
seen | ReadonlySet<string> | Every card already played this deal, finished tricks and the one on the table. |
playable | readonly string[] |
Examples
import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu";
import type { HeartsView } from "@johnmorrisdotca/toranpu/hearts";
import { heartsView } from "@johnmorrisdotca/toranpu/hearts";
const names = Array.from({ length: CARD_GAME_TABLES.hearts.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`);
const game = newGame("hearts", { players: names, seed: 42 })!;
const value: HeartsView = heartsView(game);
console.log(value.hand.length);13What it prints (run when this page was built)