shotgun/site/src/lib/game.ts
2024-02-03 11:53:19 -06:00

82 lines
1.7 KiB
TypeScript

/**
* Overall game state as received from the server.
*/
export interface Game {
/**
* Players in the game.
* The first element is the dealer and the second is the challenger.
*/
players: [Player, Player];
/**
* Previous action that occurred.
*/
action: "Start"
| "Shoot" | "GameEnd" | "BeerGameEnd" | "ChallengerWins" | "DealerWins"
| "Lens" | "Cig" | "Beer" | "Cuff" | "Knife"
| "DealerConcedes" | "ChallengerConcedes"
/**
* Round winner.
*/
winner?: 0 | 1 | null
/**
* Round number.
*/
round: number;
/**
* Whether it is the dealer's turn.
*/
dealer: boolean;
/**
* Damage that a live round will deal this turn.
*/
damage: number;
/**
* The current shell if it is revealed for the player receiving this state.
*/
shell?: boolean;
/**
* The previous discharged shell, if any.
*/
previous: boolean | null;
/**
* Number of live shells this game.
* Only included on the first turn of the game.
*/
live?: number;
/**
* Number of blank shells this game.
* Only included on the first tuurn of the game.
*/
blank?: number;
}
/**
* Displayed state of a player as received from the server.
*/
export interface Player {
hp: number;
items: string[];
cuffs?: boolean;
}
/**
* DTO for the game start.
*/
export interface GameStart {
/**
* Game ID for sharing.
*/
id: string;
/**
* Whether the player receiving this object is the dealer.
*/
dealer: boolean;
}
/**
* Commands sent to the server.
*/
export interface Action {
action: "quit" | "across" | "self" | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7";
}