This commit is contained in:
@@ -80,6 +80,17 @@ export async function leaveGame(game: string) {
|
||||
);
|
||||
}
|
||||
|
||||
export async function surrender(game: string) {
|
||||
const config = useRuntimeConfig();
|
||||
const res = await $fetch<Game>(
|
||||
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<Game>(
|
||||
|
||||
+19
-8
@@ -8,6 +8,7 @@ import {
|
||||
joinGame,
|
||||
deleteGame,
|
||||
leaveGame,
|
||||
surrender,
|
||||
} from "~/netcode";
|
||||
import { delay } from "~/netcode/events";
|
||||
import {
|
||||
@@ -262,7 +263,14 @@ onUnmounted(() => {
|
||||
|
||||
<!-- <LoadingScreen v-if="!loaded"></LoadingScreen> -->
|
||||
<footer>
|
||||
<div>
|
||||
<GameModalOptionsDialog></GameModalOptionsDialog>
|
||||
<GameModalConfigureDialog
|
||||
v-if="game && game.owner.userId == authStore.selfUser.userId"
|
||||
:game="game"
|
||||
></GameModalConfigureDialog>
|
||||
</div>
|
||||
|
||||
<ClientOnly>
|
||||
<div id="turn_buttons" v-if="game">
|
||||
<template v-if="game.started">
|
||||
@@ -284,26 +292,29 @@ onUnmounted(() => {
|
||||
>
|
||||
Start game
|
||||
</button>
|
||||
<GameModalConfigureDialog :game="game"></GameModalConfigureDialog>
|
||||
</template>
|
||||
|
||||
<button
|
||||
class="end_turn_button turn_icon"
|
||||
@click="joinGame(game._id)"
|
||||
v-else-if="
|
||||
playerList?.every(
|
||||
(p) => p.user.userId != authStore.selfUser.userId
|
||||
)
|
||||
"
|
||||
v-else-if="!selfPlayer"
|
||||
>
|
||||
Join game
|
||||
</button>
|
||||
<button v-else @click="leaveGame(game._id)">Leave game</button>
|
||||
</template>
|
||||
</div>
|
||||
</ClientOnly>
|
||||
|
||||
<div>
|
||||
<button
|
||||
v-if="game && game.started && selfPlayer"
|
||||
class="red"
|
||||
@click="surrender(game._id)"
|
||||
>
|
||||
Surrender
|
||||
</button>
|
||||
<button @click="navigateTo('/lobby')">Return to lobby</button>
|
||||
</div>
|
||||
</ClientOnly>
|
||||
</footer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user