GinView型
リファレンスの説明と例は英語です。見出しと目次は日本語です。
A COMPUTER AT THE GIN RUMMY TABLE: it takes the discard only when the card goes straight into a meld, throws the card that leaves the least deadwood (the highest of those that tie, and never one the other player has shown they are collecting when another will do), and knocks the moment it can.
It reads a view of the game (ginView): its own hand, the discard pile and
what the other player took from it — and nothing of their hand or the stock.
インポート
import type { GinView } from "@johnmorrisdotca/toranpu/gin-rummy";
定義
type GinView = {
hand: readonly CardId[];
phase: GinGame["phase"];
top: CardId | null;
taken: CardId | null;
theirPicks: readonly CardId[];
};
メンバー
| 名前 | 型 | 説明 |
|---|---|---|
hand | readonly string[] | |
phase | "over" | "discard" | "draw" | |
top | string | null | The card on top of the discard pile, if any. |
taken | string | null | The card just taken from the pile, which may not go straight back. |
theirPicks | readonly string[] | Every card the other player has taken from the discard pile this hand and still holds: the table watched them take it. |
例
import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu";
import type { GinView } from "@johnmorrisdotca/toranpu/gin-rummy";
import { ginView } from "@johnmorrisdotca/toranpu/gin-rummy";
const names = Array.from({ length: CARD_GAME_TABLES.ginRummy.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`);
const game = newGame("ginRummy", { players: names, seed: 42 })!;
const value: GinView = ginView(game);
console.log(value.hand.length);10出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。