game-village-politics-frontend/app/components/game/VillageFrame.vue

32 lines
958 B
Vue

<script setup lang="ts">
const props = defineProps<{ villageId: number }>()
// One village state for every screen in the world: the village bar, the village's own
// screens, the map and the reports all read it through useVillageContext().
const v = useVillage(props.villageId)
provideVillage(v)
v.refresh()
const { enter } = useCurrentWorld()
watch(v.village, (state) => {
if (state) enter(state.world_id, state.id)
})
</script>
<template>
<div>
<GameVillageBar v-if="v.village.value && v.resources.value" :village="v.village.value" :resources="v.resources.value" />
<VillageFoodWarning
v-if="v.village.value"
:starvation="v.village.value.starvation"
:levy="v.village.value.levy"
:seconds-until="v.secondsUntil"
/>
<p v-if="v.error.value" class="alert mx-4 mt-3 sm:mx-6" role="alert">{{ v.error.value }}</p>
<main>
<slot />
</main>
<GameTabBar :village-id="villageId" />
</div>
</template>