PresidentGametype
A GAME OF PRESIDENT: its table and moves (what is kept), and the round they
have reached. size is how many rounds the game lasts: 3, 5 or 7.
Import it
import type { PresidentGame } from "@johnmorrisdotca/toranpu/president";
Definition
type PresidentGame = KeptCardGame<PresidentMove> & ClimbTrick & {
round: number;
phase: "exchange" | "playing" | "over";
out: number[];
titles: number[] | null;
owed: {
from: number;
to: number;
count: number;
}[];
swaps: PresidentSwap[];
scores: number[];
rounds: number[][];
};
Members
| Name | Type | Description |
|---|---|---|
size | number | |
players | readonly string[] | |
computers | readonly boolean[] | |
seed | number | |
moves | readonly PresidentMove[] | |
hands | string[][] | |
pile | ClimbPlay | null | The cards to beat, or null when the seat to play leads. |
passed | boolean[] | Who has passed on this trick: they wait until it is cleared. |
toPlay | number | null | Whose move it is; null once the game is over. |
played | string[] | Every card played this deal, in order: what the whole table has seen. |
round | number | Which round this is, from 0. |
phase | "playing" | "over" | "exchange" | Handing cards over before the round, playing it, or the game over. |
out | number[] | The order players went out this round, first to last so far. |
titles | number[] | null | The order they went out last round, which gives this round's titles; null in the first. |
owed | { from: number; to: number; count: number; }[] | The hands-back still owed this round, in order: who gives, to whom, how many. |
swaps | PresidentSwap[] | What has changed hands this round, both ways. |
scores | number[] | Each seat's points so far: the most wins. |
rounds | number[][] | Each finished round's finishing order, first out first. |
Examples
import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu";
import type { PresidentGame } from "@johnmorrisdotca/toranpu/president";
const names = Array.from({ length: CARD_GAME_TABLES.president.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`);
const game = newGame("president", { players: names, seed: 42 })!;
const value: PresidentGame = game;
console.log(value.phase);playingWhat it prints (run when this page was built)