feat: FRO-24 Create Played Cards Component (#17)

Reviewed-on: #17
Reviewed-by: lq64 <lq@blackhole.local>
Co-authored-by: Janis <janis.e.20@gmx.de>
Co-committed-by: Janis <janis.e.20@gmx.de>
This commit is contained in:
2025-12-10 16:46:34 +01:00
committed by lq64
parent 0b05cba25f
commit 21db939d34
2 changed files with 44 additions and 1 deletions

View 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>

View File

@@ -34,7 +34,7 @@ type Round = {
}
type Trick = {
cards: { [player: string]: Card }
cards: Map<Player, Card>
firstCard: Card | null
winner: Player | null
}