Skip to the content

Tenka天下

Play seeded world conquest for two to six, with dice battles, cards, computer players and saved games.

Tenka means the world under heaven in Japanese. About the name

Contents

How-to

Save, restore and export

Save a game as its deal and moves, restore it by replaying them, and export a readable record.

Save the original deal and moves

encodeTenka writes compact versioned text. decodeTenka validates it by replaying from the original table and seed. tenkaToJSON writes the structured exported format; tenkaFromJSON also accepts compact text and rebuilds the state instead of trusting a supplied final board.

import {startTenka,encodeTenka,decodeTenka,tenkaToJSON,tenkaFromJSON} from "@johnmorrisdotca/tenka";
const game = startTenka(10,["Seat 1","Seat 2"],42)!;
console.log(decodeTenka(encodeTenka(game))?.seed);
console.log(tenkaFromJSON(tenkaToJSON(game))?.map);
42
undefined

Keep all setup choices

Preserve rounds, players, seed, placing and map. replayTenka applies the record and returns null for invalid setup or any impossible move. Never edit the seed beneath a played record: every die, shuffled territory and card depends on its stream.

Export a readable record

tenkaRecord reconstructs detailed roll, trade, elimination and end results. tenkaToText uses local words, and tenkaToCSV writes the tabular record. These exports can include names supplied locally; choose deliberate public seat labels before sharing. The native embed events and frame messages use generic seat labels, while local getters retain names. The embed contract documents this boundary.

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/tenka 2.2.0.