diff --git a/src/components/ingame/TieC.vue b/src/components/ingame/TieC.vue index c6aec50..1a6eaec 100644 --- a/src/components/ingame/TieC.vue +++ b/src/components/ingame/TieC.vue @@ -4,7 +4,7 @@ import {useIngame} from "@/composables/useIngame.ts"; import type {GameInfo, LobbyInfo, TieInfo, TrumpInfo} from "@/types/GameTypes.ts"; import {useQuasar} from "quasar"; import { ref } from 'vue'; -import { computed } from 'vue' +import { computed, nextTick } from 'vue' const wb = useWebSocket() const wi = useIngame() @@ -21,59 +21,59 @@ function getPlayerName(playerId: string) { return tieInf.value.tiedPlayers.find(p => p.id === playerId)?.name || 'Player'; } 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; + return isFlipping.value || (isMyTurn && !showResultScreen.value); }); +const showResultScreen = computed(() => { + const allPicked = Object.keys(tieInf.value.selectedCards).length === tieInf.value.tiedPlayers.length; + return allPicked && !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..."); + isFlipping.value = true; + nextTick(() => { + wb.sendAndWait("PickTie", { cardIndex: tieIndex }) + .then(() => { + console.log("Server accepted pick, starting animation..."); + console.log("CARD SELECTED: " + Object.keys(tieInf.value.selectedCards).length) - // 1. Trigger the animation state - isFlipping.value = true; - // 2. Optional Notification - $q.notify({ - message: "Card revealed!", - color: "positive", - position: "top", - timeout: 1000 - }); + $q.notify({ + message: "Card revealed!", + color: "positive", + position: "top", + timeout: 1000 + }); - // 3. Wait for animation to finish before switching to Waiting Screen - setTimeout(() => { + setTimeout(() => { + isFlipping.value = false; + model.value = null; + }, 2500); + }) + .catch((error) => { 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" + 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(() => { @@ -115,7 +115,6 @@ const options = computed(() => { >
{ - +
Tie-Break Round
@@ -174,7 +173,7 @@ const options = computed(() => {
- +
Waiting for {{ tieInf.currentPlayer?.name }} to pick a card...
@@ -183,6 +182,61 @@ const options = computed(() => { + +
+ + +
+ +
+ {{ (tieInf.winners?.length || 0) > 1 ? 'Another Tie!' : 'Tie Broken' }} +
+

+ {{ (tieInf.winners?.length || 0) > 1 ? 'The high cards matched. Draw again!' : 'We have a winner.' }} +

+
+ +
+
+
+
{{ getPlayerName(playerId) }}
+ +
+ +
+ +
+
+
+
+ +
+ Preparing trumpsuit selection... +
+
+
+
@@ -397,4 +451,35 @@ const options = computed(() => { 50% { transform: scale(1.45); box-shadow: 0 0 40px rgba(25, 118, 210, 0.6); } 100% { transform: scale(1.4); } } +/* Add to previous styles */ + +.winner-glow .card-image { + border-color: #31ccec; /* Default 'info' blue for ongoing ties */ + transform: scale(1.05) translateY(-10px); + box-shadow: 0 10px 40px rgba(49, 204, 236, 0.4) !important; +} + +/* If there is only one winner, change glow to Gold */ +.winner-glow:only-child .card-image, +.tie-break-card .winner-glow:has(.bg-positive) .card-image { + border-color: #f2c037; + box-shadow: 0 10px 40px rgba(242, 192, 55, 0.5) !important; +} + +.opacity-40 { + opacity: 0.4; + filter: grayscale(0.8); + transform: scale(0.9); + transition: all 0.5s ease; +} + +.card-stack { + perspective: 1000px; +} + +.card-image-reveal { + width: 130px; + border-radius: 10px; + transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); +} diff --git a/src/types/GameTypes.ts b/src/types/GameTypes.ts index 7998d26..60b98e6 100644 --- a/src/types/GameTypes.ts +++ b/src/types/GameTypes.ts @@ -33,6 +33,7 @@ type TieInfo = { tiedPlayers: Player[] highestAmount: number selectedCards: Record + winners: Player[] | null } type TrumpInfo = {