diff --git a/netcode/index.ts b/netcode/index.ts index 8b6742d..4c5b4e0 100644 --- a/netcode/index.ts +++ b/netcode/index.ts @@ -80,6 +80,17 @@ export async function leaveGame(game: string) { ); } +export async function surrender(game: string) { + const config = useRuntimeConfig(); + const res = await $fetch( + config.public.endpoint + `/games/${game}/surrender`, + { + method: "POST", + credentials: "include", + } + ); +} + export async function kickPlayer(game: string, playerId: string) { const config = useRuntimeConfig(); const res = await $fetch( diff --git a/pages/game.vue b/pages/game.vue index 1fd0aa4..a8c0194 100644 --- a/pages/game.vue +++ b/pages/game.vue @@ -8,6 +8,7 @@ import { joinGame, deleteGame, leaveGame, + surrender, } from "~/netcode"; import { delay } from "~/netcode/events"; import { @@ -262,7 +263,14 @@ onUnmounted(() => {