本文へ移動

Toranpuトランプ

デッキを使い、11種類のゲームでコンピューターと対戦し、ソリティアを解いたり、独自の絵柄でカードを表示したりできます。

「トランプ」は、日本語で playing cards を指す言葉です。 名前について(英語)

目次

リファレンス · ゲームと状態

fromJSON関数

リファレンスの説明と例は英語です。見出しと目次は日本語です。

A game from text that toJSON or toCode wrote, whichever game it is. Nothing in it is trusted: every move is played through the rules again, and a move the rules refuse means the text is not a game. Null for text that is not JSON, names no game, is of a later format than this version reads, or cannot be played out.

インポート

import { fromJSON } from "@johnmorrisdotca/toranpu";

定義

function fromJSON(text: string): ReadGame | null

引数

名前型説明
textstring

The notation, encoded state or saved text to read.

戻り値

ReadGame | null

A game from text that toJSON or toCode wrote, whichever game it is. Nothing in it is trusted: every move is played through the rules again, and a move the rules refuse means the text is not a game. null for text that is not JSON, names no game, is of a later format than this version reads, or cannot be played out.

例

import { fromJSON, newGame, toJSON } from "@johnmorrisdotca/toranpu";

const game = newGame("hearts", { players: ["Aki", "Ben", "Cy", "Dev"], seed: 42 })!;
console.log(fromJSON(toJSON("hearts", game))?.kind);
hearts

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/toranpu 2.15.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。