export interface CardInstance { key: CardKey // other relevant modifiers to show user } export type AsyncHandle = | { status: 'not-connected' } | { status: 'connecting' } | { status: 'connected'; handle: T} export type CardKey = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 export interface Card { type: number basePower: number power: number id: CardKey counters: number owner: number position: number effects: {id: number}[] sick: boolean spell: boolean } export type FighterSlot = Card | undefined export type FighterArea = [FighterSlot, FighterSlot, FighterSlot, FighterSlot] export interface Board { sentinal: FighterArea scourge: FighterArea } export interface Player { name: string id: number hand: Card[] life: number ready: boolean } interface TeamEnumMap { 1: 'sentinal' 2: 'scourge' } interface GameStatusMap { 0: 'lobby' 1: 'ready' 2: 'playing' 3: 'stop' 4: 'sentinal-win' 5: 'scourage-win' 6: 'draw' } export interface GameState { board: Board player: Player deck: Card[] team: 1 | 2 enemyLife: number enemyDeckSize: number enemyHandSize: number currentTurn: number canDraw: boolean hasDrawn: boolean gameStatus: keyof GameStatusMap } export type GameAction = | { type: 'set-player'; team: 1 | 2} | { type: 'update-state'; state: Omit} export interface GameCommandAPI { readyPlayer: () => void startTurn: () => void endTurn: () => void getView: () => void startDraw: () => void commitDraw: (cardIndex: number) => void playCard: (handIndex: number, positionIndex: number) => void moveCard: (positionFrom: number, positionTo: number) => void attackCard: (positionFrom: number, positionTo: number) => void } export type GameHandle = GameState & GameCommandAPI // TODO export type GameCommandEnum = 'a' | 's' export interface CommandVariantMap { // "state" commands s: 'b' | 's' | 'e' | 'g' // "action" commands a: 's' | 'd' | 'p' | 'm' | 'a' } export interface CommandVariantParamMap { s: Record a: { s: never d: number p: [number, number] m: [number, number] a: [number, number] } } export interface GameCommand { playerId: string type: GameCommandEnum, cmd: string // " ..." } type SelectionTarget = 'ally' | 'opponent' type SelectionType = 'hand' | 'board' export interface Selection { target: SelectionTarget type: SelectionType index: number }