squash debug commits
This commit is contained in:
parent
e82accd24b
commit
d169a46bcc
|
|
@ -13,6 +13,8 @@
|
|||
"generate": "Release the fish",
|
||||
"ready": "Ready",
|
||||
"cancel": "Cancel",
|
||||
"copyLink": "Copy join link",
|
||||
"joinGame": "Join game",
|
||||
"mainScreen": "Go to main screen",
|
||||
"instruction": "How to play",
|
||||
"rules": "Game rules"
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
"generate": "Запустить рыбу",
|
||||
"ready": "Готов",
|
||||
"cancel": "Отмена",
|
||||
"copyLink": "Копировать ссылку для подключения",
|
||||
"joinGame": "Присоединится к игре",
|
||||
"mainScreen": "На главный экран",
|
||||
"instruction": "Как играть",
|
||||
"rules": "Правила"
|
||||
|
|
|
|||
|
|
@ -124,7 +124,11 @@ export const useGameStore = defineStore("game", {
|
|||
ready() {
|
||||
const board = new boardConstructor(this.boardSize, this.getAvailableItems())
|
||||
if (!board.isAllItemsReady(this.player.items)) return
|
||||
this.player.status = "ready"
|
||||
if (this.player.status == "ready") {
|
||||
this.player.status = "lobby"
|
||||
} else {
|
||||
this.player.status = "ready"
|
||||
}
|
||||
if (this.mode == "single") {
|
||||
useBotStore().generate()
|
||||
return
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ 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 != player.id) return // Only owner can process join
|
||||
game.join(data.from)
|
||||
break
|
||||
case 'welcome':
|
||||
|
|
|
|||
|
|
@ -3,23 +3,25 @@ import { useBotStore } from '@/stores/bot';
|
|||
import { useGameStore } from '@/stores/game';
|
||||
import { usePlayerStore } from '@/stores/player';
|
||||
import { useWebsocketStore } from '@/stores/websocket';
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
|
||||
|
||||
|
||||
const route = useRoute()
|
||||
const player = usePlayerStore()
|
||||
const game = useGameStore()
|
||||
const bot = useBotStore()
|
||||
|
||||
game.$reset()
|
||||
bot.$reset()
|
||||
localStorage.removeItem('game')
|
||||
localStorage.removeItem('bot')
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const websocket = useWebsocketStore()
|
||||
if (player.id == null) player.initPlayer()
|
||||
websocket.init(route.params.gameId)
|
||||
|
||||
if (game.owner == player.id || game.player.id == player.id) {
|
||||
router.replace({ name: 'lobby', params: { gameId: game.id } })
|
||||
} else {
|
||||
game.$reset()
|
||||
bot.$reset()
|
||||
localStorage.removeItem('game')
|
||||
localStorage.removeItem('bot')
|
||||
if (player.id == null) player.initPlayer()
|
||||
websocket.init(route.params.gameId)
|
||||
}
|
||||
|
||||
const join = () => {
|
||||
websocket.send({
|
||||
|
|
@ -31,7 +33,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>
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ if (game.createdAt == null) {
|
|||
router.replace({name:'index'})
|
||||
}
|
||||
|
||||
|
||||
const board = new boardConstructor(game.boardSize, game.getAvailableItems())
|
||||
//Board cells in browser MB not needed
|
||||
const playerView = ref()
|
||||
|
|
@ -27,8 +26,14 @@ const generate = () => {
|
|||
//Set ready status for player
|
||||
const ready = () => {
|
||||
if (game.mode == 'single') useBotStore().generate()
|
||||
if (board.isAllItemsReady(game.player.items))
|
||||
game.ready()
|
||||
if (board.isAllItemsReady(game.player.items)) game.ready()
|
||||
}
|
||||
const copyJoinLink = async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(window.location.origin + '/join/' + game.id);
|
||||
} catch (err) {
|
||||
console.error('Failed to copy: ', err);
|
||||
}
|
||||
}
|
||||
const drawCell = (row, col) => {
|
||||
let classes = ''
|
||||
|
|
@ -63,7 +68,8 @@ onBeforeUnmount(() => {
|
|||
<template>
|
||||
<div class="lobby">
|
||||
<div class="lobby-buttons">
|
||||
<button class="button-lobby" @click="generate()">{{ $t("button.generate") }}</button>
|
||||
<button v-if="game.player.status == 'lobby'" class="button-lobby" @click="generate()">{{ $t("button.generate") }}</button>
|
||||
<button v-if="game.player.status == 'ready'" class="button-lobby" @click="copyJoinLink()">{{ $t("button.copyLink") }}</button>
|
||||
<button class="button-lobby" @click="ready()">{{ game.player.status == 'ready' ? $t("button.cancel") : $t("button.ready") }}</button>
|
||||
</div>
|
||||
<div class="lake-border">
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user