本文へ移動

Toranpuトランプ

デッキを使い、11種類のゲームでコンピューターと対戦し、ソリティアを解いたり、独自の絵柄でカードを表示したりできます。

「トランプ」は、日本語で playing cards を指す言葉です。 名前について(英語)

目次

リファレンス · Reactコンポーネント

useCardGame関数

リファレンスの説明と例は英語です。見出しと目次は日本語です。

A card game held in React state. See CardGameState for what it hands back; computerDelay is the milliseconds a computer waits before each move.

インポート

import { useCardGame } from "@johnmorrisdotca/toranpu/react";

定義

function useCardGame<K extends CardGameKind>(kind: K, options: NewGameOptions, computerDelay?: number): CardGameState<K>

引数

名前型説明
kindK

The named card game or sound kind.

optionsNewGameOptions

Options for this call; omitted fields retain their documented defaults.

computerDelay (省略可)number

Milliseconds between computer turns in the React view.

戻り値

CardGameState<K>

A card game held in React state. See CardGameState for what it hands back; computerDelay is the milliseconds a computer waits before each move.

例

import { useCardGame } from "@johnmorrisdotca/toranpu/react";

import { createElement } from "react";
function Table() {
  const table = useCardGame("hearts", { players: ["You", "Aki", "Ben", "Cy"], seed: 42 });
  return createElement("p", null, `${table.moves.length} legal moves`);
}
console.log(createElement(Table));

ソースを見るGitHub で編集@johnmorrisdotca/toranpu 2.15.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。