リファレンス
ゲームとテーブル
import { … } from "@johnmorrisdotca/hitotsu";
最小化と gzip 圧縮をしたサイズは 42.2 kB(読み込むものをすべて含み、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.
エクスポート
| 名前 | 種類 | 概要 |
|---|---|---|
callMatters | 関数 | Whether the call is a choice now: this seat is about to play its second-last card. |
cardOfMove | 関数 | The card a card move puts down. |
colourOf | 関数 | A card's colour, or null for a wild. |
colourWords | 関数 | A colour’s name in English or Japanese. |
decodeHitotsu | 関数 | Read a saved setup and replay every logged move through the native rules; null for an unreadable, unsupported or illegal saved game. |
DRAW_TWO | 定数 | The face code for a Draw Two card. |
encodeHitotsu | 関数 | Save the setup, seed and ordered move log as JSON text; hands and piles are reconstructed when decoded. |
faceOf | 関数 | A card's face: a digit, or S, R, D, W, F. |
freshSeed | 関数 | A fresh seed for a new deal. |
handOf | 関数 | A seat's hand; an empty one for a seat the table does not have. |
HITOTSU_CARD_BOX | 定数 | The card's width and height in the design's units. |
HITOTSU_CAUGHT | 定数 | Cards taken for going down to one without calling it, and for a Wild Draw Four challenged and found honest. |
HITOTSU_CHALLENGE_LOST | 定数 | Cards drawn when a Wild Draw Four challenge fails: six. |
HITOTSU_CLASSIC | 定数 | The 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_LOOK | 定数 | Each colour's fill, the ink written on it, its element and its name; W is the wilds' and the back's. |
HITOTSU_COLOURS | 定数 | The four colours in the order a hand sorts them and a picker offers them. |
HITOTSU_DECK | 定数 | Every card, in the deck's own order. |
HITOTSU_DECK_SIZE | 定数 | The cards in the deck: 25 in each colour and eight wilds. |
HITOTSU_DEFAULT_SIZE | 定数 | The default match target, 500 points. |
HITOTSU_FACE_MARK | 定数 | What each face shows in the middle of a card and in its corners; a number shows itself. |
HITOTSU_MOST_PLAYERS | 定数 | The most at a table: eight, which one deck of 108 deals seven each and leaves a stock to draw from. |
HITOTSU_ONE_HAND | 定数 | HOW LONG A GAME OF HITOTSU LASTS, its "size": to 200 or 500 points, or a single hand (1), the party table's game. |
HITOTSU_PAPER | 定数 | The card's paper, round every card and under the diamond. |
HITOTSU_PARTY | 定数 | PARTY 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_POINTS | 定数 | What a card left in a hand is worth to the player who went out: its number, twenty an action card, fifty a wild. |
HITOTSU_SIZES | 定数 | Supported match lengths: one hand, 200 points or 500 points. |
HITOTSU_STRINGS | 定数 | Native interface, settings and words for host code. |
HITOTSU_STRINGS_JA | 定数 | The table's words in Japanese. |
HitotsuCard | 型 | A 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. |
HitotsuCardMove | 型 | A move that puts a card down: in turn, or jumping in. |
hitotsuCardShapes | 関数 | The shapes of one card, in drawing order: a face, or the back for null. |
hitotsuCardSvg | 関数 | A whole card as an SVG document, width pixels wide (140/100 of it tall): a face, or the back for null. |
HitotsuChallenge | 型 | A 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. |
HitotsuColour | 型 | A card's colour: red, yellow, green or blue. |
hitotsuComputer | 関数 | Choose a move for the current player from the legal choices. |
hitotsuComputerJump | 関数 | A 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. |
HitotsuGame | 型 | A GAME OF HITOTSU: its table and moves (what is kept), and the hand they have reached. |
HitotsuHandle | 型 | Native game access, redealing and presentation updates. |
hitotsuJumpIns | 関数 | JUMPING 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. |
HitotsuLanguage | 型 | The languages the table speaks: English, and Japanese ("ja"). |
hitotsuLanguageOf | 関数 | The 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. |
hitotsuMatches | 関数 | Whether 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. |
HitotsuMove | 型 | One 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. |
hitotsuMoves | 関数 | Every move the player to move may make now; none once the game is over. |
HitotsuNews | 型 | Something that happened in the last move, for the table to say: nothing a player could not have seen. |
HitotsuOptions | 型 | How the house plays: each popular variant, as a choice at the set-up. |
hitotsuPlayable | 関数 | The cards the player to move may play now: on a draw, what stacks; after drawing, the card drawn if it goes. |
hitotsuPoints | 関数 | What a card left in hand is worth to the player who went out. |
HitotsuResult | 型 | How a hand ended: who won it and what they scored, or who held least when nobody could go on. |
HitotsuShape | 型 | One shape of the design. |
hitotsuShapeSvg | 関数 | One shape as SVG markup. |
hitotsuStrings | 関数 | The table's words in a language: HITOTSU_STRINGS for "en", HITOTSU_STRINGS_JA for "ja". |
HitotsuStrings | 型 | Every table word, including embed errors; hosts may override them with strings. |
HitotsuTableOptions | 型 | Native table settings, including private player names and callbacks. |
HitotsuTableSetUp | 型 | What a set-up sends beyond a length and the seats: the seed it was dealt from, and the house rules. |
hitotsuTop | 関数 | The top card of the discard pile. |
hitotsuView | 関数 | One seat’s hand and legal choices, with public counts and the current colour, for a computer player. |
HitotsuView | 型 | A COMPUTER AT THE HITOTSU TABLE. |
hitotsuWinners | 関数 | Once the game is over: whoever went out in a game of one hand; otherwise the highest score, level on it sharing the win. |
hitotsuWords | 関数 | "red five", "blue draw two", "wild draw four", as a sentence and a screen reader say it; in Japanese, "赤の5", "青のドロー2", "ワイルドドローフォー". |
identical | 関数 | Whether two cards are the same card to play (the two red fives are). |
isDrawCard | 関数 | Whether a card makes somebody draw: a Draw Two or a Wild Draw Four. |
isHitotsuCard | 関数 | Whether an unknown value is an actual physical card id from the deck. |
isNumber | 関数 | Whether a card is a number, 0 to 9. |
isWild | 関数 | Whether a card is a Wild or Wild Draw Four. |
longestColour | 関数 | The colour this hand holds most of, red first among equals so the choice is always the same. |
mixSeed | 関数 | Two numbers mixed into one seed, so each hand of a game is shuffled from its own. |
mountHitotsu | 関数 | Put a table of Hitotsu into an element: the person at this screen in seat 0, computers in the rest. |
movesFor | 関数 | Everything this seat may do now: its own turn's moves, or, at another's turn, the cards it may jump in with. |
namedTable | 関数 | The game with its seats' names written in, a seat with no name keeping the one it had. |
playableFor | 関数 | The cards this seat may play now, in turn or jumping in. |
playHitotsu | 関数 | Apply a legal move and return a new game with that move recorded; null for an illegal move or a finished game. |
quickMove | 関数 | What a card tapped twice plays: its one way, or null where there is a colour or a seat to choose. |
Random | 型 | A source of numbers in [0, 1): Math.random, or a seeded one so a deal can be made again. |
readHitotsuMove | 関数 | A move as something sent it, checked for its shape only: whether it may be made is the rules'. |
readHitotsuOptions | 関数 | House rules as something sent them, checked for shape, or null. |
readTableMove | 関数 | A move as a device sent it, checked for its shape, or null; a jump is never a move at a table on several devices. |
readTableSetUp | 関数 | The set-up as a device sent it, checked for its shape, jumping in taken off, or null. |
reshuffledHitotsu | 関数 | These cards shuffled again, the same way for the same seed and salt: a pile turned over to make a new stock. |
REVERSE | 定数 | The face code for a Reverse card. |
SEED_MOST | 定数 | The largest seed a deal takes: a whole number that travels in an address or a request as it is. |
seededRandom | 関数 | A seeded generator (mulberry32): the same seed gives the same numbers, on every machine. |
shuffled | 関数 | A shuffled copy (Fisher–Yates); the list given is left as it was. |
shuffledHitotsu | 関数 | The deck shuffled for one hand of one game: the same seed and hand always the same order. |
SKIP | 定数 | HITOTSU'S DECK, as the rules see it: 108 short names. |
sortHitotsu | 関数 | A hand as a player holds it: by colour, numbers then actions, the wilds last. |
startHitotsu | 関数 | Deal a new seeded game for two to eight players at a supported match length; null for an unsupported length or player count. |
startTable | 関数 | A 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. |
tableComputerMove | 関数 | The computer player's move for this seat, or null when the table is not waiting on it. |
tableToPlay | 関数 | The seat the table waits on, or null once the game is over. |
VERSION | 定数 | The version of this package, as package.json has it. |
waysFor | 関数 | The ways this card may go down, the call made or not as the player said (where that is a choice). |
WILD | 定数 | The face code for a Wild card. |
WILD_FOUR | 定数 | The face code for a Wild Draw Four card. |
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。