card locking and event triggering WIP
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
const props = defineProps(['game'])
|
||||
const self = useState<string>('self')
|
||||
const gameObject = useState<{ [key: string]: any }>('gameObject')
|
||||
const cards = useState<{ [key: string]: any }>('cards')
|
||||
const socket = useState<WebSocket>('socket')
|
||||
|
||||
const isTurn = computed(() => self.value && props.game?.started && (gameObject.value[self.value]?.team == props.game.turn))
|
||||
const isTurn = computed(() => self.value && props.game?.started && (gameObject.value[self.value]?.team == props.game.current_turn))
|
||||
|
||||
async function buy(cardId: string) {
|
||||
socket.value.send(JSON.stringify({
|
||||
@@ -14,22 +15,6 @@ async function buy(cardId: string) {
|
||||
}))
|
||||
}
|
||||
|
||||
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",
|
||||
@@ -41,8 +26,7 @@ async function endTurn() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
<div>
|
||||
<div @contextmenu.prevent="false">
|
||||
<button v-if="isTurn" @click="endTurn">END TURN</button>
|
||||
<div v-if="!self"><b>SPECTATOR MODE</b></div>
|
||||
<div>
|
||||
@@ -54,12 +38,12 @@ async function endTurn() {
|
||||
<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)">
|
||||
<!-- <button @click="buy_in_hand(c)">
|
||||
BUY IN HAND
|
||||
</button>
|
||||
<button @click="buy_on_stack(c)">
|
||||
BUY ON STACK
|
||||
</button>
|
||||
</button> -->
|
||||
</template>
|
||||
</CardPreview>
|
||||
</div>
|
||||
@@ -71,17 +55,17 @@ async function endTurn() {
|
||||
<button @click="buy(props.game.gem_stack.at(-1))">
|
||||
BUY
|
||||
</button>
|
||||
<button @click="buy_in_hand(props.game.gem_stack.at(-1))">
|
||||
<!-- <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>
|
||||
</button> -->
|
||||
</template>
|
||||
</CardSlot>
|
||||
</div>
|
||||
<div>
|
||||
<PlayerList :players="props.game?.players" :current_team="game.turn"></PlayerList>
|
||||
<PlayerList :players="props.game?.players" :current_team="game.current_turn"></PlayerList>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user