This commit is contained in:
Aleksandr Zaitsev 2024-07-21 22:19:37 +03:00
parent a3d1c3705b
commit f4cebd880e

View File

@ -9,6 +9,8 @@ import { useRoute } from 'vue-router'
const player = usePlayerStore() const player = usePlayerStore()
const game = useGameStore() const game = useGameStore()
const bot = useBotStore() const bot = useBotStore()
const route = useRoute()
const websocket = useWebsocketStore()
const join = () => { const join = () => {
res = websocket.send({ res = websocket.send({
@ -20,7 +22,7 @@ const join = () => {
onBeforeMount(() => { onBeforeMount(() => {
console.log(game.owner, game.opponent.id, player.id) console.log(game.owner, game.opponent.id, player.id)
if (game.owner == player.id || game.opponent.id == player.id) { if (game.owner == player.id || game.opponent.id == player.id) {
window.location.href = window.location.origin + '/lobby/' + game.id route.push({ name: 'lobby', params: { gameId: game.id } })
return return
} }
}) })
@ -30,8 +32,6 @@ onMounted(() => {
bot.$reset() bot.$reset()
localStorage.removeItem('game') localStorage.removeItem('game')
localStorage.removeItem('bot') localStorage.removeItem('bot')
const route = useRoute()
const websocket = useWebsocketStore()
if (player.id == null) player.initPlayer() if (player.id == null) player.initPlayer()
websocket.init(route.params.gameId) websocket.init(route.params.gameId)
}) })