Compare commits
14 Commits
0.17.0
...
dbffce8818
| Author | SHA1 | Date | |
|---|---|---|---|
| dbffce8818 | |||
|
|
f29ed9d338 | ||
| 6c914b1421 | |||
|
|
8482aa8876 | ||
| c6537467f8 | |||
|
|
3eb505806c | ||
| 058d232d2b | |||
|
|
67dcf6274c | ||
| 02869fff8b | |||
|
|
ef073afd5e | ||
| 92a7bc0586 | |||
|
|
352b7fd3ff | ||
| 3a62fbc129 | |||
| d8b3904cbc |
25
CHANGELOG.md
25
CHANGELOG.md
@@ -135,3 +135,28 @@
|
||||
### Features
|
||||
|
||||
* Add caching headers for env.js in Nginx configuration ([93e5af7](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/commit/93e5af7402edb9fb9662e37d9b2b8c48d250c36e))
|
||||
## [0.0.0](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/compare/0.17.0...0.0.0) (2026-01-07)
|
||||
|
||||
### Features
|
||||
|
||||
* Add caching headers for env.js in Nginx configuration ([d8b3904](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/commit/d8b3904cbc8b08ed9522d7b9b4fa8af79bc75def))
|
||||
## [0.0.0](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/compare/0.18.0...0.0.0) (2026-01-07)
|
||||
|
||||
### Features
|
||||
|
||||
* Update joinGame endpoint to accept gameId as a path parameter ([92a7bc0](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/commit/92a7bc05866b77053ebb1d074ad207be8348f9d6))
|
||||
## [0.0.0](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/compare/0.19.0...0.0.0) (2026-01-07)
|
||||
|
||||
### Features
|
||||
|
||||
* Enhance user state management with polling and WebSocket connection handling ([02869ff](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/commit/02869fff8b448cde73369679c9b38bc99fb771ff))
|
||||
## [0.0.0](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/compare/0.20.0...0.0.0) (2026-01-07)
|
||||
|
||||
### Features
|
||||
|
||||
* Implement PlayDogCard functionality in user session and update Vue component ([058d232](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/commit/058d232d2ba00f33b1e658fc8a793dcd59018fa4))
|
||||
## [0.0.0](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/compare/0.21.0...0.0.0) (2026-01-07)
|
||||
|
||||
### Features
|
||||
|
||||
* Update LobbyComponent to use icons for player removal buttons ([c653746](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/commit/c6537467f87d60aeece18f86f42c839d5437c18b))
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<link rel="icon" href="/favicon.ico">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Vite App</title>
|
||||
<title>Knockout-Whist</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
84
src/App.vue
84
src/App.vue
@@ -1,8 +1,16 @@
|
||||
<script setup lang="ts">
|
||||
import { RouterView } from 'vue-router'
|
||||
import { onMounted, onUnmounted } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { onMounted, onUnmounted, watch } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useUserInfo } from "@/composables/useUserInfo";
|
||||
import { useIngame } from "@/composables/useIngame";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useWebSocket } from "@/composables/useWebsocket";
|
||||
import { useQuasar } from "quasar";
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const info = useUserInfo();
|
||||
|
||||
const handleOnlineStatusChange = () => {
|
||||
if (navigator.onLine) {
|
||||
@@ -11,12 +19,84 @@ const handleOnlineStatusChange = () => {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let interval: number | null = null;
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('online', handleOnlineStatusChange);
|
||||
|
||||
// Continuously check user state every 10 seconds
|
||||
interval = window.setInterval(async () => {
|
||||
if (navigator.onLine && route.name !== 'login' && route.name !== 'offline') {
|
||||
await info.requestState();
|
||||
if (!info.username && route.name !== 'login') {
|
||||
router.push({ name: 'login' });
|
||||
}
|
||||
}
|
||||
}, 10000);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('online', handleOnlineStatusChange);
|
||||
if (interval) {
|
||||
clearInterval(interval);
|
||||
}
|
||||
});
|
||||
|
||||
watch(() => info.gameId, (newGameId) => {
|
||||
if (newGameId && route.name !== 'game') {
|
||||
router.push({ name: 'game' });
|
||||
}
|
||||
});
|
||||
|
||||
const ig = useIngame()
|
||||
const { isWsConnected } = storeToRefs(ig)
|
||||
const wb = useWebSocket()
|
||||
const $q = useQuasar();
|
||||
|
||||
watch(isWsConnected, (connected) => {
|
||||
if (!connected && info.gameId && route.name === 'game') {
|
||||
showReconnectDialog();
|
||||
}
|
||||
});
|
||||
|
||||
function showReconnectDialog() {
|
||||
$q.dialog({
|
||||
title: 'Connection Lost',
|
||||
message: 'The connection to the game server was lost. Would you like to reconnect?',
|
||||
persistent: true,
|
||||
ok: {
|
||||
label: 'Reconnect',
|
||||
color: 'positive'
|
||||
},
|
||||
cancel: {
|
||||
label: 'Quit',
|
||||
color: 'negative'
|
||||
}
|
||||
}).onOk(() => {
|
||||
reconnect();
|
||||
}).onCancel(() => {
|
||||
router.replace("/");
|
||||
});
|
||||
}
|
||||
|
||||
async function reconnect() {
|
||||
try {
|
||||
await wb.connect();
|
||||
$q.notify({
|
||||
message: 'Reconnected successfully!',
|
||||
color: 'positive',
|
||||
icon: 'check'
|
||||
});
|
||||
} catch (err) {
|
||||
$q.notify({
|
||||
message: 'Failed to reconnect. Please try again.',
|
||||
color: 'negative',
|
||||
icon: 'error'
|
||||
});
|
||||
showReconnectDialog();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -10,6 +10,7 @@ import TurnC from "@/components/ingame/TurnC.vue";
|
||||
import TrumpC from "@/components/ingame/TrumpC.vue";
|
||||
import {storeToRefs} from "pinia";
|
||||
import {ref, toRefs, watch} from "vue";
|
||||
import TieC from "@/components/ingame/TieC.vue";
|
||||
|
||||
const ig = useIngame()
|
||||
const { state } = toRefs(ig)
|
||||
@@ -45,6 +46,22 @@ watch(
|
||||
<TrumpC />
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
|
||||
<transition
|
||||
appear
|
||||
enter-active-class="animate__animated animate__fadeInDown"
|
||||
leave-active-class="animate__animated animate__fadeOutDown"
|
||||
>
|
||||
<div
|
||||
v-if="state === 'TieBreak'"
|
||||
class="full-overlay-blur"
|
||||
style="z-index: 2000;"
|
||||
>
|
||||
<TieC />
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<div class="fit row wrap justify-center items-center content-start">
|
||||
<div class="mt-5 ml-4 self-start col-2">
|
||||
<TurnC v-if="(cachedGameInfo as GameInfo)?.playerQueue" :queue="(cachedGameInfo as GameInfo).playerQueue!"/>
|
||||
|
||||
@@ -25,9 +25,8 @@ function triggerWiggle(index: number) {
|
||||
function handlePlayCard(index: number | null) {
|
||||
if (index === null) return
|
||||
|
||||
wb.sendAndWait("PlayCard", { cardindex: index }).catch((error) => {
|
||||
wb.sendAndWait((<GameInfo>wi.data)?.self?.dogLife ? "PlayDogCard" : "PlayCard", { cardindex: index }).catch((error) => {
|
||||
triggerWiggle(index)
|
||||
|
||||
$q.notify({
|
||||
message: error.message,
|
||||
color: "negative",
|
||||
@@ -45,7 +44,13 @@ function onBeforeLeave(el: Element) {
|
||||
element.style.height = height;
|
||||
}
|
||||
function handleSkipDogLife() {
|
||||
//TODO: Add some animation or feedback for skipping turn
|
||||
wb.sendAndWait("PlayDogCard", { cardindex: 'Skip' }).catch((error) => {
|
||||
$q.notify({
|
||||
message: error.message,
|
||||
color: "negative",
|
||||
position: "top"
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function getCardImagePath(cardPath: string) {
|
||||
|
||||
443
src/components/ingame/TieC.vue
Normal file
443
src/components/ingame/TieC.vue
Normal file
@@ -0,0 +1,443 @@
|
||||
<script setup lang="ts">
|
||||
import {useWebSocket} from "@/composables/useWebsocket.ts";
|
||||
import {useIngame} from "@/composables/useIngame.ts";
|
||||
import type { TieInfo } from "@/types/GameTypes.ts";
|
||||
import {useQuasar} from "quasar";
|
||||
import { computed, nextTick, ref } from 'vue'
|
||||
|
||||
const wb = useWebSocket()
|
||||
const wi = useIngame()
|
||||
const tieInf = computed(() => wi.data as TieInfo)
|
||||
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 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);
|
||||
// Used to force-remount the flipping subtree so the CSS transition/animation restarts reliably
|
||||
const revealKey = ref(0);
|
||||
|
||||
// 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(async () => {
|
||||
console.log("Server accepted pick, starting animation...");
|
||||
|
||||
// 1. Trigger the animation state
|
||||
isFlipping.value = true;
|
||||
// 2. Force a remount of the flip-card for the selected card so the flip restarts even if src doesn't change
|
||||
revealKey.value += 1;
|
||||
await nextTick();
|
||||
|
||||
// 3. Optional Notification
|
||||
$q.notify({
|
||||
message: "Card revealed!",
|
||||
color: "positive",
|
||||
position: "top",
|
||||
timeout: 1000
|
||||
});
|
||||
|
||||
// 4. Wait for animation to finish before switching to Waiting Screen
|
||||
setTimeout(() => {
|
||||
isFlipping.value = false;
|
||||
model.value = null;
|
||||
}, 500);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Pick failed:", error);
|
||||
$q.notify({
|
||||
message: error.message || "Failed to pick card",
|
||||
color: "negative",
|
||||
position: "top"
|
||||
});
|
||||
});
|
||||
}
|
||||
const model = ref<number | null>(null)
|
||||
const options = computed(() => {
|
||||
const list = []
|
||||
const max = tieInf.value.highestAmount?.valueOf() || 0
|
||||
for (let i = 1; i <= max; i++) {
|
||||
list.push(i)
|
||||
}
|
||||
return list
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<transition
|
||||
appear
|
||||
enter-active-class="animate__animated animate__fadeInDown"
|
||||
leave-active-class="animate__animated animate__fadeOutDown"
|
||||
mode="out-in"
|
||||
>
|
||||
<q-card v-if="showPickScreen" class="game-container text-center overflow-hidden">
|
||||
|
||||
<div class="bg-glow"></div>
|
||||
|
||||
<q-card-section class="content-layer q-py-xl">
|
||||
<div class="text-overline text-primary letter-spacing-2">Tie-Break Round</div>
|
||||
<div class="text-h4 text-weight-bold text-white q-mb-xl text-uppercase tracking-widest">
|
||||
{{ isFlipping ? 'Your Result' : (model ? `Selection: Card #${model}` : 'Pick Your Card') }}
|
||||
</div>
|
||||
|
||||
<div class="card-fan-container q-mb-xl">
|
||||
<div
|
||||
v-for="n in options"
|
||||
:key="n"
|
||||
@click="!isFlipping && (model = n)"
|
||||
v-show="model === null || model === n"
|
||||
class="tie-card-wrapper"
|
||||
:class="{ 'selected-card': model === n, 'is-flipping': isFlipping && model === n }"
|
||||
>
|
||||
<div class="card-inner">
|
||||
<!-- Flip card: keep both faces mounted; flip the inner wrapper. -->
|
||||
<div
|
||||
class="flip-card"
|
||||
:class="{ 'flip-card--flipped': isFlipping && model === n && !!myRevealedCard }"
|
||||
:key="(isFlipping && model === n) ? `${revealKey}-${n}` : `static-${n}`"
|
||||
>
|
||||
<div class="flip-card__inner">
|
||||
<!-- FRONT: blank card (deck back) -->
|
||||
<div class="flip-card__face flip-card__front">
|
||||
<q-img
|
||||
:src="getCardImagePath(tieBlankCard)"
|
||||
class="card-image shadow-24"
|
||||
no-spinner
|
||||
no-transition
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- BACK: revealed card (your pick result) -->
|
||||
<div class="flip-card__face flip-card__back">
|
||||
<q-img
|
||||
:src="(model === n && myRevealedCard) ? myRevealedCard : getCardImagePath(tieBlankCard)"
|
||||
class="card-image shadow-24"
|
||||
no-spinner
|
||||
no-transition
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!isFlipping" class="card-number">
|
||||
{{ n }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="action-area" :class="{ 'visible': model !== null && !isFlipping }">
|
||||
<div class="row q-gutter-md justify-center items-center">
|
||||
<q-btn flat color="grey-4" label="Cancel" @click="model = null" />
|
||||
<q-btn
|
||||
label="Confirm Selection"
|
||||
color="positive"
|
||||
unelevated
|
||||
@click="selectTie(model!)"
|
||||
class="confirm-btn"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!model && !isFlipping" class="text-grey-6 text-italic q-mt-md">
|
||||
Hover and click to select a card from the deck
|
||||
</div>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
||||
<q-card v-else class="game-container text-center overflow-hidden">
|
||||
<q-card-section class="content-layer q-py-xl">
|
||||
<div class="text-overline text-primary letter-spacing-2">Tie-Break Round</div>
|
||||
|
||||
<div class="column items-center">
|
||||
|
||||
<div class="revealed-row q-mb-lg">
|
||||
<div
|
||||
v-for="(card, playerId) in tieInf.selectedCards"
|
||||
:key="playerId"
|
||||
class="revealed-card-wrapper"
|
||||
>
|
||||
<div class="text-caption text-grey-5 q-mb-xs">{{ getPlayerName(playerId) }}</div>
|
||||
<q-img :src="getCardImagePath(card.path)" class="card-image shadow-24" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-fan-container skeleton-fan">
|
||||
<q-skeleton
|
||||
v-for="n in options"
|
||||
:key="n"
|
||||
type="rect"
|
||||
class="skeleton-card"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="q-mt-xl">
|
||||
<q-spinner-hourglass color="primary" size="4em" />
|
||||
<div class="text-subtitle1 text-grey-5 q-mt-sm italic">
|
||||
Waiting for <span class="text-white">{{ tieInf.currentPlayer?.name }}</span> to pick a card...
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</q-card-section>
|
||||
|
||||
</q-card>
|
||||
</transition>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.game-container {
|
||||
max-width: 1400px;
|
||||
width: 95vw;
|
||||
margin: 0 auto;
|
||||
background: #0f0f0f;
|
||||
border: 1px solid rgba(255,255,255,0.1);
|
||||
border-radius: 20px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.bg-glow {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 600px;
|
||||
height: 400px;
|
||||
background: radial-gradient(circle, rgba(25, 118, 210, 0.15) 0%, rgba(0,0,0,0) 70%);
|
||||
transform: translate(-50%, -50%);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.card-fan-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 60px 20px;
|
||||
min-height: 300px;
|
||||
perspective: 1000px;
|
||||
gap: 40px 0;
|
||||
}
|
||||
|
||||
.tie-card-wrapper {
|
||||
position: relative;
|
||||
transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
|
||||
margin-left: -35px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.tie-card-wrapper:first-child { margin-left: 0; }
|
||||
|
||||
.card-image {
|
||||
width: 60px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid rgba(255,255,255,0.1);
|
||||
}
|
||||
|
||||
.tie-card-wrapper:hover {
|
||||
transform: translateY(-40px) scale(1.1) rotate(2deg);
|
||||
z-index: 50 !important;
|
||||
}
|
||||
|
||||
.selected-card {
|
||||
margin-left: 0 !important;
|
||||
transform: scale(1.4) !important;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.selected-card .card-image {
|
||||
border: 3px solid #1976d2;
|
||||
box-shadow: 0 0 30px rgba(25, 118, 210, 0.5);
|
||||
}
|
||||
|
||||
.card-number {
|
||||
position: absolute;
|
||||
bottom: -30px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
font-weight: 900;
|
||||
font-size: 1.1rem;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
padding: 12px 40px;
|
||||
border-radius: 50px;
|
||||
font-weight: bold;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.letter-spacing-2 { letter-spacing: 2px; }
|
||||
|
||||
|
||||
/* Hide action area when no model is selected */
|
||||
.action-area {
|
||||
opacity: 0;
|
||||
transform: translateY(20px);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
.action-area.visible {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
.bg-glow.dimmed {
|
||||
background: radial-gradient(circle, rgba(150, 150, 150, 0.05) 0%, rgba(0,0,0,0) 70%);
|
||||
}
|
||||
.tracking-widest {
|
||||
letter-spacing: 0.2em;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% { transform: scale(1); opacity: 0.2; }
|
||||
50% { transform: scale(1.05); opacity: 0.5; }
|
||||
}
|
||||
.skeleton-fan {
|
||||
opacity: 0.15;
|
||||
perspective: 1000px;
|
||||
}
|
||||
|
||||
.skeleton-card {
|
||||
width: 60px;
|
||||
height: 90px;
|
||||
background: rgba(255, 255, 255, 0.1) !important;
|
||||
margin-left: -35px; /* Matches your tie-card-wrapper overlap */
|
||||
border-radius: 10px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
|
||||
.skeleton-card:first-child {
|
||||
margin-left: 0;
|
||||
}
|
||||
/* Container for the cards that have been "pulled" higher */
|
||||
.revealed-row {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: flex-end;
|
||||
gap: 20px;
|
||||
min-height: 140px; /* Reserves space so the layout doesn't jump */
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.revealed-card-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
animation: slideDownFade 0.4s ease-out;
|
||||
}
|
||||
|
||||
/* Specific styling for the revealed card images */
|
||||
.revealed-card-wrapper .card-image {
|
||||
width: 65px;
|
||||
border-radius: 8px;
|
||||
border: 2px solid var(--q-primary);
|
||||
}
|
||||
|
||||
/* Keeping your original skeleton fan look */
|
||||
.skeleton-fan {
|
||||
opacity: 0.15;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.skeleton-card {
|
||||
width: 60px;
|
||||
height: 90px;
|
||||
background: rgba(255, 255, 255, 0.1) !important;
|
||||
margin-left: -35px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.skeleton-card:first-child {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
@keyframes slideDownFade {
|
||||
0% { opacity: 0; transform: translateY(-20px); }
|
||||
100% { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
.card-inner {
|
||||
perspective: 1000px;
|
||||
transform-style: preserve-3d;
|
||||
}
|
||||
|
||||
/* --- Flip card (reliable 3D flip) --- */
|
||||
.flip-card {
|
||||
width: 60px;
|
||||
/* height follows image; q-img sets its own box, but we want a stable 3D container */
|
||||
perspective: 1000px;
|
||||
}
|
||||
|
||||
.flip-card__inner {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
transform-style: preserve-3d;
|
||||
transition: transform 1.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.flip-card__face {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
backface-visibility: hidden;
|
||||
}
|
||||
|
||||
/* Ensure the q-img root stretches to fill the face */
|
||||
.flip-card__face :deep(.q-img) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.flip-card__front {
|
||||
transform: rotateY(0deg);
|
||||
}
|
||||
|
||||
.flip-card__back {
|
||||
transform: rotateY(180deg);
|
||||
}
|
||||
|
||||
.flip-card--flipped .flip-card__inner {
|
||||
/* Lift/scale a bit like your original dramatic flip */
|
||||
transform: rotateY(180deg) scale(1.3) translateY(-10px);
|
||||
}
|
||||
|
||||
/* While flipping, don't let hover/selected transforms fight the 3D transform */
|
||||
.tie-card-wrapper.is-flipping:hover {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
/* Optional: Slight pulse while the button is waiting to be clicked */
|
||||
.selected-card:not(.is-flipping) {
|
||||
animation: pulse 0.5s infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0% { transform: scale(1.4); }
|
||||
50% { transform: scale(1.45); box-shadow: 0 0 40px rgba(25, 118, 210, 0.6); }
|
||||
100% { transform: scale(1.4); }
|
||||
}
|
||||
</style>
|
||||
@@ -103,14 +103,14 @@ const profileIcon = 'person';
|
||||
<q-btn
|
||||
v-if="player.id !== (<LobbyInfo>ig.data).self.id"
|
||||
color="negative"
|
||||
label="Remove"
|
||||
icon="sports_martial_arts"
|
||||
@click="handleKickPlayer(player)"
|
||||
class="full-width"
|
||||
/>
|
||||
<q-btn
|
||||
v-else
|
||||
color="negative"
|
||||
label="Remove (Cannot Kick Self)"
|
||||
icon="sports_martial_arts"
|
||||
disable
|
||||
class="full-width"
|
||||
/>
|
||||
|
||||
@@ -9,12 +9,17 @@ const api = window?.__RUNTIME_CONFIG__?.API_URL;
|
||||
export const useIngame = defineStore('ingame', () => {
|
||||
const state: Ref<'Lobby' | 'InGame' | 'SelectTrump' | 'TieBreak' | 'FinishedMatch' | null> = ref(null);
|
||||
const data: Ref<GameInfo | LobbyInfo | TieInfo | TrumpInfo | WonInfo | null> = ref(null);
|
||||
const isWsConnected: Ref<boolean> = ref(false);
|
||||
|
||||
function setIngame(newState: 'Lobby' | 'InGame' | 'SelectTrump' | 'TieBreak' | 'FinishedMatch', newData: GameInfo | LobbyInfo | TieInfo | TrumpInfo | WonInfo) {
|
||||
state.value = newState;
|
||||
data.value = newData;
|
||||
}
|
||||
|
||||
function setWsConnected(connected: boolean) {
|
||||
isWsConnected.value = connected;
|
||||
}
|
||||
|
||||
async function requestGame(gameId: string) {
|
||||
await axios.get(`${api}/status/${gameId}`, {withCredentials: true}).then((response) => {
|
||||
setIngame(response.data.state, response.data.data);
|
||||
@@ -24,7 +29,8 @@ export const useIngame = defineStore('ingame', () => {
|
||||
function clearIngame() {
|
||||
state.value = null;
|
||||
data.value = null;
|
||||
isWsConnected.value = false;
|
||||
}
|
||||
|
||||
return { state, data, requestGame, setIngame, clearIngame };
|
||||
return { state, data, isWsConnected, requestGame, setIngame, clearIngame, setWsConnected };
|
||||
});
|
||||
|
||||
@@ -21,10 +21,19 @@ export const useUserInfo = defineStore('userInfo', () => {
|
||||
async function requestState() {
|
||||
await axios.get(`${api}/status`, {withCredentials: true}).then((response) => {
|
||||
console.log("STATUS DATA:" + response.data.status + response.data.inGame)
|
||||
if (response.data.status === 'authenticated') {
|
||||
username.value = response.data.username;
|
||||
userId.value = response.data.userId;
|
||||
if (response.data.gameId) {
|
||||
console.log("GAMEID:" + response.data.gameId)
|
||||
gameId.value = response.data.gameId;
|
||||
} else {
|
||||
gameId.value = null;
|
||||
}
|
||||
} else {
|
||||
username.value = null;
|
||||
userId.value = null;
|
||||
gameId.value = null;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -73,8 +73,12 @@ router.beforeEach(async (to, from, next) => {
|
||||
if (isOnline) {
|
||||
|
||||
try {
|
||||
const response = await axios.get(`${api}/userInfo`, { withCredentials: true });
|
||||
info.setUserInfo(response.data.username, response.data.userId);
|
||||
await info.requestState();
|
||||
|
||||
if (!info.username) {
|
||||
info.clearUserInfo();
|
||||
return next('/login');
|
||||
}
|
||||
|
||||
return next({ name: 'mainmenu' });
|
||||
|
||||
@@ -92,11 +96,17 @@ router.beforeEach(async (to, from, next) => {
|
||||
|
||||
if (!to.meta.requiresAuth) return next();
|
||||
try {
|
||||
await axios.get(`${api}/userInfo`, { withCredentials: true }).then(
|
||||
res => {
|
||||
info.setUserInfo(res.data.username, res.data.userId);
|
||||
await info.requestState();
|
||||
|
||||
if (!info.username) {
|
||||
info.clearUserInfo();
|
||||
return next('/login');
|
||||
}
|
||||
);
|
||||
|
||||
if (info.gameId && to.name !== 'game') {
|
||||
return next({ name: 'game' });
|
||||
}
|
||||
|
||||
next();
|
||||
} catch (err) {
|
||||
info.clearUserInfo();
|
||||
|
||||
@@ -160,14 +160,15 @@ function setupSocketHandlers(socket: WebSocket) {
|
||||
stopHeartbeat();
|
||||
failAllPending("WebSocket closed");
|
||||
|
||||
if (uState) {
|
||||
uState.setWsConnected(false);
|
||||
}
|
||||
|
||||
if (ev.wasClean) {
|
||||
console.log(`[WS] Closed cleanly: code=${ev.code} reason=${ev.reason}`);
|
||||
} else {
|
||||
console.warn("[WS] Connection died");
|
||||
}
|
||||
|
||||
// You redirect here — if you don’t want auto reconnect, keep as is.
|
||||
router.replace("/");
|
||||
};
|
||||
}
|
||||
|
||||
@@ -191,6 +192,9 @@ export function connectWebSocket(url?: string): Promise<void> {
|
||||
const prevOnError = ws!.onerror;
|
||||
ws!.onopen = (ev) => {
|
||||
if (prevOnOpen) prevOnOpen.call(ws!, ev);
|
||||
if (uState) {
|
||||
uState.setWsConnected(true);
|
||||
}
|
||||
resolve();
|
||||
};
|
||||
ws!.onerror = (err) => {
|
||||
@@ -207,6 +211,9 @@ export function connectWebSocket(url?: string): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
ws!.onopen = () => {
|
||||
console.log("[WS] Connected");
|
||||
if (uState) {
|
||||
uState.setWsConnected(true);
|
||||
}
|
||||
startHeartbeat();
|
||||
resolve();
|
||||
};
|
||||
@@ -224,6 +231,9 @@ export function disconnectWebSocket(code = 1000, reason = "Client disconnect") {
|
||||
ws.close(code, reason);
|
||||
} catch {}
|
||||
ws = null;
|
||||
if (uState) {
|
||||
uState.setWsConnected(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<string, Card>
|
||||
}
|
||||
|
||||
type TrumpInfo = {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { ref } from 'vue';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { useRouter } from 'vue-router';
|
||||
import axios from "axios";
|
||||
import {useUserInfo} from "@/composables/useUserInfo";
|
||||
|
||||
const api = window?.__RUNTIME_CONFIG__?.API_URL;
|
||||
const lobbyName = ref('');
|
||||
@@ -11,13 +12,14 @@ const playerAmount = ref(2);
|
||||
const $q = useQuasar();
|
||||
const isLoading = ref(false);
|
||||
const router = useRouter();
|
||||
const info = useUserInfo();
|
||||
const createGameQuasar = async () => {
|
||||
if (!lobbyName.value) {
|
||||
$q.notify({ message: 'Lobby-Name wird benötigt', color: 'red', position: 'top', icon: 'cancel' });
|
||||
return;
|
||||
}
|
||||
isLoading.value = true;
|
||||
axios.post(`${api}/createGame`, {lobbyname: lobbyName.value, playeramount: playerAmount.value.toString()}, {withCredentials: true}).then((response) => {
|
||||
axios.post(`${api}/createGame`, {lobbyname: lobbyName.value, playeramount: playerAmount.value.toString()}, {withCredentials: true}).then(async (response) => {
|
||||
const responseData = response.data
|
||||
console.log("Response" + responseData.status)
|
||||
$q.notify({
|
||||
@@ -26,12 +28,12 @@ const createGameQuasar = async () => {
|
||||
icon: 'check_circle',
|
||||
position: 'top'
|
||||
});
|
||||
await info.requestState();
|
||||
router.replace("/game")
|
||||
}).catch((err) => {
|
||||
console.log("ERROR:" + err)
|
||||
}).finally(() =>
|
||||
isLoading.value = false
|
||||
)
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import LobbyComponent from "@/components/lobby/LobbyComponent.vue";
|
||||
import {storeToRefs} from "pinia";
|
||||
import {useQuasar} from "quasar";
|
||||
import router from "@/router";
|
||||
import {ref, watch} from "vue";
|
||||
|
||||
const wb = useWebSocket()
|
||||
const ig = useIngame()
|
||||
@@ -20,7 +21,6 @@ ui.requestState().then(() => {
|
||||
$q.notify({
|
||||
message: "You're not in any game!",
|
||||
color: "negative"
|
||||
|
||||
})
|
||||
router.replace("/")
|
||||
} else {
|
||||
@@ -33,7 +33,7 @@ ui.requestState().then(() => {
|
||||
|
||||
<template>
|
||||
<div class="lobby-background">
|
||||
<Ingame v-if="state === 'InGame' || state === 'SelectTrump'"/>
|
||||
<Ingame v-if="state === 'InGame' || state === 'SelectTrump' || state === 'TieBreak'"/>
|
||||
<lobby-component v-if="state === 'Lobby'"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,28 +1,49 @@
|
||||
<script setup lang="ts">
|
||||
import {ref} from "vue";
|
||||
import {ref, onUnmounted} from "vue";
|
||||
import { useRouter } from 'vue-router';
|
||||
import {useQuasar} from "quasar";
|
||||
import axios from "axios";
|
||||
import {useUserInfo} from "@/composables/useUserInfo";
|
||||
const router = useRouter();
|
||||
const info = useUserInfo();
|
||||
const lobbyCode = ref('');
|
||||
const isLoading = ref(false);
|
||||
const $q = useQuasar();
|
||||
const api = window?.__RUNTIME_CONFIG__?.API_URL;
|
||||
|
||||
let pollInterval: number | null = null;
|
||||
|
||||
onUnmounted(() => {
|
||||
if (pollInterval) {
|
||||
clearInterval(pollInterval);
|
||||
}
|
||||
});
|
||||
|
||||
const startGameQuasar = async() => {
|
||||
if (!lobbyCode.value) {
|
||||
$q.notify({ message: 'Lobby-Name wird benötigt', color: 'red', position: 'top', icon: 'cancel' });
|
||||
return;
|
||||
}
|
||||
isLoading.value = true;
|
||||
axios.post(`${api}/joinGame`, {gameId: lobbyCode.value.toString()}, {withCredentials: true}).then(response => {
|
||||
const responseData = response.data
|
||||
axios.post(`${api}/joinGame/${lobbyCode.value.toString()}`, {}, {withCredentials: true}).then(() => {
|
||||
$q.notify({
|
||||
message: `Lobby "${lobbyCode.value}" erfolgreich gefunden`,
|
||||
color: 'green-6',
|
||||
icon: 'check_circle',
|
||||
position: 'top'
|
||||
});
|
||||
router.replace("/game")
|
||||
|
||||
// Start polling until gameId is set
|
||||
pollInterval = window.setInterval(async () => {
|
||||
await info.requestState();
|
||||
if (info.gameId) {
|
||||
if (pollInterval) {
|
||||
clearInterval(pollInterval);
|
||||
pollInterval = null;
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
|
||||
}).catch(() => {
|
||||
$q.notify({
|
||||
message: `Lobby "${lobbyCode.value}" nicht gefunden`,
|
||||
@@ -30,9 +51,8 @@ const startGameQuasar = async() => {
|
||||
icon: 'cancel',
|
||||
position: 'top'
|
||||
})
|
||||
}).finally(() =>
|
||||
isLoading.value = false
|
||||
)
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
MAJOR=0
|
||||
MINOR=17
|
||||
MINOR=22
|
||||
PATCH=0
|
||||
|
||||
Reference in New Issue
Block a user