This commit is contained in:
Aleksandr Zaitsev 2024-07-21 21:33:06 +03:00
parent b5aec17dd4
commit 49b1b9bd13

View File

@ -12,26 +12,31 @@ const player = usePlayerStore()
const game = useGameStore()
const bot = useBotStore()
if (game.owner == player.id || game.opponent.id == player.id) {
window.location.href = window.location.origin + '/lobby/' + game.id
return
}
game.$reset()
bot.$reset()
localStorage.removeItem('game')
localStorage.removeItem('bot')
const websocket = useWebsocketStore()
if (player.id == null) player.initPlayer()
websocket.init(route.params.gameId)
const join = () => {
res = websocket.send({
action: 'join',
from: player.id
})
}
onBeforeMount(() => {
console.log(game.owner, game.opponent.id, player.id)
if (game.owner == player.id || game.opponent.id == player.id) {
window.location.href = window.location.origin + '/lobby/' + game.id
return
}
})
onMounted(() => {
game.$reset()
bot.$reset()
localStorage.removeItem('game')
localStorage.removeItem('bot')
const websocket = useWebsocketStore()
if (player.id == null) player.initPlayer()
websocket.init(route.params.gameId)
})
</script>
<template>