toCSVfunction
A game's moves as CSV for a spreadsheet: a header, then a row a move, with
its number from 1, the seat from 1 and its player, the kind of move
(play, bid, pass…), the cards it names as two-letter ids with spaces
between, the move itself as JSON, and the move in English. Lines end CRLF,
as RFC 4180 has it. It is for reading, and is not read back.
Import it
import { toCSV } from "@johnmorrisdotca/toranpu";
Definition
function toCSV<K extends CardGameKind>(kind: K, game: GameOf<K>): string
Parameters
| Name | Type | Description |
|---|---|---|
kind | K | The named card game or sound kind. |
game | GameOf<K> | The current native game; applying a move returns a new state. |
Returns
string
A game's moves as CSV for a spreadsheet: a header, then a row a move, with its number from 1, the seat from 1 and its player, the kind of move (play, bid, pass…), the cards it names as two-letter ids with spaces between, the move itself as JSON, and the move in English. Lines end CRLF, as RFC 4180 has it. It is for reading, and is not read back.
Examples
import { newGame, toCSV } from "@johnmorrisdotca/toranpu";
const game = newGame("hearts", { players: ["Aki", "Ben", "Cy", "Dev"], seed: 42 })!;
console.log(toCSV("hearts", game));move,seat,player,action,cards,detail,textWhat it prints (run when this page was built)