TrainGame型
リファレンスの説明と例は英語です。見出しと目次は日本語です。
A game, as its table and moves make it. Only the set, the options, the
seed, the seats and the moves are ever kept (encodeTrain); everything
else is read again from them (replayTrain), so a kept game can never hold
a hand or a train its moves do not make, and a reload cannot deal again.
インポート
import type { TrainGame } from "@johnmorrisdotca/domino";
定義
type TrainGame = {
set: number;
options: TrainOptions;
seed: number;
players: readonly string[];
computers: readonly boolean[];
history: TrainHistory | null;
rounds: number;
round: number;
engine: number;
hands: readonly (readonly Domino[])[];
trains: readonly Train[];
boneyard: readonly Domino[];
toPlay: TrainSeat;
uncovered: readonly number[];
chaining: boolean;
drew: boolean;
passes: number;
turn: number;
phase: TrainPhase;
results: readonly RoundResult[];
winners: readonly TrainSeat[];
last: {
seat: TrainSeat;
move: TrainMove;
} | null;
};
メンバー
| 名前 | 型 | 説明 |
|---|---|---|
set | number | The set, by its highest double: 9, 12 or 15. The party game's "board size". |
options | TrainOptions | |
seed | number | What every shuffle of this game is drawn from. |
players | readonly string[] | The names given at the table, in seat order: "" for one left blank. |
computers | readonly boolean[] | Which seats a computer plays. |
history | TrainHistory | null | Every move made, the last first, each pointing at the record before it:
the game's whole record ( |
rounds | number | How many rounds this game plays, and which one is being played (0 for the first). |
round | number | |
engine | number | The engine double's number this round: the set's highest in the first, one fewer each round after. |
hands | readonly (readonly number[])[] | |
trains | readonly Train[] | Every seat's train, then the Mexican Train last. |
boneyard | readonly number[] | The tiles still face down, in the order they will be drawn. |
toPlay | number | |
uncovered | readonly number[] | Trains whose last tile is a double not yet covered, the last laid last: while any is open, the only play anywhere is to cover the last of them. |
chaining | boolean | The player to move laid a double this turn and may still lay another before covering ( |
drew | boolean | The player to move has drawn this turn: the tile drawn must be played if it can, or they pass. |
passes | number | Turns passed in a row with nothing played: a whole table of them with the boneyard empty ends the round. |
turn | number | Counts every change of the player to move: a new number is a new turn, and a covered hand to pass on. |
phase | TrainPhase | |
results | readonly RoundResult[] | |
winners | readonly number[] | On a finished game, every seat with the lowest total. |
last | { seat: TrainSeat; move: TrainMove; } | null | The last move played, for the line that says what just happened. |
例
import { startTrain } from "@johnmorrisdotca/domino";
import type { TrainGame } from "@johnmorrisdotca/domino";
const game = startTrain(9,["A","B"],42,{length:"short",doubles:"one",mexican:"any"},[false,true])!;
const value: TrainGame = game;
console.log(value);{
set: 9,
options: { length: 'short', doubles: 'one', mexican: 'any' },
seed: 42,
players: [ 'A', 'B' ],
computers: [ false, true ],
history: null,
rounds: 5,
round: 0,
engine: 9,
hands: [
[
21, 41, 86, 72, 73,
3, 88, 70, 137, 56
],
[
0, 103, 2, 22, 1,
40, 52, 105, 9, 24
]
],
trains: [
{ laid: [], open: false },
{ laid: [], open: false },
{ laid: [], open: true }
],
boneyard: [
69, 87, 35, 68, 54, 18, 119, 25, 38,
57, 20, 23, 136, 89, 7, 17, 53, 55,
4, 51, 102, 71, 85, 36, 121, 8, 104,
37, 34, 120, 39, 5, 6, 19
],
toPlay: 0,
uncovered: [],
chaining: false,
drew: false,
passes: 0,
turn: 0,
phase: 'playing',
results: [],
winners: [],
last: null
}出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。