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 · Crazy Eights

crazyPlayablefunction

The cards the player to move may play now: after drawing, only the card drawn.

Import it

import { crazyPlayable } from "@johnmorrisdotca/toranpu/crazy-eights";

Definition

function crazyPlayable(game: CrazyEightsGame): CardId[]

Parameters

NameTypeDescription
gameCrazyEightsGame

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

Returns

string[]

The cards the player to move may play now: after drawing, only the card drawn.

Examples

import { CARD_GAME_TABLES, newGame, rulesFor } from "@johnmorrisdotca/toranpu";
import { crazyPlayable } from "@johnmorrisdotca/toranpu/crazy-eights";

const names = Array.from({ length: CARD_GAME_TABLES.crazyEights.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`);
let game = newGame("crazyEights", { players: names, seed: 42 })!;
const rules = rulesFor("crazyEights");
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(crazyPlayable(game));
[ '3S' ]

What it prints (run when this page was built)

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