game-village-politics-frontend/app/pages/village/[id]/recruit.vue

45 lines
1.5 KiB
Vue
Raw Normal View History

<script setup lang="ts">
const route = useRoute()
const v = useVillageContext()
const village = computed(() => v.village.value!)
const resources = computed(() => v.resources.value!)
/** Military building whose tab is open; `?at=` picks one. */
const recruitAt = ref<number | null>(Number(route.query.at) || null)
watch(
() => route.query.at,
(at) => (recruitAt.value = Number(at) || recruitAt.value),
)
</script>
<!-- Recruiting at every military building, the troops at home and the levy. -->
<template>
<div class="grid gap-6 px-4 py-6 sm:px-6 lg:grid-cols-[minmax(0,1fr)_22rem] 2xl:grid-cols-[minmax(0,1fr)_26rem]">
<VillageRecruit
v-if="village.military.length"
v-model:selected="recruitAt"
:military="village.military"
:troops="village.troops"
:villagers="village.population.villagers - village.levy.militia"
:resources="resources"
:seconds-until="v.secondsUntil"
:busy="v.busy.value"
:recruit="v.recruit"
@cancel="v.cancelRecruit"
/>
<section v-else class="panel">
<div class="panel-body py-8 text-center text-sm text-ink-500">{{ $t('village.troops.hint') }}</div>
</section>
<VillageTroopsPanel
:troops="village.troops"
:training="village.population.training"
:levy="village.levy"
:villagers="village.population.villagers"
:seconds-until="v.secondsUntil"
:busy="v.busy.value"
@levy="v.levy"
@end-levy="v.endLevy"
/>
</div>
</template>