playCrazyEightsfunction
The game after that move, with the move added to its record, or null for a move the rules refuse.
Import it
import { playCrazyEights } from "@johnmorrisdotca/toranpu/crazy-eights";
Definition
function playCrazyEights(game: CrazyEightsGame, move: CrazyEightsMove): CrazyEightsGame | null
Parameters
| Name | Type | Description |
|---|---|---|
game | CrazyEightsGame | The current native game; applying a move returns a new state. |
move | CrazyEightsMove | The native move to validate or apply. |
Returns
CrazyEightsGame | null
The game after that move, with the move added to its record, or null for a move the rules refuse.
Examples
import { CARD_GAME_TABLES, newGame, rulesFor } from "@johnmorrisdotca/toranpu";
import { playCrazyEights } 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 })!;
console.log(playCrazyEights(game, rulesFor("crazyEights").moves(game)[0]!)?.moves.length);1What it prints (run when this page was built)