Skip to the content

Toranpuトランプ

Use a deck, play eleven games with computers, solve a solitaire, or display cards in your own design.

Toranpu is Japanese for playing cards. About the name

Contents

Reference · Hearts

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

NameTypeDescription
seatnumber
seatsnumber
handreadonly string[]
phaseHeartsPhase
trickreadonly HeartsPlay[]
seenReadonlySet<string>

Every card already played this deal, finished tricks and the one on the table.

playablereadonly 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);
13

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/toranpu 2.15.0.