From 1ed4365c7883302bf6f5770e3bc5149c74026bbc Mon Sep 17 00:00:00 2001 From: LQ63 Date: Tue, 13 Jan 2026 22:22:34 +0100 Subject: [PATCH] feat(ui): Tie selection Added a nice tie selection ui --- src/components/ingame/TieC.vue | 410 ++++++++++++++++++++++++++++----- src/types/GameTypes.ts | 4 +- 2 files changed, 359 insertions(+), 55 deletions(-) diff --git a/src/components/ingame/TieC.vue b/src/components/ingame/TieC.vue index 873c33e..c6aec50 100644 --- a/src/components/ingame/TieC.vue +++ b/src/components/ingame/TieC.vue @@ -9,32 +9,73 @@ import { computed } from 'vue' const wb = useWebSocket() const wi = useIngame() const tieInf = computed(() => wi.data as TieInfo) -const tieBlankCard = [ - "/images/cards/AS.png" -] +const tieBlankCard = "/images/cards/1B.png" const $q = useQuasar(); function getCardImagePath(cardPath: string) { if (!cardPath) return '' if (cardPath.includes('://') || cardPath.startsWith('/')) return cardPath return `/${cardPath}` } -function selectTie(tieIndex: number) { - wb.sendAndWait("PickTie", { cardIndex: tieIndex }).then( - $q.notify({ - message: "You've successfully picked your tieCard", - color: "positive", - position: "top" - }) - ).catch((error) => { - $q.notify({ - message: error.message, - color: "negative", - position: "top" - }) - }) +function getPlayerName(playerId: string) { + return tieInf.value.tiedPlayers.find(p => p.id === playerId)?.name || 'Player'; } -const model = ref(1) +const myRevealedCard = computed(() => { + // 1. Get your own ID from the 'self' object in the DTO + const myId = tieInf.value.self?.id; + + // 2. Safety check: ensure we have an ID and the map exists + if (!myId || !tieInf.value.selectedCards) return null; + + // 3. Look up the CardDTO using your ID as the key + const card = tieInf.value.selectedCards[myId]; + + // 4. If found, convert the relative path to a full URL + return card ? getCardImagePath(card.path) : null; +}); + +const isFlipping = ref(false); + +// This replaces your v-if check. +// It keeps the "Pick" screen visible while flipping. +const showPickScreen = computed(() => { + const isMyTurn = tieInf.value.self?.id === tieInf.value.currentPlayer?.id; + return isMyTurn || isFlipping.value; +}); + +function selectTie(tieIndex: number) { + // Use model.value because it's a ref + wb.sendAndWait("PickTie", { cardIndex: tieIndex }) + .then(() => { + console.log("Server accepted pick, starting animation..."); + + // 1. Trigger the animation state + isFlipping.value = true; + + // 2. Optional Notification + $q.notify({ + message: "Card revealed!", + color: "positive", + position: "top", + timeout: 1000 + }); + + // 3. Wait for animation to finish before switching to Waiting Screen + setTimeout(() => { + isFlipping.value = false; + model.value = null; + }, 2500); + }) + .catch((error) => { + console.error("Pick failed:", error); + $q.notify({ + message: error.message || "Failed to pick card", + color: "negative", + position: "top" + }); + }); +} +const model = ref(null) const options = computed(() => { const list = [] const max = tieInf.value.highestAmount?.valueOf() || 0 @@ -47,52 +88,313 @@ const options = computed(() => { diff --git a/src/types/GameTypes.ts b/src/types/GameTypes.ts index 9c3bca5..7998d26 100644 --- a/src/types/GameTypes.ts +++ b/src/types/GameTypes.ts @@ -5,7 +5,8 @@ import type { PodiumPlayer, Round, Trick, - User + User, + Card } from "@/types/GameSubTypes.ts"; @@ -31,6 +32,7 @@ type TieInfo = { self: Player | null tiedPlayers: Player[] highestAmount: number + selectedCards: Record } type TrumpInfo = {