fix join process
This commit is contained in:
parent
16a688212e
commit
9236620b4c
|
|
@ -14,6 +14,7 @@
|
||||||
"ready": "Ready",
|
"ready": "Ready",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
"copyLink": "Copy join link",
|
"copyLink": "Copy join link",
|
||||||
|
"joinGame": "Join game",
|
||||||
"mainScreen": "Go to main screen",
|
"mainScreen": "Go to main screen",
|
||||||
"instruction": "How to play",
|
"instruction": "How to play",
|
||||||
"rules": "Game rules"
|
"rules": "Game rules"
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
"ready": "Готов",
|
"ready": "Готов",
|
||||||
"cancel": "Отмена",
|
"cancel": "Отмена",
|
||||||
"copyLink": "Копировать ссылку для подключения",
|
"copyLink": "Копировать ссылку для подключения",
|
||||||
|
"joinGame": "Присоединится к игре",
|
||||||
"mainScreen": "На главный экран",
|
"mainScreen": "На главный экран",
|
||||||
"instruction": "Как играть",
|
"instruction": "Как играть",
|
||||||
"rules": "Правила"
|
"rules": "Правила"
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,8 @@ export const useWebsocketStore = defineStore("websocket", {
|
||||||
break
|
break
|
||||||
case 'join':
|
case 'join':
|
||||||
console.log('Recieve join from ' + data.from)
|
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)
|
game.join(data.from)
|
||||||
break
|
break
|
||||||
case 'welcome':
|
case 'welcome':
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ if (player.id == null) player.initPlayer()
|
||||||
websocket.init(route.params.gameId)
|
websocket.init(route.params.gameId)
|
||||||
|
|
||||||
const join = () => {
|
const join = () => {
|
||||||
websocket.send({
|
res = websocket.send({
|
||||||
action: 'join',
|
action: 'join',
|
||||||
from: player.id
|
from: player.id
|
||||||
})
|
})
|
||||||
|
|
@ -31,7 +31,7 @@ const join = () => {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<button class="button_game_start" @click="join()">{{ $t("button.startNewGame") }}</button>
|
<button class="button_game_start" @click="join()">{{ $t("button.joinGame") }}</button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user