ReadGametype
A game read back: which game it is, and the game itself.
Import it
import type { ReadGame } from "@johnmorrisdotca/toranpu";
Definition
type ReadGame = {
[K in CardGameKind]: {
kind: K;
game: GameOf<K>;
};
}[CardGameKind];
Examples
import { fromJSON, newGame, toJSON } from "@johnmorrisdotca/toranpu";
import type { ReadGame } from "@johnmorrisdotca/toranpu";
const game = newGame("hearts", { players: ["Aki", "Ben", "Cy", "Dev"], seed: 42 })!;
const value: ReadGame = fromJSON(toJSON("hearts", game))!;
console.log(value.kind);heartsWhat it prints (run when this page was built)