twenty-one/src/shared/game/gameActions.ts
2023-04-22 20:48:06 +02:00

50 lines
No EOL
721 B
TypeScript

import type { SpecialCardType } from "./cards"
type PlayerAction = {
initiatingPlayerId: string
} & (
| {
type: "hit"
}
| {
type: "stay"
}
| {
type: "use-special"
cardType: SpecialCardType
}
)
type ServerAction = {
initiatingPlayerId?: never
} & (
| {
type: "start"
targetSum: number
players: Array<{
id: string
name: string
}>
}
| {
type: "deal-number"
toPlayerId: string
number: number
isCovert: boolean
}
| {
type: "deal-special"
toPlayerId: string
cardType: SpecialCardType
}
| {
type: "end"
winnerIds: string[]
cardsByPlayerId: Record<string, number[]> // without redactions
}
)
export type GameAction = {
index: number
} & (PlayerAction | ServerAction)