本文へ移動

Toranpuトランプ

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

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

目次

リファレンス · ハーツ

HeartsGame型

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

A GAME OF HEARTS: its table and moves (what is kept, KeptCardGame), and everything the moves make, read again from them whenever the game is. size is the score that ends the game: 50 or 100.

インポート

import type { HeartsGame } from "@johnmorrisdotca/toranpu/hearts";

定義

type HeartsGame = KeptCardGame<HeartsMove> & {
    deal: number;
    phase: HeartsPhase;
    hands: CardId[][];
    passing: (CardId[] | null)[];
    received: CardId[][];
    trick: HeartsPlay[];
    lastTrick: {
        plays: HeartsPlay[];
        winner: number;
    } | null;
    played: CardId[];
    toPlay: number | null;
    heartsBroken: boolean;
    points: number[];
    scores: number[];
    dealScores: number[][];
    moon: number | null;
};

メンバー

名前型説明
sizenumber
playersreadonly string[]
computersreadonly boolean[]
seednumber
movesreadonly HeartsMove[]
dealnumber

Which deal this is, from 0: it decides the way the cards are passed.

phaseHeartsPhase
handsstring[][]
passing(string[] | null)[]

The three cards each seat has chosen to pass this deal, or null while it has not.

receivedstring[][]

The three cards each seat was passed this deal, shown to that seat once the passing is done.

trickHeartsPlay[]

The trick on the table, in the order it was played.

lastTrick{ plays: HeartsPlay[]; winner: number; } | null

The trick before, and who took it: what a player may still look back at.

playedstring[]

Every card played in a finished trick this deal: what everybody at the table has seen.

toPlaynumber | null

Whose move it is; null once the game is over.

heartsBrokenboolean
pointsnumber[]

Each seat's points taken this deal, so far.

scoresnumber[]

Each seat's total before this deal.

dealScoresnumber[][]

Each finished deal's points, one row a deal.

moonnumber | null

The seat that took every point of the last finished deal, if one did.

例

import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu";
import type { HeartsGame } from "@johnmorrisdotca/toranpu/hearts";

const names = Array.from({ length: CARD_GAME_TABLES.hearts.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`);
const game = newGame("hearts", { players: names, seed: 42 })!;
const value: HeartsGame = game;
console.log(value.phase);
passing

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

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

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