Compare commits
17 Commits
0.5.0
...
0faa042401
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0faa042401 | ||
|
|
bda06a37cc | ||
| 39898ed03b | |||
|
|
97b7df2a75 | ||
| 06f27d6813 | |||
|
|
7c8cf6503b | ||
| f05f10ea56 | |||
|
|
43920b25f3 | ||
| 21db939d34 | |||
|
|
0b05cba25f | ||
| 14e001cae6 | |||
|
|
fc60234faf | ||
| b20ec0a363 | |||
|
|
027095f874 | ||
| df61db2730 | |||
|
|
8758f95fcd | ||
| ecb38510de |
36
CHANGELOG.md
@@ -68,3 +68,39 @@
|
|||||||
### Features
|
### Features
|
||||||
|
|
||||||
* FRO-20 Create scoreboard component ([#12](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/issues/12)) ([97a9f85](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/commit/97a9f857586eb41feb056d7af0a5d8553d2bcf80))
|
* FRO-20 Create scoreboard component ([#12](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/issues/12)) ([97a9f85](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/commit/97a9f857586eb41feb056d7af0a5d8553d2bcf80))
|
||||||
|
## [0.0.0](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/compare/0.5.0...0.0.0) (2025-12-10)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* FRO-21 Create Turn Component ([#13](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/issues/13)) ([ecb3851](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/commit/ecb38510de53b811eaaee2a39fc1ae423aed71c6))
|
||||||
|
## [0.0.0](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/compare/0.6.0...0.0.0) (2025-12-10)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **api:** FRO-14 Create Game ([#14](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/issues/14)) ([df61db2](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/commit/df61db2730b5e6b2796cbe58d1d224f1d5d6f085))
|
||||||
|
## [0.0.0](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/compare/0.7.0...0.0.0) (2025-12-10)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* FRO-23 Create Player Hand Component ([#15](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/issues/15)) ([b20ec0a](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/commit/b20ec0a3638649155f2f9c5984014d75eb2ba618))
|
||||||
|
## [0.0.0](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/compare/0.8.0...0.0.0) (2025-12-10)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **api:** FRO-15 Join Game ([#16](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/issues/16)) ([14e001c](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/commit/14e001cae67592c5ea15786905aa3574df9a9e6c))
|
||||||
|
## [0.0.0](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/compare/0.9.0...0.0.0) (2025-12-10)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* FRO-24 Create Played Cards Component ([#17](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/issues/17)) ([21db939](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/commit/21db939d342c72f5ad5fad3b4f873e902d1e5a0f))
|
||||||
|
## [0.0.0](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/compare/0.10.0...0.0.0) (2025-12-10)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **ui:** FRO-13 User Component ([#18](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/issues/18)) ([f05f10e](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/commit/f05f10ea56b21f15cefbc76277ead5806eb1cf18))
|
||||||
|
## [0.0.0](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/compare/0.11.0...0.0.0) (2025-12-10)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* FRO-25 Create Game Info Component ([#19](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/issues/19)) ([06f27d6](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/commit/06f27d6813f625af25e734de3dcbcf07b10f3a1a))
|
||||||
|
## [0.0.0](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/compare/0.12.0...0.0.0) (2025-12-10)
|
||||||
|
|||||||
BIN
public/images/cards/1B.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
public/images/cards/1J.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
public/images/cards/2B.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
public/images/cards/2C.png
Normal file
|
After Width: | Height: | Size: 8.4 KiB |
BIN
public/images/cards/2D.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
public/images/cards/2H.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
public/images/cards/2J.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
public/images/cards/2S.png
Normal file
|
After Width: | Height: | Size: 7.7 KiB |
BIN
public/images/cards/3C.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
public/images/cards/3D.png
Normal file
|
After Width: | Height: | Size: 7.3 KiB |
BIN
public/images/cards/3H.png
Normal file
|
After Width: | Height: | Size: 7.6 KiB |
BIN
public/images/cards/3S.png
Normal file
|
After Width: | Height: | Size: 9.1 KiB |
BIN
public/images/cards/4C.png
Normal file
|
After Width: | Height: | Size: 9.1 KiB |
BIN
public/images/cards/4D.png
Normal file
|
After Width: | Height: | Size: 6.6 KiB |
BIN
public/images/cards/4H.png
Normal file
|
After Width: | Height: | Size: 7.0 KiB |
BIN
public/images/cards/4S.png
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
public/images/cards/5C.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
public/images/cards/5D.png
Normal file
|
After Width: | Height: | Size: 7.9 KiB |
BIN
public/images/cards/5H.png
Normal file
|
After Width: | Height: | Size: 8.4 KiB |
BIN
public/images/cards/5S.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
public/images/cards/6C.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
public/images/cards/6D.png
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
public/images/cards/6H.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
public/images/cards/6S.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
public/images/cards/7C.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
public/images/cards/7D.png
Normal file
|
After Width: | Height: | Size: 9.0 KiB |
BIN
public/images/cards/7H.png
Normal file
|
After Width: | Height: | Size: 9.6 KiB |
BIN
public/images/cards/7S.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
public/images/cards/8C.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
public/images/cards/8D.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
public/images/cards/8H.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
public/images/cards/8S.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
public/images/cards/9C.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
public/images/cards/9D.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
public/images/cards/9H.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
public/images/cards/9S.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
public/images/cards/AC.png
Normal file
|
After Width: | Height: | Size: 6.6 KiB |
BIN
public/images/cards/ACB.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
public/images/cards/AD.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
public/images/cards/ADB.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
public/images/cards/AH.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
public/images/cards/AHB.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
public/images/cards/AS.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
public/images/cards/ASB.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
public/images/cards/JC.png
Normal file
|
After Width: | Height: | Size: 68 KiB |
BIN
public/images/cards/JD.png
Normal file
|
After Width: | Height: | Size: 72 KiB |
BIN
public/images/cards/JH.png
Normal file
|
After Width: | Height: | Size: 66 KiB |
BIN
public/images/cards/JS.png
Normal file
|
After Width: | Height: | Size: 67 KiB |
BIN
public/images/cards/KC.png
Normal file
|
After Width: | Height: | Size: 60 KiB |
BIN
public/images/cards/KD.png
Normal file
|
After Width: | Height: | Size: 61 KiB |
BIN
public/images/cards/KH.png
Normal file
|
After Width: | Height: | Size: 68 KiB |
BIN
public/images/cards/KS.png
Normal file
|
After Width: | Height: | Size: 68 KiB |
BIN
public/images/cards/QC.png
Normal file
|
After Width: | Height: | Size: 64 KiB |
BIN
public/images/cards/QD.png
Normal file
|
After Width: | Height: | Size: 73 KiB |
BIN
public/images/cards/QH.png
Normal file
|
After Width: | Height: | Size: 73 KiB |
BIN
public/images/cards/QS.png
Normal file
|
After Width: | Height: | Size: 72 KiB |
BIN
public/images/cards/TC.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
public/images/cards/TD.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
public/images/cards/TH.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
public/images/cards/TS.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
62
src/components/Ingame.vue
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
import {useIngame} from "@/composables/useIngame.ts";
|
||||||
|
import type {GameInfo} from "@/types/GameTypes.ts";
|
||||||
|
import HandC from "@/components/ingame/HandC.vue";
|
||||||
|
import GameInfoC from "@/components/ingame/GameInfoC.vue";
|
||||||
|
import PlayedCardsC from "@/components/ingame/PlayedCardsC.vue";
|
||||||
|
import ScoreboardC from "@/components/ingame/ScoreboardC.vue";
|
||||||
|
import TurnC from "@/components/ingame/TurnC.vue";
|
||||||
|
|
||||||
|
const ig = useIngame()
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<q-page class="game-field-background vh-100 ingame-side-shadow">
|
||||||
|
<div class="py-5 container-xxl">
|
||||||
|
|
||||||
|
<q-row class="q-gutter-md q-mx-md">
|
||||||
|
<q-col cols="4" class="mt-5 text-start">
|
||||||
|
<TurnC v-if="(ig.data as GameInfo)?.playerQueue" :queue="(ig.data as GameInfo).playerQueue!"/>
|
||||||
|
</q-col>
|
||||||
|
|
||||||
|
<q-col cols="4" class="text-center">
|
||||||
|
<ScoreboardC v-if="(ig.data as GameInfo)?.currentRound" :current-round="(ig.data as GameInfo).currentRound!" />
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-center g-3 mb-5">
|
||||||
|
<PlayedCardsC v-if="(ig.data as GameInfo)?.currentTrick" :trick="(ig.data as GameInfo).currentTrick!" />
|
||||||
|
</div>
|
||||||
|
</q-col>
|
||||||
|
|
||||||
|
|
||||||
|
<q-col cols="4" class="mt-5 text-end">
|
||||||
|
<GameInfoC v-if="(ig.data as GameInfo)?.currentRound"
|
||||||
|
:first-card="(ig.data as GameInfo).currentTrick?.firstCard ?? null"
|
||||||
|
:trumpsuit="(ig.data as GameInfo).currentRound!.trumpSuit"/>
|
||||||
|
</q-col>
|
||||||
|
</q-row>
|
||||||
|
|
||||||
|
<q-row justify="center" class="q-gutter-sm mt-4 bottom-div" style="backdrop-filter: blur(4px); margin-left: 0; margin-right: 0;">
|
||||||
|
<q-col cols="12" class="flex justify-center">
|
||||||
|
<HandC v-if="(ig.data as GameInfo)?.hand && (ig.data as GameInfo)?.self" :hand="(ig.data as GameInfo).hand!" :self="(ig.data as GameInfo).self"/>
|
||||||
|
</q-col>
|
||||||
|
</q-row>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</q-page>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.game-field-background {
|
||||||
|
background-image: var(--body-background-color);
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: cover;
|
||||||
|
max-width: 1400px;
|
||||||
|
margin: 0 auto;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
.ingame-side-shadow {
|
||||||
|
box-shadow: 0 1px 15px 0 #000000
|
||||||
|
}
|
||||||
|
</style>
|
||||||
81
src/components/User.vue
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { useUserInfo } from "@/composables/useUserInfo.ts";
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
import {useQuasar} from "quasar";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
const api = window?.__RUNTIME_CONFIG__?.API_URL;
|
||||||
|
const $q = useQuasar()
|
||||||
|
let userinfo = useUserInfo();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const handleLogoff = () => {
|
||||||
|
|
||||||
|
axios.post(`${api}/logout`, {}, {withCredentials: true}).then((response) => {
|
||||||
|
const responseData = response.data
|
||||||
|
console.log("Response" + responseData.status)
|
||||||
|
$q.notify({
|
||||||
|
message: `You successfully logged out!`,
|
||||||
|
color: 'green-6',
|
||||||
|
icon: 'check_circle',
|
||||||
|
position: 'top'
|
||||||
|
});
|
||||||
|
router.push({ name: 'login' });
|
||||||
|
}).catch((err) => {
|
||||||
|
console.log("ERROR:" + err)
|
||||||
|
$q.notify({
|
||||||
|
message: `Something went wrong`,
|
||||||
|
color: 'red-6',
|
||||||
|
icon: 'cancel',
|
||||||
|
position: 'top'
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="row items-center q-gutter-x-md">
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="userinfo.username"
|
||||||
|
class="text-body1 text-weight-medium row items-center q-gutter-x-sm cursor-pointer relative-position"
|
||||||
|
>
|
||||||
|
<div id="user-menu-target" class="row items-center q-gutter-x-sm" style="min-width: 150px">
|
||||||
|
<q-icon name="account_circle" size="md" />
|
||||||
|
<span>{{ userinfo.username }}</span>
|
||||||
|
<q-icon name="arrow_drop_down" size="sm" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<q-menu
|
||||||
|
target="#user-menu-target"
|
||||||
|
anchor="bottom right"
|
||||||
|
self="top right"
|
||||||
|
>
|
||||||
|
<q-list style="max-width: 150px" class="bg-dark">
|
||||||
|
<q-item
|
||||||
|
clickable
|
||||||
|
v-close-popup
|
||||||
|
@click="handleLogoff"
|
||||||
|
class="text-negative"
|
||||||
|
>
|
||||||
|
<q-item-section avatar>
|
||||||
|
<q-icon name="logout" color="negative" />
|
||||||
|
</q-item-section>
|
||||||
|
<q-item-section>Log Off</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
|
</q-menu>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else class="text-caption text-grey-4">
|
||||||
|
Not Logged In
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<style scoped>
|
||||||
|
#user-menu-target:hover {
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
57
src/components/ingame/GameInfoC.vue
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type {Card} from "@/types/GameSubTypes.ts";
|
||||||
|
import {computed, toRefs} from "vue";
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
trumpsuit: Card
|
||||||
|
firstCard: Card | null
|
||||||
|
}>()
|
||||||
|
const {trumpsuit, firstCard} = toRefs(props)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const trumpName = computed(() => {
|
||||||
|
switch (trumpsuit.value.path.charAt(trumpsuit.value.path.length - 1)) {
|
||||||
|
case 'S':
|
||||||
|
return 'Spades'
|
||||||
|
case 'H':
|
||||||
|
return 'Hearts'
|
||||||
|
case 'D':
|
||||||
|
return 'Diamonds'
|
||||||
|
case 'C':
|
||||||
|
return 'Clubs'
|
||||||
|
default:
|
||||||
|
return 'Unknown'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div class="q-mb-sm">
|
||||||
|
<div class="text-h6 q-mb-xs q-font-medium">Trumpsuit</div>
|
||||||
|
<div id="trumpsuit" class="text-h5 text-primary">{{ trumpName }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="q-mt-md">
|
||||||
|
<div class="text-subtitle1 q-mb-xs q-font-medium">First Card</div>
|
||||||
|
<div id="first-card-container" class="q-pa-sm bg-grey-2 rounded shadow-2"
|
||||||
|
style="display:inline-block;">
|
||||||
|
<q-img v-if="firstCard" :src="firstCard.path" alt="First Card" class="firstbox"
|
||||||
|
style="width: 80px; border-radius: 6px;"/>
|
||||||
|
<div v-else class="q-pa-sm"
|
||||||
|
style="width: 80px; height: 120px; display:flex; align-items:center; justify-content:center; border-radius:6px; background: #ffffff; color: #666;">
|
||||||
|
No image
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.firstbox {
|
||||||
|
width: 80px;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
129
src/components/ingame/HandC.vue
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import {toRefs} from 'vue'
|
||||||
|
import type {Hand, Player} from "@/types/GameSubTypes.ts";
|
||||||
|
import {useWebSocket} from "@/composables/useWebsocket.ts";
|
||||||
|
|
||||||
|
const wb = useWebSocket()
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
hand: Hand
|
||||||
|
isHandInactive?: boolean
|
||||||
|
self: Player | null
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const { hand, isHandInactive, self } = toRefs(props)
|
||||||
|
|
||||||
|
function handlePlayCard(element: any, index: number | null) {
|
||||||
|
if (index === null) return
|
||||||
|
if (isHandInactive?.value) return
|
||||||
|
isHandInactive.value = true
|
||||||
|
|
||||||
|
const wiggleKeyframes = [
|
||||||
|
{ transform: 'translateX(0)' },
|
||||||
|
{ transform: 'translateX(-5px)' },
|
||||||
|
{ transform: 'translateX(5px)' },
|
||||||
|
{ transform: 'translateX(-5px)' },
|
||||||
|
{ transform: 'translateX(0)' }
|
||||||
|
];
|
||||||
|
|
||||||
|
const wiggleTiming = {
|
||||||
|
duration: 400,
|
||||||
|
iterations: 1,
|
||||||
|
easing: 'ease-in-out',
|
||||||
|
fill: 'forwards'
|
||||||
|
};
|
||||||
|
|
||||||
|
wb.sendAndWait("PlayCard", { cardindex: index })
|
||||||
|
.catch(() => {
|
||||||
|
element.animate(wiggleKeyframes, wiggleTiming);
|
||||||
|
isHandInactive.value = false;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSkipDogLife() {
|
||||||
|
//TODO: Add some animation or feedback for skipping turn
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCardImagePath(cardPath: string) {
|
||||||
|
if (!cardPath) return ''
|
||||||
|
if (cardPath.includes('://') || cardPath.startsWith('/')) return cardPath
|
||||||
|
return `/${cardPath}`
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="bottom-div hand-container">
|
||||||
|
<div id="card-slide" :class="'ingame-cards-slide ' + (isHandInactive ? 'inactive' : '' )">
|
||||||
|
<div class="cards-row">
|
||||||
|
<div v-for="card in hand.cards" :key="card.identifier" class="handcard">
|
||||||
|
<div class="card-btn" @click="handlePlayCard(this, card.idx)" aria-label="Play card">
|
||||||
|
<q-img :src="getCardImagePath(card.path)" :alt="card.identifier" class="card" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="self?.dogLife" class="dog-actions">
|
||||||
|
<q-btn color="negative" label="Skip Turn" @click="handleSkipDogLife" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.bottom-div {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
max-width: 1400px;
|
||||||
|
width: 100%;
|
||||||
|
margin: 0;
|
||||||
|
text-align: center;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
.hand-container {
|
||||||
|
margin-left: 0;
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
.ingame-cards-slide {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
.cards-row {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: nowrap;
|
||||||
|
gap: 8px;
|
||||||
|
align-items: flex-end;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
.handcard {
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
.card-btn {
|
||||||
|
padding: 0;
|
||||||
|
min-width: 0;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
.inactive {
|
||||||
|
opacity: 0.6;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
.dog-actions {
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
.handcard :hover {
|
||||||
|
box-shadow: 3px 3px 3px #000000;
|
||||||
|
}
|
||||||
|
.card {
|
||||||
|
width:120px;
|
||||||
|
border-radius:6px
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-height: 500px) {
|
||||||
|
.card {
|
||||||
|
width: 80px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
43
src/components/ingame/PlayedCardsC.vue
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import {computed, defineProps, toRefs} from 'vue'
|
||||||
|
import type {Trick} from "@/types/GameSubTypes.ts";
|
||||||
|
const props = defineProps<{ trick: Trick }>()
|
||||||
|
|
||||||
|
const {trick } = toRefs(props)
|
||||||
|
|
||||||
|
const playedCards = computed(() => {
|
||||||
|
return [...trick.value.cards].map(card => {
|
||||||
|
return {
|
||||||
|
cardId: card[1].path,
|
||||||
|
player: card[0].name
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
function getCardImagePath(cardPath: string) {
|
||||||
|
if (!cardPath) return ''
|
||||||
|
if (cardPath.includes('://') || cardPath.startsWith('/')) return cardPath
|
||||||
|
return `/${cardPath}`
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="row items-center justify-center q-gutter-sm" id="trick-cards-content">
|
||||||
|
<div v-for="(play, index) in playedCards" :key="index" class="col-auto">
|
||||||
|
<q-card flat class="bg-transparent trick-card" style="width: 7rem; backdrop-filter: blur(4px);">
|
||||||
|
<q-card-section class="q-pa-sm q-pb-xs">
|
||||||
|
<q-img :src="getCardImagePath(play.cardId)" alt="card" style="border-radius: 6px; width:100%" />
|
||||||
|
</q-card-section>
|
||||||
|
<q-card-section class="q-pa-sm q-pt-xs text-center bg-transparent">
|
||||||
|
<div class="text-subtitle2 text-grey-7">{{ play.player }}</div>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.trick-card {
|
||||||
|
box-shadow: 0 1px 6px rgba(0,0,0,0.08);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
38
src/components/ingame/TurnC.vue
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import type {PlayerQueue} from "@/types/GameSubTypes.ts";
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
queue: PlayerQueue
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const safeNextPlayers = computed(() => props.queue.players ?? [])
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<q-card flat class="turn-tracker-container q-pa-md">
|
||||||
|
<q-card-section>
|
||||||
|
<div class="text-subtitle2 q-mb-xs">Current Player</div>
|
||||||
|
<div id="current-player-name" class="text-h6 text-weight-bold text-positive">{{
|
||||||
|
props.queue.currentPlayer?.name
|
||||||
|
}}</div>
|
||||||
|
|
||||||
|
<div v-if="safeNextPlayers.length > 0" class="q-mt-md">
|
||||||
|
<div id="next-players-text" class="text-subtitle2 q-mb-xs">Next Players</div>
|
||||||
|
<q-list id="next-players-container" dense>
|
||||||
|
<q-item v-for="player in safeNextPlayers" :key="player.id">
|
||||||
|
<q-item-section>
|
||||||
|
<div class="text-body1 text-primary">{{ player.name }}</div>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
|
</div>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.turn-tracker-container {
|
||||||
|
max-width: 320px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
125
src/components/lobby/LobbyComponent.vue
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type {LobbyInfo} from "@/types/GameTypes.ts";
|
||||||
|
import type {User} from "@/types/GameSubTypes.ts";
|
||||||
|
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
lobbyInfo: LobbyInfo
|
||||||
|
}>()
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'kick-player', user: User): void;
|
||||||
|
(e: 'start-game'): void;
|
||||||
|
(e: 'leave-game', user: User): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const isHost = props.lobbyInfo.self.host;
|
||||||
|
|
||||||
|
const players = props.lobbyInfo.users;
|
||||||
|
|
||||||
|
const lobbyName = `${props.lobbyInfo.gameId}`;
|
||||||
|
|
||||||
|
const handleKickPlayer = (user: User) => {
|
||||||
|
if (isHost) {
|
||||||
|
emit('kick-player', user);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleStartGame = () => {
|
||||||
|
if (isHost) {
|
||||||
|
emit('start-game');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleLeaveGame = (user: User) => {
|
||||||
|
emit('leave-game', user);
|
||||||
|
};
|
||||||
|
const profileIcon = 'person';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
|
||||||
|
<div class="row q-pa-md items-center">
|
||||||
|
<div class="col text-center text-h4 text-weight-medium">
|
||||||
|
Lobby Name: {{ lobbyName }} </div>
|
||||||
|
<q-btn
|
||||||
|
color="negative"
|
||||||
|
label="Exit"
|
||||||
|
@click="handleLeaveGame(props.lobbyInfo.self)"
|
||||||
|
class="q-ml-auto"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row q-pb-md">
|
||||||
|
<div class="col text-center text-subtitle1">
|
||||||
|
Players: {{ players.length }} / {{ props.lobbyInfo.maxPlayers }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row justify-center items-center flex-grow-1 q-px-md">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="row justify-center q-gutter-md">
|
||||||
|
<div v-for="player in players" :key="player.id" class="col-auto">
|
||||||
|
<q-card class="bg-dark q-pa-md text-center" style="width: 250px;">
|
||||||
|
|
||||||
|
<q-avatar size="80px" color="primary" text-color="white" :icon="profileIcon" class="q-mb-sm" />
|
||||||
|
|
||||||
|
<q-card-section>
|
||||||
|
<div class="text-h6">
|
||||||
|
{{ player.username }} <q-badge v-if="player.id === props.lobbyInfo.self.id" color="orange" align="middle" class="q-ml-xs">
|
||||||
|
(You)
|
||||||
|
</q-badge>
|
||||||
|
<q-badge v-else-if="player.host" color="blue" align="middle" class="q-ml-xs">
|
||||||
|
(Host)
|
||||||
|
</q-badge>
|
||||||
|
</div>
|
||||||
|
</q-card-section>
|
||||||
|
|
||||||
|
<q-card-actions align="center" v-if="isHost">
|
||||||
|
<q-btn
|
||||||
|
v-if="player.id !== props.lobbyInfo.self.id"
|
||||||
|
color="negative"
|
||||||
|
label="Remove"
|
||||||
|
@click="handleKickPlayer(props.lobbyInfo.self)"
|
||||||
|
class="full-width"
|
||||||
|
/>
|
||||||
|
<q-btn
|
||||||
|
v-else
|
||||||
|
color="negative"
|
||||||
|
label="Remove (Cannot Kick Self)"
|
||||||
|
disable
|
||||||
|
class="full-width"
|
||||||
|
/>
|
||||||
|
</q-card-actions>
|
||||||
|
|
||||||
|
</q-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row q-py-lg text-center">
|
||||||
|
<div class="col-12">
|
||||||
|
<template v-if="isHost">
|
||||||
|
<q-btn
|
||||||
|
color="positive"
|
||||||
|
label="Start Game"
|
||||||
|
size="lg"
|
||||||
|
@click="handleStartGame"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<div class="text-h6 q-mb-sm">
|
||||||
|
Waiting for the host to start the game...
|
||||||
|
</div>
|
||||||
|
<q-spinner
|
||||||
|
color="primary"
|
||||||
|
size="3em"
|
||||||
|
:thickness="2"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
</style>
|
||||||
29
src/composables/useIngame.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import { defineStore } from 'pinia'
|
||||||
|
import {ref, type Ref} from 'vue'
|
||||||
|
import type {GameInfo, LobbyInfo, TieInfo, TrumpInfo, WonInfo} from "@/types/GameTypes.ts";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
function setIngame(newState: 'Lobby' | 'InGame' | 'SelectTrump' | 'TieBreak' | 'FinishedMatch', newData: GameInfo | LobbyInfo | TieInfo | TrumpInfo | WonInfo) {
|
||||||
|
state.value = newState;
|
||||||
|
data.value = newData;
|
||||||
|
}
|
||||||
|
|
||||||
|
function requestGame(gameId: string) {
|
||||||
|
axios.get(`${api}/status/${gameId}`, {withCredentials: true}).then((response) => {
|
||||||
|
setIngame(response.data.state, response.data.data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearIngame() {
|
||||||
|
state.value = null;
|
||||||
|
data.value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { state, data, requestGame, setIngame, clearIngame };
|
||||||
|
});
|
||||||
@@ -1,19 +1,41 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import {ref, type Ref} from 'vue'
|
import {ref, type Ref} from 'vue'
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
const api = window?.__RUNTIME_CONFIG__?.API_URL;
|
||||||
|
|
||||||
export const useUserInfo = defineStore('userInfo', () => {
|
export const useUserInfo = defineStore('userInfo', () => {
|
||||||
const username: Ref<string | null> = ref(null);
|
const username: Ref<string | null> = ref(null);
|
||||||
const userId: Ref<number | null> = ref(null);
|
const userId: Ref<number | null> = ref(null);
|
||||||
|
const gameId: Ref<string | null> = ref(null);
|
||||||
|
|
||||||
function setUserInfo(name: string, id: number) {
|
function setUserInfo(name: string, id: number) {
|
||||||
username.value = name;
|
username.value = name;
|
||||||
userId.value = id;
|
userId.value = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setGameId(id: string) {
|
||||||
|
gameId.value = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
function requestState() {
|
||||||
|
axios.get(`${api}/status`, {withCredentials: true}).then((response) => {
|
||||||
|
console.log("STATUS DATA:" + response.data.status + response.data.inGame)
|
||||||
|
username.value = response.data.username;
|
||||||
|
if (response.data.ingame) {
|
||||||
|
gameId.value = response.data.gameId;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function clearUserInfo() {
|
function clearUserInfo() {
|
||||||
username.value = null;
|
username.value = null;
|
||||||
userId.value = null;
|
userId.value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return { username, userId, setUserInfo, clearUserInfo };
|
function clearGameId() {
|
||||||
|
gameId.value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { username, userId, gameId, setUserInfo, requestState, clearUserInfo, setGameId, clearGameId };
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,8 +6,13 @@ import {
|
|||||||
sendEventAndWait,
|
sendEventAndWait,
|
||||||
onEvent,
|
onEvent,
|
||||||
isWebSocketConnected,
|
isWebSocketConnected,
|
||||||
|
setDefaultHandler,
|
||||||
} from "@/services/ws";
|
} from "@/services/ws";
|
||||||
|
|
||||||
|
function defaultEventHandler<T = any>(data: (data: T) => void) {
|
||||||
|
setDefaultHandler(data);
|
||||||
|
}
|
||||||
|
|
||||||
export function useWebSocket() {
|
export function useWebSocket() {
|
||||||
const isConnected = ref(isWebSocketConnected());
|
const isConnected = ref(isWebSocketConnected());
|
||||||
const lastMessage = ref<any>(null);
|
const lastMessage = ref<any>(null);
|
||||||
@@ -51,5 +56,6 @@ export function useWebSocket() {
|
|||||||
sendAndWait: sendEventAndWait,
|
sendAndWait: sendEventAndWait,
|
||||||
|
|
||||||
useEvent,
|
useEvent,
|
||||||
|
defaultEventHandler
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,15 @@ import { createPinia } from 'pinia'
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import VueAxios from 'vue-axios'
|
import VueAxios from 'vue-axios'
|
||||||
import {useUserInfo} from "@/composables/useUserInfo.ts";
|
import {useUserInfo} from "@/composables/useUserInfo.ts";
|
||||||
|
import {useIngame} from "@/composables/useIngame.ts";
|
||||||
|
import {initWebSocket} from "@/services/ws.ts";
|
||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
const pinia = createPinia()
|
const pinia = createPinia()
|
||||||
|
|
||||||
app.use(pinia)
|
app.use(pinia)
|
||||||
|
const ingameStore = useIngame();
|
||||||
|
initWebSocket(ingameStore)
|
||||||
app.use(router)
|
app.use(router)
|
||||||
app.use(Quasar, {
|
app.use(Quasar, {
|
||||||
plugins: {
|
plugins: {
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ import defaultMenu from "../components/DefaultMenu.vue"
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { useUserInfo } from "@/composables/useUserInfo";
|
import { useUserInfo } from "@/composables/useUserInfo";
|
||||||
import rulesView from "../components/Rules.vue";
|
import rulesView from "../components/Rules.vue";
|
||||||
|
import LobbyView from "@/views/LobbyView.vue";
|
||||||
|
import GameView from "@/views/Game.vue"
|
||||||
const api = window?.__RUNTIME_CONFIG__?.API_URL;
|
const api = window?.__RUNTIME_CONFIG__?.API_URL;
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
@@ -50,6 +51,12 @@ const router = createRouter({
|
|||||||
component: LoginView,
|
component: LoginView,
|
||||||
meta: { requiresAuth: false }
|
meta: { requiresAuth: false }
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/lobby',
|
||||||
|
name: 'lobby',
|
||||||
|
component: LobbyView,
|
||||||
|
meta: {requiresAuth: true }
|
||||||
|
}
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import {useIngame} from "@/composables/useIngame.ts";
|
||||||
|
import type {GameInfo, LobbyInfo, TieInfo, TrumpInfo, WonInfo} from "@/types/GameTypes.ts";
|
||||||
|
|
||||||
const api = window.__RUNTIME_CONFIG__?.API_URL;
|
const api = window.__RUNTIME_CONFIG__?.API_URL;
|
||||||
|
|
||||||
// ---------- Types ---------------------------------------------------------
|
// ---------- Types ---------------------------------------------------------
|
||||||
@@ -6,6 +9,8 @@ export type ServerMessage<T = any> = {
|
|||||||
id?: string;
|
id?: string;
|
||||||
event?: string;
|
event?: string;
|
||||||
status?: "success" | "error";
|
status?: "success" | "error";
|
||||||
|
state?: "Lobby" | "InGame" | "SelectTrump" | "TieBreak" | "FinishedMatch";
|
||||||
|
stateData?: GameInfo | LobbyInfo | TieInfo | TrumpInfo | WonInfo;
|
||||||
data?: T;
|
data?: T;
|
||||||
error?: string;
|
error?: string;
|
||||||
};
|
};
|
||||||
@@ -28,9 +33,15 @@ let ws: WebSocket | null = null;
|
|||||||
|
|
||||||
const pending = new Map<string, PendingEntry>();
|
const pending = new Map<string, PendingEntry>();
|
||||||
const handlers = new Map<string, HandlerFn>();
|
const handlers = new Map<string, HandlerFn>();
|
||||||
|
let uState: ReturnType<typeof useIngame> | null = null;
|
||||||
|
|
||||||
let heartbeatTimer: ReturnType<typeof setInterval> | null = null;
|
let heartbeatTimer: ReturnType<typeof setInterval> | null = null;
|
||||||
|
|
||||||
|
export function initWebSocket(ingameStore: ReturnType<typeof useIngame>) {
|
||||||
|
uState = ingameStore;
|
||||||
|
}
|
||||||
|
let defaultHandler: HandlerFn | null = null;
|
||||||
|
|
||||||
function uuid(): string {
|
function uuid(): string {
|
||||||
return crypto.randomUUID();
|
return crypto.randomUUID();
|
||||||
}
|
}
|
||||||
@@ -62,6 +73,10 @@ function stopHeartbeat() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setupSocketHandlers(socket: WebSocket) {
|
function setupSocketHandlers(socket: WebSocket) {
|
||||||
|
if (!uState) {
|
||||||
|
console.error("[WS] WebSocket module not initialized with Pinia store!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
socket.onmessage = async (raw) => {
|
socket.onmessage = async (raw) => {
|
||||||
console.debug("[WS] MESSAGE:", raw.data);
|
console.debug("[WS] MESSAGE:", raw.data);
|
||||||
|
|
||||||
@@ -73,7 +88,7 @@ function setupSocketHandlers(socket: WebSocket) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { id, event, status, data } = msg;
|
const { id, event, state, stateData, status, data } = msg;
|
||||||
|
|
||||||
// RPC response branch
|
// RPC response branch
|
||||||
if (id && status) {
|
if (id && status) {
|
||||||
@@ -91,6 +106,12 @@ function setupSocketHandlers(socket: WebSocket) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state && stateData) {
|
||||||
|
if(uState) {
|
||||||
|
uState.setIngame(state, stateData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Server event → handler branch
|
// Server event → handler branch
|
||||||
if (id && event) {
|
if (id && event) {
|
||||||
const handler = handlers.get(event);
|
const handler = handlers.get(event);
|
||||||
@@ -103,7 +124,17 @@ function setupSocketHandlers(socket: WebSocket) {
|
|||||||
|
|
||||||
if (!handler) {
|
if (!handler) {
|
||||||
console.warn("[WS] No handler for event:", event);
|
console.warn("[WS] No handler for event:", event);
|
||||||
reply("error", `No handler for '${event}'`);
|
if (defaultHandler) {
|
||||||
|
try {
|
||||||
|
await defaultHandler(data ?? {});
|
||||||
|
reply("success");
|
||||||
|
} catch (err) {
|
||||||
|
reply("error", (err as Error).message);
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
reply("error", `No handler for '${event}'`);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,5 +263,9 @@ export function onEvent(event: string, handler: HandlerFn) {
|
|||||||
handlers.set(event, handler);
|
handlers.set(event, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setDefaultHandler(handler: HandlerFn) {
|
||||||
|
defaultHandler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
export const isWebSocketConnected = () =>
|
export const isWebSocketConnected = () =>
|
||||||
!!ws && ws.readyState === WebSocket.OPEN;
|
!!ws && ws.readyState === WebSocket.OPEN;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ type Hand = {
|
|||||||
type Player = {
|
type Player = {
|
||||||
id: string
|
id: string
|
||||||
name: string
|
name: string
|
||||||
dogLife: string
|
dogLife: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
type PlayerQueue = {
|
type PlayerQueue = {
|
||||||
@@ -34,7 +34,7 @@ type Round = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Trick = {
|
type Trick = {
|
||||||
cards: { [player: string]: Card }
|
cards: Map<Player, Card>
|
||||||
firstCard: Card | null
|
firstCard: Card | null
|
||||||
winner: Player | null
|
winner: Player | null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,30 +2,36 @@
|
|||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { useQuasar } from 'quasar';
|
import { useQuasar } from 'quasar';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
const api = window?.__RUNTIME_CONFIG__?.API_URL;
|
||||||
const lobbyName = ref('');
|
const lobbyName = ref('');
|
||||||
const isPublic = ref(false);
|
const isPublic = ref(false);
|
||||||
const playerAmount = ref(2);
|
const playerAmount = ref(2);
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
|
|
||||||
const createGameQuasar = async () => {
|
const createGameQuasar = async () => {
|
||||||
if (!lobbyName.value) {
|
if (!lobbyName.value) {
|
||||||
$q.notify({ message: 'Lobby-Name wird benötigt', color: 'red', position: 'top', icon: 'cancel' });
|
$q.notify({ message: 'Lobby-Name wird benötigt', color: 'red', position: 'top', icon: 'cancel' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
//TODO: Implement Logic to Create the Game and Redirect to Lobby
|
axios.post(`${api}/createGame`, {lobbyname: lobbyName.value, playeramount: playerAmount.value.toString()}, {withCredentials: true}).then((response) => {
|
||||||
await delay(3000)
|
const responseData = response.data
|
||||||
isLoading.value = false;
|
console.log("Response" + responseData.status)
|
||||||
$q.notify({
|
$q.notify({
|
||||||
message: `Lobby "${lobbyName.value}" erfolgreich erstellt!`,
|
message: `Lobby "${lobbyName.value}" erfolgreich erstellt mit gameId ${responseData.gameId}!`,
|
||||||
color: 'green-6',
|
color: 'green-6',
|
||||||
icon: 'check_circle',
|
icon: 'check_circle',
|
||||||
position: 'top'
|
position: 'top'
|
||||||
});
|
});
|
||||||
router.push({ name: 'mainmenu'});
|
router.push("/lobby")
|
||||||
|
}).catch((err) => {
|
||||||
|
console.log("ERROR:" + err)
|
||||||
|
}).finally(() =>
|
||||||
|
isLoading.value = false
|
||||||
|
)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
33
src/views/Game.vue
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {useWebSocket} from "@/composables/useWebsocket.ts";
|
||||||
|
import {useIngame} from "@/composables/useIngame.ts";
|
||||||
|
import Ingame from "@/components/Ingame.vue";
|
||||||
|
import {useUserInfo} from "@/composables/useUserInfo.ts";
|
||||||
|
import router from "@/router";
|
||||||
|
|
||||||
|
const wb = useWebSocket()
|
||||||
|
const ig = useIngame()
|
||||||
|
const ui = useUserInfo()
|
||||||
|
|
||||||
|
ui.requestState()
|
||||||
|
if (ui.gameId) {
|
||||||
|
ig.requestGame(ui.gameId)
|
||||||
|
wb.connect()
|
||||||
|
} else {
|
||||||
|
router.replace("/")
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="lobby-background">
|
||||||
|
<Ingame v-if="ig.state === 'InGame'" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.lobby-background {
|
||||||
|
background-color: var(--body-background-color);
|
||||||
|
width: 100%;
|
||||||
|
min-height:100vh;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -2,27 +2,37 @@
|
|||||||
import {ref} from "vue";
|
import {ref} from "vue";
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import {useQuasar} from "quasar";
|
import {useQuasar} from "quasar";
|
||||||
|
import axios from "axios";
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const lobbyCode = ref('');
|
const lobbyCode = ref('');
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
|
const api = window?.__RUNTIME_CONFIG__?.API_URL;
|
||||||
const startGameQuasar = async() => {
|
const startGameQuasar = async() => {
|
||||||
if (!lobbyCode.value) {
|
if (!lobbyCode.value) {
|
||||||
$q.notify({ message: 'Lobby-Name wird benötigt', color: 'red', position: 'top', icon: 'cancel' });
|
$q.notify({ message: 'Lobby-Name wird benötigt', color: 'red', position: 'top', icon: 'cancel' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
//TODO: Implement Logic to Start the Game and Redirect to Ingame
|
axios.post(`${api}/joinGame`, {gameId: lobbyCode.value.toString()}, {withCredentials: true}).then(response => {
|
||||||
await delay(3000)
|
const responseData = response.data
|
||||||
isLoading.value = false;
|
$q.notify({
|
||||||
$q.notify({
|
message: `Lobby "${lobbyCode.value}" erfolgreich gefunden`,
|
||||||
message: `Lobby "${lobbyCode.value}" erfolgreich gefunden`,
|
color: 'green-6',
|
||||||
color: 'green-6',
|
icon: 'check_circle',
|
||||||
icon: 'check_circle',
|
position: 'top'
|
||||||
position: 'top'
|
});
|
||||||
});
|
router.push("/lobby")
|
||||||
router.push({ name: 'mainmenu'});
|
}).catch(() => {
|
||||||
|
$q.notify({
|
||||||
|
message: `Lobby "${lobbyCode.value}" nicht gefunden`,
|
||||||
|
color: 'red-6',
|
||||||
|
icon: 'cancel',
|
||||||
|
position: 'top'
|
||||||
|
})
|
||||||
|
}).finally(() =>
|
||||||
|
isLoading.value = false
|
||||||
|
)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
53
src/views/LobbyView.vue
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {computed, ref} from 'vue';
|
||||||
|
import LobbyComponent from '../components/lobby/LobbyComponent.vue';
|
||||||
|
import type {LobbyInfo} from "@/types/GameTypes.ts";
|
||||||
|
import type {User} from "@/types/GameSubTypes.ts";
|
||||||
|
import {useIngame} from "@/composables/useIngame.ts";
|
||||||
|
import {sendEvent} from "@/services/ws.ts";
|
||||||
|
|
||||||
|
const ig = useIngame()
|
||||||
|
|
||||||
|
const lobbyInfo = computed<LobbyInfo | null>(() => {
|
||||||
|
if (ig.state === 'Lobby' && ig.data) {
|
||||||
|
return ig.data as LobbyInfo;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleKickPlayer = (user: User) => {
|
||||||
|
sendEvent("KickEvent", {
|
||||||
|
user: user
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleStartGame = () => {
|
||||||
|
//TODO: Implement start game
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleLeaveGame = (user: User) => {
|
||||||
|
sendEvent("LeftEvent",{
|
||||||
|
user: user
|
||||||
|
})
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<q-layout>
|
||||||
|
<q-page-container>
|
||||||
|
<q-page class="vh-100 column">
|
||||||
|
<lobby-component
|
||||||
|
v-if="lobbyInfo"
|
||||||
|
:lobbyInfo="lobbyInfo"
|
||||||
|
@kick-player="handleKickPlayer"
|
||||||
|
@start-game="handleStartGame"
|
||||||
|
@leave-game="handleLeaveGame"
|
||||||
|
/>
|
||||||
|
</q-page>
|
||||||
|
</q-page-container>
|
||||||
|
</q-layout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -80,7 +80,7 @@ const onSubmit = () => {
|
|||||||
loginError.value = ''
|
loginError.value = ''
|
||||||
axios.post(`${api}/login`, {username: username.value, password: password.value}, {withCredentials: true}).then((response) => {
|
axios.post(`${api}/login`, {username: username.value, password: password.value}, {withCredentials: true}).then((response) => {
|
||||||
uInfo.setUserInfo(response.data.user.username, response.data.user.id)
|
uInfo.setUserInfo(response.data.user.username, response.data.user.id)
|
||||||
router.push("/")
|
router.push("/mainmenu")
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
loginError.value = 'Invalid username or password'
|
loginError.value = 'Invalid username or password'
|
||||||
}).finally(() =>
|
}).finally(() =>
|
||||||
|
|||||||
@@ -1,18 +1,24 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import MainMenuBoxes from "@/components/MainMenuBoxes.vue";
|
import UserStatusArea from '../components/User.vue'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<q-layout view="hHh lpR fFf" class="font-roboto">
|
<q-layout view="hHh lpR fFf" class="font-roboto">
|
||||||
<q-page-container>
|
<q-header elevated class="bg-dark text-white">
|
||||||
<q-page class="flex justify-start items-center column">
|
<q-toolbar>
|
||||||
|
<q-toolbar-title class="q-ml-md">
|
||||||
|
</q-toolbar-title>
|
||||||
|
|
||||||
<header class="text-center q-mb-xl">
|
<UserStatusArea />
|
||||||
<h1 class="game-title text-white q-my-none">
|
</q-toolbar>
|
||||||
KnockOutWhist
|
</q-header>
|
||||||
</h1>
|
|
||||||
</header>
|
<q-page-container>
|
||||||
<router-view></router-view>
|
<q-page class="flex justify-start items-center column q-pa-md"> <header class="text-center q-mb-xl q-mt-md"> <h1 class="game-title text-white q-my-none">
|
||||||
|
KnockOutWhist
|
||||||
|
</h1>
|
||||||
|
</header>
|
||||||
|
<router-view></router-view>
|
||||||
</q-page>
|
</q-page>
|
||||||
</q-page-container>
|
</q-page-container>
|
||||||
</q-layout>
|
</q-layout>
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
MAJOR=0
|
MAJOR=0
|
||||||
MINOR=5
|
MINOR=12
|
||||||
PATCH=0
|
PATCH=1
|
||||||
|
|||||||