Skip to the content

Hitotsu一つ

Match the colour or number, call with one card left, and play classic or party rules against computers or at a shared table.

Hitotsu is Japanese for one: the call with one card left. About the name

Contents

Reference

Game engine and table

import { … } from "@johnmorrisdotca/hitotsu";

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

Hitotsu 一つ: a colour-card shedding game for two to eight, with the house rules people actually play.

The core is plain functions over plain data, with no dependency and no DOM: deal, list the legal moves, play one, score the hand, let a computer choose, and keep a game as a line of text. Every function returns a new game and leaves the one it was given alone. The card design is ./card.ts, the table for several devices ./table.ts, and a table to play in any page is mountHitotsu in ./ui/mount.ts, exported here too.

Exports

NameKindWhat it is
callMattersfunctionWhether the call is a choice now: this seat is about to play its second-last card.
cardOfMovefunctionThe card a card move puts down.
colourOffunctionA card's colour, or null for a wild.
colourWordsfunctionA colour’s name in English or Japanese.
decodeHitotsufunctionRead a saved setup and replay every logged move through the native rules; null for an unreadable, unsupported or illegal saved game.
DRAW_TWOconstantThe face code for a Draw Two card.
encodeHitotsufunctionSave the setup, seed and ordered move log as JSON text; hands and piles are reconstructed when decoded.
faceOffunctionA card's face: a digit, or S, R, D, W, F.
freshSeedfunctionA fresh seed for a new deal.
handOffunctionA seat's hand; an empty one for a seat the table does not have.
HITOTSU_CARD_BOXconstantThe card's width and height in the design's units.
HITOTSU_CAUGHTconstantCards taken for going down to one without calling it, and for a Wild Draw Four challenged and found honest.
HITOTSU_CHALLENGE_LOSTconstantCards drawn when a Wild Draw Four challenge fails: six.
HITOTSU_CLASSICconstantThe published rules: no stacking, no jumping in, sevens and zeros as plain numbers, one card drawn, a Wild Draw Four that may be challenged, seven cards dealt.
HITOTSU_COLOUR_LOOKconstantEach colour's fill, the ink written on it, its element and its name; W is the wilds' and the back's.
HITOTSU_COLOURSconstantThe four colours in the order a hand sorts them and a picker offers them.
HITOTSU_DECKconstantEvery card, in the deck's own order.
HITOTSU_DECK_SIZEconstantThe cards in the deck: 25 in each colour and eight wilds.
HITOTSU_DEFAULT_SIZEconstantThe default match target, 500 points.
HITOTSU_FACE_MARKconstantWhat each face shows in the middle of a card and in its corners; a number shows itself.
HITOTSU_MOST_PLAYERSconstantThe most at a table: eight, which one deck of 108 deals seven each and leaves a stock to draw from.
HITOTSU_ONE_HANDconstantHOW LONG A GAME OF HITOTSU LASTS, its "size": to 200 or 500 points, or a single hand (1), the party table's game.
HITOTSU_PAPERconstantThe card's paper, round every card and under the diamond.
HITOTSU_PARTYconstantPARTY MODE: the house rules a big table plays by, and a short game — five cards each, one hand, draw cards stacking on any draw card, jumping in, and sevens and zeros moving hands round.
HITOTSU_POINTSconstantWhat a card left in a hand is worth to the player who went out: its number, twenty an action card, fifty a wild.
HITOTSU_SIZESconstantSupported match lengths: one hand, 200 points or 500 points.
HITOTSU_STRINGSconstantNative interface, settings and words for host code.
HITOTSU_STRINGS_JAconstantThe table's words in Japanese.
HitotsuCardtypeA card by its short name: its colour letter (W for a wild), its face — a digit, S skip, R reverse, D draw two, W wild, F wild draw four — and which copy of that card it is, so the two red fives are R50 and R51.
HitotsuCardMovetypeA move that puts a card down: in turn, or jumping in.
hitotsuCardShapesfunctionThe shapes of one card, in drawing order: a face, or the back for null.
hitotsuCardSvgfunctionA whole card as an SVG document, width pixels wide (140/100 of it tall): a face, or the back for null.
HitotsuChallengetypeA Wild Draw Four the player to move may challenge: who played it, and whether they held a card of the colour it was played on.
HitotsuColourtypeA card's colour: red, yellow, green or blue.
hitotsuComputerfunctionChoose a move for the current player from the legal choices.
hitotsuComputerJumpfunctionA computer's card played out of turn, where the table jumps in: the first computer seat round from the player to move that holds a card identical to the top one.
HitotsuGametypeA GAME OF HITOTSU: its table and moves (what is kept), and the hand they have reached.
HitotsuHandletypeNative game access, redealing and presentation updates.
hitotsuJumpInsfunctionJUMPING IN: with the option on, any other player holding a card identical to the one on top — same colour, same face, never a wild — may play it out of turn, and play goes on from them.
HitotsuLanguagetypeThe languages the table speaks: English, and Japanese ("ja").
hitotsuLanguageOffunctionThe language a language tag such as "ja", "ja-JP" or "en-GB" asks for: Japanese for any ja, English for everything else, and for nothing.
hitotsuMatchesfunctionWhether a card may go on the pile on an ordinary turn: a wild always; otherwise the colour to follow, or the top card's face.
HitotsuMovetypeOne move: a card played, a draw, a turn passed, a pending draw taken, a Wild Draw Four challenged, or a card played out of turn.
hitotsuMovesfunctionEvery move the player to move may make now; none once the game is over.
HitotsuNewstypeSomething that happened in the last move, for the table to say: nothing a player could not have seen.
HitotsuOptionstypeHow the house plays: each popular variant, as a choice at the set-up.
hitotsuPlayablefunctionThe cards the player to move may play now: on a draw, what stacks; after drawing, the card drawn if it goes.
hitotsuPointsfunctionWhat a card left in hand is worth to the player who went out.
HitotsuResulttypeHow a hand ended: who won it and what they scored, or who held least when nobody could go on.
HitotsuShapetypeOne shape of the design.
hitotsuShapeSvgfunctionOne shape as SVG markup.
hitotsuStringsfunctionThe table's words in a language: HITOTSU_STRINGS for "en", HITOTSU_STRINGS_JA for "ja".
HitotsuStringstypeEvery table word, including embed errors; hosts may override them with strings.
HitotsuTableOptionstypeNative table settings, including private player names and callbacks.
HitotsuTableSetUptypeWhat a set-up sends beyond a length and the seats: the seed it was dealt from, and the house rules.
hitotsuTopfunctionThe top card of the discard pile.
hitotsuViewfunctionOne seat’s hand and legal choices, with public counts and the current colour, for a computer player.
HitotsuViewtypeA COMPUTER AT THE HITOTSU TABLE.
hitotsuWinnersfunctionOnce the game is over: whoever went out in a game of one hand; otherwise the highest score, level on it sharing the win.
hitotsuWordsfunction"red five", "blue draw two", "wild draw four", as a sentence and a screen reader say it; in Japanese, "赤の5", "青のドロー2", "ワイルドドローフォー".
identicalfunctionWhether two cards are the same card to play (the two red fives are).
isDrawCardfunctionWhether a card makes somebody draw: a Draw Two or a Wild Draw Four.
isHitotsuCardfunctionWhether an unknown value is an actual physical card id from the deck.
isNumberfunctionWhether a card is a number, 0 to 9.
isWildfunctionWhether a card is a Wild or Wild Draw Four.
longestColourfunctionThe colour this hand holds most of, red first among equals so the choice is always the same.
mixSeedfunctionTwo numbers mixed into one seed, so each hand of a game is shuffled from its own.
mountHitotsufunctionPut a table of Hitotsu into an element: the person at this screen in seat 0, computers in the rest.
movesForfunctionEverything this seat may do now: its own turn's moves, or, at another's turn, the cards it may jump in with.
namedTablefunctionThe game with its seats' names written in, a seat with no name keeping the one it had.
playableForfunctionThe cards this seat may play now, in turn or jumping in.
playHitotsufunctionApply a legal move and return a new game with that move recorded; null for an illegal move or a finished game.
quickMovefunctionWhat a card tapped twice plays: its one way, or null where there is a colour or a seat to choose.
RandomtypeA source of numbers in [0, 1): Math.random, or a seeded one so a deal can be made again.
readHitotsuMovefunctionA move as something sent it, checked for its shape only: whether it may be made is the rules'.
readHitotsuOptionsfunctionHouse rules as something sent them, checked for shape, or null.
readTableMovefunctionA move as a device sent it, checked for its shape, or null; a jump is never a move at a table on several devices.
readTableSetUpfunctionThe set-up as a device sent it, checked for its shape, jumping in taken off, or null.
reshuffledHitotsufunctionThese cards shuffled again, the same way for the same seed and salt: a pile turned over to make a new stock.
REVERSEconstantThe face code for a Reverse card.
SEED_MOSTconstantThe largest seed a deal takes: a whole number that travels in an address or a request as it is.
seededRandomfunctionA seeded generator (mulberry32): the same seed gives the same numbers, on every machine.
shuffledfunctionA shuffled copy (Fisher–Yates); the list given is left as it was.
shuffledHitotsufunctionThe deck shuffled for one hand of one game: the same seed and hand always the same order.
SKIPconstantHITOTSU'S DECK, as the rules see it: 108 short names.
sortHitotsufunctionA hand as a player holds it: by colour, numbers then actions, the wilds last.
startHitotsufunctionDeal a new seeded game for two to eight players at a supported match length; null for an unsupported length or player count.
startTablefunctionA new table: count seats with blank names (a table's names are its seats', written in when it is shown), the seats in computers played by the computer player.
tableComputerMovefunctionThe computer player's move for this seat, or null when the table is not waiting on it.
tableToPlayfunctionThe seat the table waits on, or null once the game is over.
VERSIONconstantThe version of this package, as package.json has it.
waysForfunctionThe ways this card may go down, the call made or not as the player said (where that is a choice).
WILDconstantThe face code for a Wild card.
WILD_FOURconstantThe face code for a Wild Draw Four card.

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/hitotsu 1.4.0.