Add chess premoves and time control metadata
- pass chess room time control to the client - add premove handling and richer chess board UI - update join result typing for room options
This commit is contained in:
@@ -244,7 +244,12 @@ export class GameServer {
|
|||||||
this.replacedConnections.delete(discordId);
|
this.replacedConnections.delete(discordId);
|
||||||
|
|
||||||
// Build room options for the client
|
// Build room options for the client
|
||||||
const roomOptions = room?.betAmount ? { betAmount: room.betAmount } : undefined;
|
const roomOptions = room
|
||||||
|
? {
|
||||||
|
...(room.betAmount > 0 ? { betAmount: room.betAmount } : {}),
|
||||||
|
...(typeof room.options?.timeControl === "string" ? { timeControl: room.options.timeControl } : {}),
|
||||||
|
}
|
||||||
|
: undefined;
|
||||||
|
|
||||||
// Respond with JOIN_RESULT
|
// Respond with JOIN_RESULT
|
||||||
ws.send(JSON.stringify({
|
ws.send(JSON.stringify({
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export type GameWsServerMessage =
|
|||||||
| { type: "GAME_STARTED"; roomId: string; state: unknown }
|
| { type: "GAME_STARTED"; roomId: string; state: unknown }
|
||||||
| { type: "GAME_ENDED"; roomId: string; winner: string | null; reason: string; payout?: { amount: number; refunded?: boolean } }
|
| { type: "GAME_ENDED"; roomId: string; winner: string | null; reason: string; payout?: { amount: number; refunded?: boolean } }
|
||||||
| { type: "ROOM_CREATED"; roomId: string; gameSlug: string }
|
| { type: "ROOM_CREATED"; roomId: string; gameSlug: string }
|
||||||
| { type: "JOIN_RESULT"; roomId: string; joinedAs: "player" | "spectator"; roomStatus: "waiting" | "playing" | "finished"; players: PlayerInfo[]; spectators: PlayerInfo[]; state?: unknown; roomOptions?: { betAmount?: number } }
|
| { type: "JOIN_RESULT"; roomId: string; joinedAs: "player" | "spectator"; roomStatus: "waiting" | "playing" | "finished"; players: PlayerInfo[]; spectators: PlayerInfo[]; state?: unknown; roomOptions?: { betAmount?: number; timeControl?: string } }
|
||||||
| { type: "ROUND_SETTLED"; roomId: string; payouts: Record<string, { net: number }> }
|
| { type: "ROUND_SETTLED"; roomId: string; payouts: Record<string, { net: number }> }
|
||||||
| { type: "SESSION_REPLACED"; roomId: string }
|
| { type: "SESSION_REPLACED"; roomId: string }
|
||||||
| { type: "ERROR"; message: string };
|
| { type: "ERROR"; message: string };
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@ export interface GameUIProps {
|
|||||||
onAction: (action: unknown) => void;
|
onAction: (action: unknown) => void;
|
||||||
players: { discordId: string; username: string }[];
|
players: { discordId: string; username: string }[];
|
||||||
roundResult?: { payouts: Record<string, { net: number }> } | null;
|
roundResult?: { payouts: Record<string, { net: number }> } | null;
|
||||||
roomOptions?: { betAmount?: number };
|
roomOptions?: { betAmount?: number; timeControl?: string };
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GameUIPlugin {
|
export interface GameUIPlugin {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ interface GameRoomState {
|
|||||||
roundResult: RoundResult | null;
|
roundResult: RoundResult | null;
|
||||||
error: string | null;
|
error: string | null;
|
||||||
sessionReplaced: boolean;
|
sessionReplaced: boolean;
|
||||||
roomOptions: { betAmount?: number };
|
roomOptions: { betAmount?: number; timeControl?: string };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useGameRoom(roomId: string, userId: string, role?: string, preferAs: "player" | "spectator" = "player") {
|
export function useGameRoom(roomId: string, userId: string, role?: string, preferAs: "player" | "spectator" = "player") {
|
||||||
|
|||||||
Reference in New Issue
Block a user