Reference · Rules, maps and records
tenkaToJSONfunction
A game as JSON, two spaces deep, with the format's number first. tenkaFromJSON reads it back.
Import it
import { tenkaToJSON } from "@johnmorrisdotca/tenka";
Definition
function tenkaToJSON(game: TenkaGame): string
Parameters
| Name | Type | Description |
|---|---|---|
game | TenkaGame | The current native game state. |
Returns
string
A game as JSON, two spaces deep, with the format's number first. tenkaFromJSON reads it back.
Examples
import { startTenka, tenkaToJSON } from "@johnmorrisdotca/tenka";
const game = startTenka(10,["Seat 1","Seat 2"],42)!;
console.log(tenkaToJSON(game));{
"format": 2,
"game": "tenka",
"generator": "tenka 2.2.0",
"seed": 42,
"players": [
"Seat 1",
"Seat 2"
],
"rounds": 10,
"placing": "auto",
"moves": [],
"state": {"round":1,"phase":"reinforce","toPlay":1,"winners":[]}
}What it prints (run when this page was built)