feat(P5B.T2): GamePayload + games wrappers + winner-detect helpers + tests

Adds conversation_games table type + game_make_move RPC to db-types, GamePayload variant and parseMessagePayload branch to shared/attachments, games.ts with createGame/getGame/makeGameMove wrappers plus pure tttWinningLine/c4WinningCells/c4DropRow/isBoardFull helpers, 11 tests covering all winner helpers, and re-export from chat/index.ts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
byGalax
2026-05-16 21:47:36 +02:00
parent e1423dba32
commit 256a613134
5 changed files with 304 additions and 1 deletions
+39
View File
@@ -612,6 +612,41 @@ export type Database = {
};
Relationships: [];
};
conversation_games: {
Row: {
id: string;
conversation_id: string;
game_type: 'ttt' | 'c4';
state: { kind: 'ttt' | 'c4'; board: Array<number | null> };
players: [string, string];
current_turn_user_id: string | null;
winner_user_id: string | null;
created_at: string;
finished_at: string | null;
};
Insert: {
id?: string;
conversation_id: string;
game_type: 'ttt' | 'c4';
state: { kind: 'ttt' | 'c4'; board: Array<number | null> };
players: [string, string];
current_turn_user_id: string | null;
winner_user_id?: string | null;
created_at?: string;
finished_at?: string | null;
};
Update: {
id?: string;
conversation_id?: string;
game_type?: 'ttt' | 'c4';
state?: { kind: 'ttt' | 'c4'; board: Array<number | null> };
players?: [string, string];
current_turn_user_id?: string | null;
winner_user_id?: string | null;
finished_at?: string | null;
};
Relationships: [];
};
}
Views: {
[_ in never]: never
@@ -620,6 +655,10 @@ export type Database = {
accept_dm: { Args: { conversation_id: string }; Returns: undefined }
are_friends: { Args: { a: string; b: string }; Returns: boolean }
revoke_device: { Args: { p_device_id: string }; Returns: undefined }
game_make_move: {
Args: { p_game_id: string; p_move: object };
Returns: { kind: 'ttt' | 'c4'; board: Array<number | null> };
}
attachment_object_conv_id: {
Args: { object_name: string }
Returns: string