encodeGinfunction
A game of Gin Rummy as text: its table, its seed and its moves, never a hand.
Import it
import { encodeGin } from "@johnmorrisdotca/toranpu/gin-rummy";
Definition
function encodeGin(game: GinGame): string
Parameters
| Name | Type | Description |
|---|---|---|
game | GinGame | The current native game; applying a move returns a new state. |
Returns
string
A game of Gin Rummy as text: its table, its seed and its moves, never a hand.
Examples
import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu";
import { encodeGin } from "@johnmorrisdotca/toranpu/gin-rummy";
const names = Array.from({ length: CARD_GAME_TABLES.ginRummy.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`);
let game = newGame("ginRummy", { players: names, seed: 42 })!;
console.log(encodeGin(game));{"v":1,"g":"ginRummy","size":100,"players":["Seat 1","Seat 2"],"computers":[false,false],"seed":42,"moves":[]}What it prints (run when this page was built)