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 · Spades

spadesPlayablefunction

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

Import it

import { spadesPlayable } from "@johnmorrisdotca/toranpu/spades";

Definition

function spadesPlayable(game: SpadesGame): CardId[]

Parameters

NameTypeDescription
gameSpadesGame

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 { spadesPlayable } from "@johnmorrisdotca/toranpu/spades";

const names = Array.from({ length: CARD_GAME_TABLES.spades.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`);
let game = newGame("spades", { players: names, seed: 42 })!;
const rules = rulesFor("spades");
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(spadesPlayable(game));
[
  'KD', 'AD', '6C',
  '8C', 'JC', 'AC',
  '3H', '6H', 'TH',
  'JH'
]

What it prints (run when this page was built)

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