useCardGamefunction
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 it
import { useCardGame } from "@johnmorrisdotca/toranpu/react";
Definition
function useCardGame<K extends CardGameKind>(kind: K, options: NewGameOptions, computerDelay?: number): CardGameState<K>
Parameters
| Name | Type | Description |
|---|---|---|
kind | K | The named card game or sound kind. |
options | NewGameOptions | Options for this call; omitted fields retain their documented defaults. |
computerDelay (optional) | number | Milliseconds between computer turns in the React view. |
Returns
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.
Examples
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));