-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchess.ts
More file actions
36 lines (33 loc) · 1005 Bytes
/
chess.ts
File metadata and controls
36 lines (33 loc) · 1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { client } from "@/client";
import { handleResponse } from "@/lib/api-client";
import type { UsersResponse, Piece, AIResponse, initGame, initGameResponse } from "@repo/schema";
export async function fetch(): Promise<UsersResponse> {
const response = await client.users.$get({});
return handleResponse<UsersResponse>(response);
}
export async function resolveAction(
pieces: Piece[],
from: string,
to: string,
order: string,
): Promise<AIResponse> {
const response = await client.v1.resolveAction.$post({
json: {
pieces: pieces,
from: from,
to: to,
order: order,
},
});
return handleResponse<AIResponse>(response);
}
export async function initGame(initData: initGame): Promise<initGameResponse> {
const response = await client.v1.createGame.$post({
json: {
player_id: initData.player_id,
enemy_id: initData.enemy_id,
first_player: initData.first_player,
},
});
return handleResponse<initGameResponse>(response);
}