From bf2dbca152f94ba7821e0af54fb64ba04d69cec7 Mon Sep 17 00:00:00 2001 From: legonzaur Date: Fri, 17 May 2024 15:22:57 +0200 Subject: [PATCH] Feat : more interesting lobby button messages Closes #4 --- components/GameBoard.vue | 2 +- components/LobbyView.vue | 31 +++++++++++++++++++++++-------- netcode/Game.ts | 1 + netcode/index.ts | 15 +++++++++++---- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/components/GameBoard.vue b/components/GameBoard.vue index 1e6ab22..75bf992 100644 --- a/components/GameBoard.vue +++ b/components/GameBoard.vue @@ -6,7 +6,7 @@ import { playSound } from '~/helpers/audioHelpers'; const current_players = computed>(() => Array.from(goStore.current_game?.players ?? []).filter(p => p.team === goStore.current_game?.current_turn)) watch( - () => goStore.current_game?.current_turn.uuid, + () => goStore.current_game?.current_turn?.uuid, () => { if (goStore.current_game?.current_turn?.uuid == goStore.self?.team?.uuid) { playSound('/sounds/ding.mp3') diff --git a/components/LobbyView.vue b/components/LobbyView.vue index 6daf671..b6e184b 100644 --- a/components/LobbyView.vue +++ b/components/LobbyView.vue @@ -26,16 +26,27 @@ function killErika() {
- @@ -146,6 +157,10 @@ function killErika() { box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); } + + button.own_game { + border: solid yellow 5px; + } } .overlay { diff --git a/netcode/Game.ts b/netcode/Game.ts index 8535eba..d7c268c 100644 --- a/netcode/Game.ts +++ b/netcode/Game.ts @@ -13,6 +13,7 @@ export interface GameNetcode extends GameObjectNetcode { players: Array losers: Array ended: boolean + owner: string } diff --git a/netcode/index.ts b/netcode/index.ts index be441ef..6c0d55b 100644 --- a/netcode/index.ts +++ b/netcode/index.ts @@ -35,6 +35,7 @@ export class GameObjectRegister { clientMouseX: Ref clientMouseY: Ref + discordId: Ref constructor() { this.effects = reactive(new Map()); this.cards = reactive(new Map()); @@ -51,6 +52,7 @@ export class GameObjectRegister { this.hoveredCard = ref() this.clientMouseX = ref(0) this.clientMouseY = ref(0) + this.discordId = ref("") } update_object(obj: GameObjectNetcode) { @@ -106,11 +108,14 @@ export class GameObjectRegister { }, } as { [id: string]: (data: any) => any }; - set_self = (uuid: string) => { + setSelf = (uuid: string) => { this.self.value = this.players.get(uuid) ?? null; }; - set_current_game = (uuid: string) => { + setDiscordId = (username: string) => { + this.discordId.value = username + } + setCurrentGame = (uuid: string) => { this.current_game.value = this.games.get(uuid) ?? null; }; } @@ -167,11 +172,13 @@ export const setup_websocket = () => // console.log(data.data); } else if (data.type === "set") { if (data.data_type == "self") { - goStore.set_self(data.data); + goStore.setSelf(data.data); } else if (data.data_type == "current_game") { - goStore.set_current_game(data.data); + goStore.setCurrentGame(data.data); } else if (data.data_type == "session_cookie") { heron_session.value = data.data; + } else if (data.data_type == "self_discord_id") { + goStore.setDiscordId(data.data) } } else { // console.log(data.type, data.data_type, data.data);