本文へ移動

Toranpuトランプ

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

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

目次

リファレンス · スペード

SpadesGame型

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

A GAME OF SPADES: its table and moves (what is kept, KeptCardGame), and everything the moves make, read again from them whenever the game is. Four seats in two partnerships, sitting across from each other: seats 0 and 2 against 1 and 3. size is the score that ends the game: 200, 300 or 500.

インポート

import type { SpadesGame } from "@johnmorrisdotca/toranpu/spades";

定義

type SpadesGame = KeptCardGame<SpadesMove> & {
    deal: number;
    phase: SpadesPhase;
    hands: CardId[][];
    bids: (number | null)[];
    trick: SpadesPlay[];
    lastTrick: {
        plays: SpadesPlay[];
        winner: number;
    } | null;
    played: CardId[];
    toPlay: number | null;
    spadesBroken: boolean;
    tricks: number[];
    scores: [
        number,
        number
    ];
    bags: [
        number,
        number
    ];
    dealScores: SpadesDealScore[];
};

メンバー

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

Which deal this is, from 0: the deal moves one seat round each time.

phaseSpadesPhase
handsstring[][]
bids(number | null)[]

Each seat's bid this deal, 0 for nil, or null while it has not bid.

trickSpadesPlay[]

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

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

The trick before, and who took it.

playedstring[]

Every card played in a finished trick this deal.

toPlaynumber | null

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

spadesBrokenboolean

Whether a spade has been played on another suit (or led from a hand of nothing else) this deal.

tricksnumber[]

The tricks each seat has taken this deal.

scores[number, number]

Each partnership's score, before this deal: seats 0 and 2, then 1 and 3.

bags[number, number]

Each partnership's overtricks carried towards the next ten.

dealScoresSpadesDealScore[]

Each finished deal, one row a deal.

例

import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu";
import type { SpadesGame } from "@johnmorrisdotca/toranpu/spades";

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

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

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

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