add join link

This commit is contained in:
Aleksandr Zaitsev 2024-07-21 21:00:12 +03:00
parent 483dadaa4e
commit 54f0a3efb9
4 changed files with 15 additions and 2 deletions

View File

@ -13,6 +13,7 @@
"generate": "Release the fish",
"ready": "Ready",
"cancel": "Cancel",
"copyLink": "Copy join link",
"mainScreen": "Go to main screen",
"instruction": "How to play",
"rules": "Game rules"

View File

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

View File

@ -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

View File

@ -27,9 +27,16 @@ const generate = () => {
//Set ready status for player
const ready = () => {
if (game.mode == 'single') useBotStore().generate()
if (game.player.status == 'ready') game.player.status = 'lobby'
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 = ''
let cell = ((row * game.boardSize) + col) - 1