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

63 lines
2.6 KiB
Vue
Raw Normal View History

<script setup lang="ts">
import type { Population } from '~/types/game'
const props = defineProps<{
population: Population
/** Villagers drafted by a levy: neither working nor idle. */
militia: number
}>()
const stats = computed(() => [
{ key: 'villagers', value: props.population.villagers },
{ key: 'workers', value: props.population.workers },
{ key: 'idle', value: props.population.idle },
{ key: 'soldiers', value: props.population.soldiers },
])
</script>
<template>
<section class="panel">
<div class="panel-head">
<h2 class="panel-title">{{ $t('village.population.title') }}</h2>
<IconUi name="users" class="size-5 text-ink-400" />
</div>
<div class="panel-body space-y-4">
<!-- Heads, the same on every world speed: the food per hour is in the resource bar. -->
<div class="grid grid-cols-2 gap-3" :title="$t('village.population.heads_hint')">
<div class="rounded-sm border-2 border-parchment-300 bg-parchment-100 p-3">
<p class="text-xs text-ink-500">{{ $t('village.population.food_budget') }}</p>
<p class="mt-0.5 flex items-center gap-1 font-semibold tabular-nums">
<IconUi name="users" class="size-4 text-wood-800" />
{{ $t('village.population.heads', { value: population.food_budget }) }}
</p>
</div>
<div class="rounded-sm border-2 border-parchment-300 bg-parchment-100 p-3">
<p class="text-xs text-ink-500">{{ $t('village.population.upkeep') }}</p>
<p class="mt-0.5 flex items-center gap-1 font-semibold tabular-nums">
<IconUi name="users" class="size-4 text-wood-800" />
{{ $t('village.population.heads', { value: population.upkeep }) }}
</p>
</div>
</div>
<dl class="grid grid-cols-4 gap-2 text-center">
<div v-for="s in stats" :key="s.key">
<dd class="text-lg font-semibold tabular-nums">{{ s.value }}</dd>
<dt class="text-xs text-ink-500">{{ $t(`village.population.${s.key}`) }}</dt>
</div>
</dl>
<p v-if="population.reserved" class="text-xs text-ink-500">
{{ $t('village.population.reserved') }}: <span class="font-semibold tabular-nums">{{ population.reserved }}</span>
</p>
<div>
<div class="mb-1 flex justify-between text-xs text-ink-500">
<span>{{ $t('village.population.workforce') }}</span>
<span class="tabular-nums">{{ population.workers }}/{{ population.villagers }}</span>
</div>
<UiBar :value="population.villagers ? population.workers / population.villagers : 0" tone="sky" />
</div>
</div>
</section>
</template>