Reference
Shared Awase table
import { … } from "@johnmorrisdotca/jarajara/table";
4.7 kB minified and gzipped, with everything it imports (measured with esbuild)
Awase at a table, for two to four: one layout, turns taken, each pair scoring (the plain suits one, ones and nines two, a wind three, a dragon four, a flower or season two and another turn), most points wins. With a computer player for any seat.
Exports
| Name | Kind | What it is |
|---|---|---|
AWASE_TABLE | constant | THE RULES AT THE TABLE. |
AwaseSeat | type | Who sits in a seat: a name typed on the device, or a computer. |
AwaseTable | type | A GAME AT THE TABLE, as it is kept: the deal, who sits where, and every pair taken, in order. |
AwaseTableState | type | Where a game at the table stands, read from its pairs. |
AwaseTake | type | One pair taken, as the table remembers it. |
computerPair | function | The pair a computer in the seat to move takes, or null when there is nothing to take. |
decodeTable | function | A kept table read back, its shape checked and every pair played again; null for anything that is not one. |
encodeTable | function | As kept in the browser: the table as JSON, its takes as slot pairs. |
isComputerSeat | function | Whether a computer plays this seat. |
playAtTable | function | The player to move takes this pair: the table and where it now stands, or null where the rules do not allow it. |
readTable | function | WHERE THE GAME STANDS, played again from its pairs: null for a deal that is not one, or a pair the rules would not have allowed. |
SEAT_WINDS | constant | The four seats' winds, east first, as a mahjong table seats its players. |
seatName | function | What a seat is called: its name, "Computer 2", or its wind. |
startTable | function | A new game at the table: the deal made from the seed, these seats, and nothing taken. |
tablePairs | function | The pairs the player to move may take: none once the game is over. |
tablePlayersAsked | function | A players count from an address, or 1 (the solitaire) for anything that is not two to four. |
takeAtTable | function | The table after the player to move takes this pair, or null where the rules do not allow it. |
tidySeatName | function | A name as kept: trimmed, one line, and no longer than a line holds. |
undoAtTable | function | The table with its last pair given back: the undo a table agrees to. |