HeartsGametype
A GAME OF HEARTS: its table and moves (what is kept, KeptCardGame), and
everything the moves make, read again from them whenever the game is.
size is the score that ends the game: 50 or 100.
Import it
import type { HeartsGame } from "@johnmorrisdotca/toranpu/hearts";
Definition
type HeartsGame = KeptCardGame<HeartsMove> & {
deal: number;
phase: HeartsPhase;
hands: CardId[][];
passing: (CardId[] | null)[];
received: CardId[][];
trick: HeartsPlay[];
lastTrick: {
plays: HeartsPlay[];
winner: number;
} | null;
played: CardId[];
toPlay: number | null;
heartsBroken: boolean;
points: number[];
scores: number[];
dealScores: number[][];
moon: number | null;
};
Members
| Name | Type | Description |
|---|---|---|
size | number | |
players | readonly string[] | |
computers | readonly boolean[] | |
seed | number | |
moves | readonly HeartsMove[] | |
deal | number | Which deal this is, from 0: it decides the way the cards are passed. |
phase | HeartsPhase | |
hands | string[][] | |
passing | (string[] | null)[] | The three cards each seat has chosen to pass this deal, or null while it has not. |
received | string[][] | The three cards each seat was passed this deal, shown to that seat once the passing is done. |
trick | HeartsPlay[] | The trick on the table, in the order it was played. |
lastTrick | { plays: HeartsPlay[]; winner: number; } | null | The trick before, and who took it: what a player may still look back at. |
played | string[] | Every card played in a finished trick this deal: what everybody at the table has seen. |
toPlay | number | null | Whose move it is; null once the game is over. |
heartsBroken | boolean | |
points | number[] | Each seat's points taken this deal, so far. |
scores | number[] | Each seat's total before this deal. |
dealScores | number[][] | Each finished deal's points, one row a deal. |
moon | number | null | The seat that took every point of the last finished deal, if one did. |
Examples
import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu";
import type { HeartsGame } 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: HeartsGame = game;
console.log(value.phase);passingWhat it prints (run when this page was built)