<template>
	<v-app :theme="theme">
		<v-app-bar :elevation="2">
			<v-app-bar-title>SHOTGUN</v-app-bar-title>
			<template #append>
				<v-btn :icon="themeIcon" @click="toggleDark()"></v-btn>
			</template>
		</v-app-bar>
		<v-main>
			<TheLanding v-if="!playing && !loading" @play="clickPlay" />
			<v-container v-else-if="loading" class="fill-height">
				<v-row class="d-flex justify-center">
					<v-progress-circular class="pa-8" indeterminate size="128"></v-progress-circular>
				</v-row>
			</v-container>
			<Game v-else :game="testGame" :dealer="true" />
		</v-main>
	</v-app>
</template>

<script setup lang="ts">
import { useDark, useToggle } from '@vueuse/core';
import { computed, ref } from 'vue';
import type { Game } from '@/lib/game';

const dark = useDark();
const toggleDark = useToggle(dark);
const theme = computed(() => dark.value ? 'dark' : 'light');
const themeIcon = computed(() => dark.value ? 'mdi-moon-waxing-crescent' : 'mdi-white-balance-sunny');

const playing = ref(false);
const loading = ref(false);
function clickPlay() {
	loading.value = true;
	setTimeout(() => {
		playing.value = true;
		loading.value = false;
	}, 1000);
}

const testGame = ref<Game>({
	players: [
		{ hp: 4, items: ['🔍', '🔪', '', '', '', '', '', ''] },
		{ hp: 3, items: ['👮', '🚬', '', '', '', '', '', ''] },
	],
	round: 1,
	dealer: true,
	damage: 1,
	previous: null,
	live: 3,
	blank: 4,
});
</script>
