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

Reference

Browser table and SVG

import { … } from "@johnmorrisdotca/tenka/ui";

81.9 kB minified and gzipped, with everything it imports (measured with esbuild)

Tenka drawn and played in the browser, in plain DOM: a whole table against the computer (mountTenka), and the map on its own (tenkaMapSvg, drawn from tenkaMapModel). Its own entry, so the rules never carry the map.

Exports

NameKindWhat it is
continentNameInfunctionA continent's name in a table of strings, by its key ("northAmerica", "asia"…).
continentViewfunctionThe part of the map that frames a continent, with a margin, widened to the map's own shape so it fills the same box; the whole world for null.
landInDirectionfunctionThe territory a key moves to from another: the nearest counter in that direction, a little straighter being better than a little nearer, and only among those inside view (the whole map when none is given), so that the focus never leaves what is on the screen.
mountTenkafunctionA WHOLE TABLE OF TENKA IN PLAIN DOM: the map, whose turn it is and what to do, the players, your cards and the last dice, played against the computer (or by people taking turns on one device, with computers all false).
nearestLandfunctionThe territory whose counter is nearest a point of the map, within reach map units, or null.
NO_MARKSconstantNothing lit up.
ownerColourfunctionThe colour a territory's owner is drawn in.
TENKA_MAP_SHAPESconstantHow each map is drawn.
TENKA_NEUTRAL_COLOURconstantThe grey of the neutral army.
TENKA_SEAT_COLOURSconstantTHE COLOURS A TABLE IS DRAWN IN: one for each of six seats, and a grey for the neutral army that holds a third of the world in a game for two.
TENKA_STRINGSconstantThe package's words in each language it speaks: TENKA_STRINGS.en, TENKA_STRINGS.ja.
TENKA_STYLEconstantThe table's own styles, scoped to .tk-root, with every colour a CSS variable so a page can wear it in its own colours (set them on the element or any ancestor, or pass them as theme).
TenkaArrowtypeA way to move between territories from a keyboard.
TenkaBackHowtypeWhat a dressing is told about the back it is asked to draw.
TenkaCardHowtypeWhat a dressing is told about a card it is asked to draw.
TenkaDieHowtypeWhat a dressing is told about a die it is asked to draw.
TenkaDrawntypeSomething a dressing drew: the element to put on the table, and what to do when the table takes it away again (stop a timer, say).
TenkaDressingtypeHOW A TABLE DRAWS ITS DICE AND ITS CARDS, if not the plain way: each is a function that is given what the rules decided and hands back the element to show.
TenkaLandtypeOne territory as a drawing needs it.
TenkaLocaletypeThe languages the package speaks: English and Japanese.
tenkaMapModelfunctionEVERYTHING A DRAWING OF THE WORLD NEEDS, for one game: each territory's outline in its owner's colour, its counter's place and armies, and its ring.
TenkaMapModeltypeThe whole world as a drawing needs it, in map units: tenkaMapModel makes one, tenkaMapSvg and TenkaMap draw it.
tenkaMapSvgfunctionTHE WORLD AS AN SVG ELEMENT, drawn from a model (tenkaMapModel): the sea, each territory in its owner's colour, the continents' borders and the sea links, the rings of a choice, and a counter of armies on each.
TenkaRingtypeHow a territory is ringed: the one chosen, one it can reach, or the target.
tenkaSayfunctionA line from a table of strings with its braces filled in: tenkaSay(strings.moveIn, { n: 3 }) is "Move 3 in".
tenkaShapesOffunctionHow a game's map is drawn: the world unless the game says otherwise.
tenkaStringsfunctionThe table of strings for a locale with a page's own words laid over it.
TenkaStringstypeEvery table word, including local embed error feedback.
TenkaTableHandletypeNative game access, restoration, redealing and presentation updates.
TenkaTableOptionstypeNative table settings; defaults to three players, with two computers.
TenkaViewtypeA part of the map to show, in map units: left, top, width, height (an SVG viewBox).
territoryNameInfunctionA territory's name in a table of strings, by its key (TENKA_TERRITORIES[n].key, such as "alaska"); "" for a key that is no territory's.

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