afterTurnfunction
Whose move it is after from played or passed: the next seat still in that
has not passed, or — when nobody is left to answer — the trick cleared and
led by whoever played last, or the next seat after them still in.
Import it
import { afterTurn } from "@johnmorrisdotca/toranpu/big-two";
Also exported from: @johnmorrisdotca/toranpu/president
Definition
function afterTurn<T extends ClimbTrick>(trick: T, from: number): T
Parameters
| Name | Type | Description |
|---|---|---|
trick | T | The cards and seats in the current trick. |
from | number | The source position or source state specified by this API. |
Returns
T
Whose move it is after from played or passed: the next seat still in that has not passed, or — when nobody is left to answer — the trick cleared and led by whoever played last, or the next seat after them still in.
Examples
import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu";
import { afterTurn } from "@johnmorrisdotca/toranpu/big-two";
const names = Array.from({ length: CARD_GAME_TABLES.bigTwo.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`);
let game = newGame("bigTwo", { players: names, seed: 42 })!;
console.log(afterTurn(game, game.toPlay!));{
size: 3,
players: [ 'Seat 1', 'Seat 2', 'Seat 3', 'Seat 4' ],
computers: [ false, false, false, false ],
seed: 42,
moves: [],
deal: 0,
phase: 'playing',
penalties: [ 0, 0, 0, 0 ],
deals: [],
hands: [
[
'3C', '5H', '7C',
'8H', 'JS', 'QD',
'QC', 'QS', 'KC',
'KH', 'AS', '2C',
'2S'
],
[
'3H', '3S', '5S',
'6C', '6H', '8C',
'9S', 'TH', 'JC',
'JH', 'KD', 'AD',
'AC'
],
[
'3D', '4D', '4C',
'4H', '4S', '6D',
'7D', '7S', '8D',
'QH', 'KS', '2D',
'2H'
],
[
'5D', '5C', '6S',
'7H', '8S', '9D',
'9C', '9H', 'TD',
'TC', 'TS', 'JD',
'AH'
]
],
pile: null,
passed: [ false, false, false, false ],
toPlay: 2,
played: [],
opening: '3D'
}What it prints (run when this page was built)