fix join process

This commit is contained in:
Aleksandr Zaitsev 2024-07-21 21:13:33 +03:00
parent 16a688212e
commit 9236620b4c
4 changed files with 6 additions and 3 deletions

View File

@ -14,6 +14,7 @@
"ready": "Ready",
"cancel": "Cancel",
"copyLink": "Copy join link",
"joinGame": "Join game",
"mainScreen": "Go to main screen",
"instruction": "How to play",
"rules": "Game rules"

View File

@ -14,6 +14,7 @@
"ready": "Готов",
"cancel": "Отмена",
"copyLink": "Копировать ссылку для подключения",
"joinGame": "Присоединится к игре",
"mainScreen": "На главный экран",
"instruction": "Как играть",
"rules": "Правила"

View File

@ -46,7 +46,8 @@ export const useWebsocketStore = defineStore("websocket", {
break
case 'join':
console.log('Recieve join from ' + data.from)
if (game.owner != player.id) return // Only owner ccan process join
if (game.owner == data.from || game.opponent.id == data.from) window.location.href = window.location.origin + '/lobby/' + game.id
if (game.owner != player.id) return // Only owner can process join
game.join(data.from)
break
case 'welcome':

View File

@ -22,7 +22,7 @@ if (player.id == null) player.initPlayer()
websocket.init(route.params.gameId)
const join = () => {
websocket.send({
res = websocket.send({
action: 'join',
from: player.id
})
@ -31,7 +31,7 @@ const join = () => {
<template>
<div>
<button class="button_game_start" @click="join()">{{ $t("button.startNewGame") }}</button>
<button class="button_game_start" @click="join()">{{ $t("button.joinGame") }}</button>
</div>
</template>