94 lines
2.7 KiB
Vue
94 lines
2.7 KiB
Vue
<script setup lang="ts">
|
|
const props = defineProps(['game'])
|
|
const self = useState<string>('self')
|
|
const gameObject = useState<{ [key: string]: any }>('gameObject')
|
|
const socket = useState<WebSocket>('socket')
|
|
|
|
const isTurn = computed(() => self.value && props.game?.started && (gameObject.value[self.value]?.team == props.game.turn))
|
|
|
|
async function buy(cardId: string) {
|
|
socket.value.send(JSON.stringify({
|
|
type: "action",
|
|
data_type: "buy",
|
|
data: cardId
|
|
}))
|
|
}
|
|
|
|
async function buy_in_hand(cardId: string) {
|
|
socket.value.send(JSON.stringify({
|
|
type: "temp_action",
|
|
data_type: "buy_in_hand",
|
|
data: cardId
|
|
}))
|
|
}
|
|
|
|
async function buy_on_stack(cardId: string) {
|
|
socket.value.send(JSON.stringify({
|
|
type: "temp_action",
|
|
data_type: "buy_on_stack",
|
|
data: cardId
|
|
}))
|
|
}
|
|
|
|
async function endTurn() {
|
|
socket.value.send(JSON.stringify({
|
|
type: "action",
|
|
data_type: "end_turn",
|
|
data: true
|
|
}))
|
|
}
|
|
|
|
</script>
|
|
|
|
<template>
|
|
|
|
<div>
|
|
<button v-if="isTurn" @click="endTurn">END TURN</button>
|
|
<div v-if="!self"><b>SPECTATOR MODE</b></div>
|
|
<div>
|
|
market_amount = {{ props.game.market_stack?.length }}
|
|
<br>
|
|
market =
|
|
<div class="cards_container">
|
|
|
|
<CardPreview :data="c" v-for="c in props.game.market">
|
|
<template v-if="isTurn && c">
|
|
<button @click="buy(c)">BUY</button>
|
|
<button @click="buy_in_hand(c)">
|
|
BUY IN HAND
|
|
</button>
|
|
<button @click="buy_on_stack(c)">
|
|
BUY ON STACK
|
|
</button>
|
|
</template>
|
|
</CardPreview>
|
|
</div>
|
|
|
|
<br>
|
|
gems =
|
|
<CardSlot :stack="props.game.gem_stack">
|
|
<template v-if="isTurn && props.game.gem_stack.length > 0">
|
|
<button @click="buy(props.game.gem_stack.at(-1))">
|
|
BUY
|
|
</button>
|
|
<button @click="buy_in_hand(props.game.gem_stack.at(-1))">
|
|
BUY IN HAND
|
|
</button>
|
|
<button @click="buy_on_stack(props.game.gem_stack.at(-1))">
|
|
BUY ON STACK
|
|
</button>
|
|
</template>
|
|
</CardSlot>
|
|
</div>
|
|
<div>
|
|
<PlayerList :players="props.game?.players" :current_team="game.turn"></PlayerList>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<style>
|
|
.cards_container {
|
|
display: flex;
|
|
flex-direction: row;
|
|
}
|
|
</style> |