Feat : add Leave, kick and game configuration

This commit is contained in:
2024-08-27 11:51:31 +02:00
parent ddcb6c6849
commit 0fb4877266
10 changed files with 243 additions and 46 deletions
+26
View File
@@ -50,6 +50,10 @@ export async function startGame(game: string) {
);
}
export async function deleteGame(game: string) {
const config = useRuntimeConfig();
}
export async function joinGame(game: string) {
const config = useRuntimeConfig();
const res = await $fetch<Game>(
@@ -61,6 +65,28 @@ export async function joinGame(game: string) {
);
}
export async function leaveGame(game: string) {
const config = useRuntimeConfig();
const res = await $fetch<Game>(
config.public.endpoint + `/games/${game}/leave`,
{
method: "POST",
credentials: "include",
}
);
}
export async function kickPlayer(game: string, playerId: string) {
const config = useRuntimeConfig();
const res = await $fetch<Game>(
config.public.endpoint + `/games/${game}/kick/${playerId}`,
{
method: "POST",
credentials: "include",
}
);
}
export async function endTurn(game: string) {
const config = useRuntimeConfig();
await $fetch(config.public.endpoint + `/games/${game}/endTurn`, {