twenty-one/shared/game/actions.ts

54 lines
No EOL
772 B
TypeScript

import type { SpecialCardId } from "./cards"
type PlayerAction = {
initiatingPlayerId: string
} & (
| {
type: "join"
name: string
}
| {
type: "hit"
}
| {
type: "stay"
}
| {
type: "use-special"
cardId: SpecialCardId
}
| {
type: "leave"
}
)
type ServerAction = {
initiatingPlayerId?: never
} & (
| {
type: "start"
targetSum: number
startingPlayerId: string
}
| {
type: "deal-number"
toPlayerId: string
number: number
isCovert: boolean
}
| {
type: "deal-special"
toPlayerId: string
cardId?: SpecialCardId // undefined if redacted
}
| {
type: "end"
winnerIds: string[]
cardsByPlayerId: Record<string, number[]> // without redactions
}
)
export type GameAction = {
index: number
} & (PlayerAction | ServerAction)