parent
36475c0a9b
commit
a38bf9631f
@ -67,7 +67,7 @@ const loading = computed(() => status.value === 'CONNECTING' || status.value ===
|
|||||||
|
|
||||||
function clickPlay() {
|
function clickPlay() {
|
||||||
if (local) {
|
if (local) {
|
||||||
data.value = JSON.stringify({
|
game.value = {
|
||||||
action: "Start",
|
action: "Start",
|
||||||
damage: 1,
|
damage: 1,
|
||||||
dealer: false,
|
dealer: false,
|
||||||
@ -77,9 +77,12 @@ function clickPlay() {
|
|||||||
],
|
],
|
||||||
previous: null,
|
previous: null,
|
||||||
round: 1,
|
round: 1,
|
||||||
|
deadline: Date.now() + 15000,
|
||||||
blank: 3,
|
blank: 3,
|
||||||
live: 2,
|
live: 2,
|
||||||
});
|
}
|
||||||
|
data.value = JSON.stringify(game.value);
|
||||||
|
dealer.value = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
open();
|
open();
|
||||||
@ -89,6 +92,7 @@ function clickPlay() {
|
|||||||
function action(evt: Action) {
|
function action(evt: Action) {
|
||||||
if (local && game.value != null) {
|
if (local && game.value != null) {
|
||||||
game.value.dealer = !game.value.dealer;
|
game.value.dealer = !game.value.dealer;
|
||||||
|
game.value.deadline = Date.now() + 15000;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (evt.action === 'quit') {
|
if (evt.action === 'quit') {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
<v-container>
|
<v-container>
|
||||||
<v-row class="d-flex justify-center">
|
<v-row class="d-flex justify-center">
|
||||||
<v-sheet :elevation="2" width="800">
|
<v-sheet :elevation="2" width="800">
|
||||||
|
<v-progress-linear :model-value="timeLeft" :max="initTimeLeft" :color="moveColor"></v-progress-linear>
|
||||||
<v-row class="d-flex justify-center">
|
<v-row class="d-flex justify-center">
|
||||||
<v-col cols="auto">
|
<v-col cols="auto">
|
||||||
<GameStatus :game="props.game" />
|
<GameStatus :game="props.game" />
|
||||||
@ -49,7 +50,8 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Game, Action } from '@/lib/game';
|
import type { Game, Action } from '@/lib/game';
|
||||||
import { computed } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
|
import { useTimestamp } from '@vueuse/core';
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
/**
|
/**
|
||||||
@ -76,6 +78,19 @@ const currentTurn = computed(() => props.game.dealer ? 'DEALER' : 'CHALLENGER');
|
|||||||
const dealerTarget = computed(() => props.dealer ? 'YOURSELF' : 'THE DEALER');
|
const dealerTarget = computed(() => props.dealer ? 'YOURSELF' : 'THE DEALER');
|
||||||
const challTarget = computed(() => props.dealer ? 'THE CHALLENGER' : 'YOURSELF');
|
const challTarget = computed(() => props.dealer ? 'THE CHALLENGER' : 'YOURSELF');
|
||||||
|
|
||||||
|
const initTimeLeft = ref(15000);
|
||||||
|
const timeLeft = ref(15000);
|
||||||
|
const timestamp = useTimestamp({
|
||||||
|
callback: (t) => {
|
||||||
|
timeLeft.value = props.game.deadline - t;
|
||||||
|
},
|
||||||
|
interval: 60,
|
||||||
|
});
|
||||||
|
watch(props.game, (now) => {
|
||||||
|
initTimeLeft.value = now.deadline - timestamp.value;
|
||||||
|
});
|
||||||
|
const moveColor = computed(() => timeLeft.value > 3000 ? 'primary' : 'red');
|
||||||
|
|
||||||
function attack(left: boolean) {
|
function attack(left: boolean) {
|
||||||
const action = left === props.dealer ? 'self' : 'across';
|
const action = left === props.dealer ? 'self' : 'across';
|
||||||
emit('action', { action });
|
emit('action', { action });
|
||||||
|
@ -30,6 +30,11 @@ export interface Game {
|
|||||||
* Damage that a live round will deal this turn.
|
* Damage that a live round will deal this turn.
|
||||||
*/
|
*/
|
||||||
damage: number;
|
damage: number;
|
||||||
|
/**
|
||||||
|
* Deadline for the current player's next action in milliseconds since the
|
||||||
|
* Unix epoch.
|
||||||
|
*/
|
||||||
|
deadline: number;
|
||||||
/**
|
/**
|
||||||
* The current shell if it is revealed for the player receiving this state.
|
* The current shell if it is revealed for the player receiving this state.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user