147 lines
3.4 KiB
Vue
147 lines
3.4 KiB
Vue
<script setup lang="ts">
|
|
import goStore, { useEffect, playCard, playAllCards, discard, lockCard, heal, damage_champion, damage_team, endTurn } from '~/netcode';
|
|
import { CardEffects } from '@/netcode/Effect'
|
|
|
|
const isTurn = computed(() => goStore.self?.team == goStore.current_game?.current_turn)
|
|
|
|
let warning = ref(false)
|
|
|
|
function checkEndTurn() {
|
|
// TODO: Add a confirmation dialog if resources are left
|
|
console.log("Checking end turn")
|
|
if (
|
|
(!warning.value)
|
|
&& (
|
|
(goStore.self?.turn?.damage_reserve ? goStore.self?.turn?.damage_reserve > 0 : false)
|
|
|| (goStore.self?.turn?.gold_reserve ? goStore.self?.turn?.gold_reserve > 0 : false)
|
|
|| (goStore.self?.turn?.fuck_u_markers ? goStore.self?.turn?.fuck_u_markers > 0 : false)
|
|
)) {
|
|
// Set a warning flag to true
|
|
// Display an alert somehow using this warning flag
|
|
warning.value = true
|
|
}
|
|
else {
|
|
warning.value = false
|
|
endTurn()
|
|
}
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
<template>
|
|
<div :class="'player ' + (isTurn ? 'turn' : '')">
|
|
<button v-if="goStore.self && goStore.self!.turn && goStore.self?.team != goStore.self?.team" id="end_turn"
|
|
@click="useEffect(goStore.self.turn.find_effect(CardEffects.MAKE_DISCARD)!, goStore.self)"
|
|
:disabled="!goStore.self.turn.find_effect(CardEffects.MAKE_DISCARD)">
|
|
make Discard</button>
|
|
<div id="turn_data">
|
|
<div class="warning" v-if="warning">/!\<br> Effets restants!<br> /!\</div>
|
|
<button id="end_turn" v-if="isTurn" @click="checkEndTurn">END TURN</button>
|
|
<PlayerStats v-if="goStore.self" :player='goStore.self'></PlayerStats>
|
|
</div>
|
|
|
|
<div class="cards_container" id="self_hand">
|
|
<CardPreview :card_id="c?.card_id" v-for=" c in goStore.self?.hand " @click="c && playCard(c)">
|
|
<button v-if="c && isTurn && goStore.self?.turn && (goStore.self.turn.discard_markers ?? 0) > 0"
|
|
@click="discard(c!)">DISCARD</button>
|
|
</CardPreview>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.cards_container {
|
|
display: flex;
|
|
flex-direction: row-reverse;
|
|
justify-content: center;
|
|
}
|
|
|
|
.stack_and_discard {
|
|
display: flex;
|
|
flex-direction: row-reverse;
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
.player {
|
|
border-top: 5px solid black;
|
|
}
|
|
|
|
#play_all {
|
|
display: flex;
|
|
flex-direction: row;
|
|
align-items: center;
|
|
font-size: 10em;
|
|
}
|
|
|
|
#turn_data {
|
|
position: fixed;
|
|
bottom: 10px;
|
|
left: 10px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: flex-start;
|
|
z-index: 9;
|
|
}
|
|
|
|
.warning {
|
|
background-color: rgba(255, 0, 0, 0.7);
|
|
color: white;
|
|
padding: 5px;
|
|
border-radius: 5px;
|
|
width: 60px;
|
|
font-size: 0.9em;
|
|
}
|
|
|
|
#end_turn {
|
|
z-index: 10;
|
|
}
|
|
|
|
#self_hand {
|
|
position: fixed;
|
|
z-index: 1;
|
|
display: flex;
|
|
align-items: stretch;
|
|
flex-direction: row;
|
|
flex-wrap: nowrap;
|
|
left: 70px;
|
|
bottom: -50px;
|
|
max-width: 100vw;
|
|
justify-content: flex-start;
|
|
transition: 0.5s all cubic-bezier(0.075, 0.82, 0.165, 1);
|
|
transform: translateY(150px)
|
|
}
|
|
|
|
#self_hand:hover {
|
|
transform: translateY(0px);
|
|
}
|
|
|
|
#end_turn {
|
|
width: 50px;
|
|
height: 50px;
|
|
}
|
|
</style>
|
|
|
|
<style>
|
|
#turn_data * {
|
|
margin: 2.5px 0 2.5px 0;
|
|
}
|
|
|
|
#self_hand .card {
|
|
transition: 0.5s all cubic-bezier(0.075, 0.82, 0.165, 1);
|
|
overflow: visible;
|
|
}
|
|
|
|
|
|
#self_hand .card:hover {
|
|
transform: translateY(-40px);
|
|
|
|
}
|
|
|
|
|
|
|
|
.cards_container {
|
|
min-width: 250px;
|
|
}
|
|
</style> |