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

heartsPlayablefunction

The cards the seat to play may lay on the trick now.

Import it

import { heartsPlayable } from "@johnmorrisdotca/toranpu/hearts";

Definition

function heartsPlayable(game: HeartsGame): CardId[]

Parameters

NameTypeDescription
gameHeartsGame

The current native game; applying a move returns a new state.

Returns

string[]

The cards the seat to play may lay on the trick now.

Examples

import { CARD_GAME_TABLES, newGame, rulesFor } from "@johnmorrisdotca/toranpu";
import { heartsPlayable } from "@johnmorrisdotca/toranpu/hearts";

const names = Array.from({ length: CARD_GAME_TABLES.hearts.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`);
let game = newGame("hearts", { players: names, seed: 42 })!;
const rules = rulesFor("hearts");
for (let setup = 0; setup < 100 && game.phase !== "playing" && game.phase !== "over"; setup += 1) {
  const next = rules.play(game, rules.computer(game));
  if (next === null) throw new Error("Unexpected illegal setup move");
  game = next;
}
if (game.phase !== "playing") throw new Error("Setup did not reach playing");
console.log(heartsPlayable(game));
[ '2C' ]

What it prints (run when this page was built)

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