feat(ui): Trumpsuit Component
Added a working trumpsuit component (without animation, not so nice)
This commit is contained in:
@@ -1,15 +1,18 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
||||||
import {useIngame} from "@/composables/useIngame.ts";
|
import {useIngame} from "@/composables/useIngame.ts";
|
||||||
import type {GameInfo} from "@/types/GameTypes.ts";
|
import type {GameInfo, TrumpInfo} from "@/types/GameTypes.ts";
|
||||||
import HandC from "@/components/ingame/HandC.vue";
|
import HandC from "@/components/ingame/HandC.vue";
|
||||||
import GameInfoC from "@/components/ingame/GameInfoC.vue";
|
import GameInfoC from "@/components/ingame/GameInfoC.vue";
|
||||||
import PlayedCardsC from "@/components/ingame/PlayedCardsC.vue";
|
import PlayedCardsC from "@/components/ingame/PlayedCardsC.vue";
|
||||||
import ScoreboardC from "@/components/ingame/ScoreboardC.vue";
|
import ScoreboardC from "@/components/ingame/ScoreboardC.vue";
|
||||||
import TurnC from "@/components/ingame/TurnC.vue";
|
import TurnC from "@/components/ingame/TurnC.vue";
|
||||||
|
import TrumpC from "@/components/ingame/TrumpC.vue";
|
||||||
|
import {storeToRefs} from "pinia";
|
||||||
|
import {toRefs} from "vue";
|
||||||
|
|
||||||
const ig = useIngame()
|
const ig = useIngame()
|
||||||
|
const { state } = toRefs(ig)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -17,7 +20,7 @@ const ig = useIngame()
|
|||||||
<q-page-container>
|
<q-page-container>
|
||||||
<q-page class="game-field-background vh-100 ingame-side-shadow">
|
<q-page class="game-field-background vh-100 ingame-side-shadow">
|
||||||
<div class="py-5 container-xxl">
|
<div class="py-5 container-xxl">
|
||||||
|
<TrumpC v-if="state === 'SelectTrump'" />
|
||||||
<div class="fit row wrap justify-center items-center content-start">
|
<div class="fit row wrap justify-center items-center content-start">
|
||||||
<div class="mt-5 ml-4 self-start col-2">
|
<div class="mt-5 ml-4 self-start col-2">
|
||||||
<TurnC v-if="(ig.data as GameInfo)?.playerQueue" :queue="(ig.data as GameInfo).playerQueue!"/>
|
<TurnC v-if="(ig.data as GameInfo)?.playerQueue" :queue="(ig.data as GameInfo).playerQueue!"/>
|
||||||
|
|||||||
135
src/components/ingame/TrumpC.vue
Normal file
135
src/components/ingame/TrumpC.vue
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
<script setup lang="ts" xmlns="http://www.w3.org/1999/html">
|
||||||
|
console.log("TRUMP WURDE AUFGERUFEN")
|
||||||
|
import {useWebSocket} from "@/composables/useWebsocket.ts";
|
||||||
|
import {useIngame} from "@/composables/useIngame.ts";
|
||||||
|
import type {GameInfo, TrumpInfo} from "@/types/GameTypes.ts";
|
||||||
|
import {useQuasar} from "quasar";
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
const wb = useWebSocket()
|
||||||
|
const wi = useIngame()
|
||||||
|
const trumpInf = wi.data as TrumpInfo
|
||||||
|
const trumpSuits = [
|
||||||
|
"/images/cards/AS.png",
|
||||||
|
"/images/cards/AH.png",
|
||||||
|
"/images/cards/AD.png",
|
||||||
|
"/images/cards/AC.png"
|
||||||
|
]
|
||||||
|
const $q = useQuasar();
|
||||||
|
$q.notify({
|
||||||
|
message: "Bin im Trump",
|
||||||
|
color: "negative",
|
||||||
|
position: "top"
|
||||||
|
})
|
||||||
|
function getCardImagePath(cardPath: string) {
|
||||||
|
if (!cardPath) return ''
|
||||||
|
if (cardPath.includes('://') || cardPath.startsWith('/')) return cardPath
|
||||||
|
return `/${cardPath}`
|
||||||
|
}
|
||||||
|
function selectTrump(trumpSuitIndex: number) {
|
||||||
|
// 1. Notify the user of the selection
|
||||||
|
$q.notify({
|
||||||
|
message: `You selected ${trumpSuitIndex} as the trump suit.`,
|
||||||
|
color: "positive",
|
||||||
|
position: "top"
|
||||||
|
});
|
||||||
|
wb.sendAndWait("PickTrumpsuit", { suitIndex: trumpSuitIndex }).then(
|
||||||
|
$q.notify({
|
||||||
|
message: "You've successfully picked your trumpsuit",
|
||||||
|
color: "positive",
|
||||||
|
position: "top"
|
||||||
|
})
|
||||||
|
|
||||||
|
).catch((error) => {
|
||||||
|
$q.notify({
|
||||||
|
message: error.message,
|
||||||
|
color: "negative",
|
||||||
|
position: "top"
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<q-card v-if="trumpInf.chooser?.name === trumpInf.self?.name" class="player-profile-card q-ma-md q-mx-auto" flat bordered>
|
||||||
|
<q-card-section class="bg-primary text-white text-center q-py-lg">
|
||||||
|
<div class="text-h3 text-weight-bolder">
|
||||||
|
{{ trumpInf.self?.name || "Loading Player..."}}
|
||||||
|
</div>
|
||||||
|
</q-card-section>
|
||||||
|
|
||||||
|
<q-separator />
|
||||||
|
|
||||||
|
<q-card-section class="q-py-md text-center bg-dark">
|
||||||
|
<div class="text-h6 q-mb-sm">Trump Suits</div>
|
||||||
|
<div class="row justify-center q-gutter-sm">
|
||||||
|
<q-card v-for="(path, index) in trumpSuits" :key="index" class="q-pa-xs cursor-pointer">
|
||||||
|
<q-img
|
||||||
|
:src="getCardImagePath(path)"
|
||||||
|
@click="selectTrump(index)"
|
||||||
|
:alt="path"
|
||||||
|
class="card"
|
||||||
|
/>
|
||||||
|
</q-card>
|
||||||
|
</div>
|
||||||
|
</q-card-section>
|
||||||
|
|
||||||
|
<q-separator />
|
||||||
|
|
||||||
|
<q-card-section class="q-pa-md text-center bg-dark">
|
||||||
|
<div class="text-h6 q-mb-sm">Your Hand ({{ trumpInf.selfHand?.cards.length || 0 }} Cards)</div>
|
||||||
|
<div class="row wrap justify-center q-gutter-sm">
|
||||||
|
|
||||||
|
<div v-for="card in trumpInf.selfHand?.cards || []" :key="card.idx!" >
|
||||||
|
<q-img
|
||||||
|
:src="getCardImagePath(card.path)"
|
||||||
|
:alt="card.identifier"
|
||||||
|
class="card"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
|
<q-card
|
||||||
|
v-else
|
||||||
|
class="player-profile-card q-ma-md q-mx-auto text-center"
|
||||||
|
flat
|
||||||
|
bordered
|
||||||
|
style="min-height: 200px; display: flex; flex-direction: column; justify-content: center;"
|
||||||
|
>
|
||||||
|
<q-card-section class="q-pa-lg">
|
||||||
|
<q-spinner-hourglass color="primary" size="3em" class="q-mb-md" />
|
||||||
|
<div class="text-h5 text-grey-8">
|
||||||
|
Waiting for {{ trumpInf.chooser?.name || 'the other player' }} to select the trump suit...
|
||||||
|
</div>
|
||||||
|
</q-card-section>
|
||||||
|
|
||||||
|
<q-separator />
|
||||||
|
<q-card-section class="q-pa-md text-center bg-dark">
|
||||||
|
<div class="text-h6 text-white q-mb-sm">Your Hand ({{ trumpInf.selfHand?.cards.length || 0 }} Cards)</div>
|
||||||
|
<div class="row wrap justify-center q-gutter-sm">
|
||||||
|
|
||||||
|
<div v-for="card in trumpInf.selfHand?.cards || []" :key="card.idx!" >
|
||||||
|
<q-img
|
||||||
|
:src="getCardImagePath(card.path)"
|
||||||
|
:alt="card.identifier"
|
||||||
|
class="card"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</q-card-section>
|
||||||
|
|
||||||
|
</q-card>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.card {
|
||||||
|
width:120px;
|
||||||
|
border-radius:6px
|
||||||
|
}
|
||||||
|
.player-profile-card {
|
||||||
|
max-width: 1000px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -33,7 +33,7 @@ ui.requestState().then(() => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="lobby-background">
|
<div class="lobby-background">
|
||||||
<Ingame v-if="state === 'InGame'"/>
|
<Ingame v-if="state === 'InGame' || state === 'SelectTrump'"/>
|
||||||
<lobby-component v-if="state === 'Lobby'"/>
|
<lobby-component v-if="state === 'Lobby'"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user