2026-10-28 23:38:54 +00:00
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
import type { Resources, VillageState } from '~/types/game'
|
|
|
|
|
|
|
|
|
|
|
|
const props = defineProps<{ village: VillageState; resources: Resources }>()
|
|
|
|
|
|
const v = useVillageContext()
|
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
|
|
|
|
|
|
|
const base = computed(() => `/village/${props.village.id}`)
|
|
|
|
|
|
const incoming = computed(() => props.village.movements.filter((m) => m.direction === 'in'))
|
|
|
|
|
|
const attacks = computed(() => incoming.value.filter((m) => m.type === 'attack'))
|
|
|
|
|
|
const nextAttack = computed(() => attacks.value[0] ?? null)
|
|
|
|
|
|
const support = computed(() => incoming.value.length - attacks.value.length)
|
|
|
|
|
|
const isActive = (path: string) => route.path === `${base.value}${path}`
|
|
|
|
|
|
|
2026-10-29 09:33:26 +00:00
|
|
|
|
/** Another of the player's villages, on the same screen where the URL has one. */
|
|
|
|
|
|
const others = computed(() => props.village.villages)
|
|
|
|
|
|
const position = computed(() => others.value.findIndex((o) => o.id === props.village.id))
|
|
|
|
|
|
function switchTo(id: number) {
|
|
|
|
|
|
const path = route.path.startsWith(base.value) ? route.path.replace(base.value, `/village/${id}`) : `/village/${id}`
|
|
|
|
|
|
navigateTo(path)
|
|
|
|
|
|
}
|
|
|
|
|
|
function step(by: number) {
|
|
|
|
|
|
const list = others.value
|
|
|
|
|
|
switchTo(list[(position.value + by + list.length) % list.length]!.id)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-29 09:15:36 +00:00
|
|
|
|
const questBook = useQuestBookOpen()
|
|
|
|
|
|
/** Quests to claim plus level rewards to collect. */
|
|
|
|
|
|
const questsWaiting = computed(() => props.village.quests.claimable + props.village.quests.rewards)
|
|
|
|
|
|
|
2026-10-28 23:38:54 +00:00
|
|
|
|
/** The new name while the village is being renamed. */
|
|
|
|
|
|
const renaming = ref<string | null>(null)
|
|
|
|
|
|
async function rename() {
|
|
|
|
|
|
if (renaming.value !== null && (await v.rename(renaming.value))) renaming.value = null
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<!--
|
2026-10-29 09:33:26 +00:00
|
|
|
|
Above the content, like the header of Die Stämme: the quick bar with the village's
|
2026-10-29 00:26:08 +00:00
|
|
|
|
screens, then one row with the village and its stock. Plain numbers in thin cells;
|
|
|
|
|
|
each resource leads to the workforce, where it is made.
|
2026-10-28 23:38:54 +00:00
|
|
|
|
-->
|
|
|
|
|
|
<template>
|
2026-10-29 00:26:08 +00:00
|
|
|
|
<div class="space-y-1 text-[13px]">
|
|
|
|
|
|
<nav class="hidden border border-wood-700 bg-parchment-200 md:flex" :aria-label="$t('village.screens.label')">
|
|
|
|
|
|
<NuxtLink
|
|
|
|
|
|
v-for="s in VILLAGE_SCREENS"
|
|
|
|
|
|
:key="s.name"
|
|
|
|
|
|
:to="`${base}${s.path}`"
|
|
|
|
|
|
class="quick"
|
|
|
|
|
|
:class="{ 'quick-active': isActive(s.path) }"
|
|
|
|
|
|
:aria-current="isActive(s.path) ? 'page' : undefined"
|
|
|
|
|
|
:title="$t('app.shortcut', { key: SHORTCUTS[s.name].toUpperCase() })"
|
|
|
|
|
|
>
|
|
|
|
|
|
<IconBuilding :type="s.icon" class="size-4 text-wood-800" />
|
|
|
|
|
|
{{ $t(`village.screens.${s.name}`) }}
|
|
|
|
|
|
</NuxtLink>
|
|
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="flex flex-wrap items-stretch border border-wood-700 bg-parchment-200">
|
2026-10-29 09:15:36 +00:00
|
|
|
|
<!-- The quest book, with what waits in it. -->
|
|
|
|
|
|
<button
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
class="flex items-center gap-1 border-r border-wood-700 px-2 py-1 font-semibold text-wood-900 hover:bg-parchment-100 hover:text-blood-700"
|
|
|
|
|
|
:class="questsWaiting ? 'bg-gold-400' : ''"
|
|
|
|
|
|
:title="$t('quests.open')"
|
|
|
|
|
|
@click="questBook = true"
|
|
|
|
|
|
>
|
|
|
|
|
|
<IconUi name="book" class="size-4" />
|
|
|
|
|
|
<span class="sr-only sm:not-sr-only">{{ $t('quests.open') }}</span>
|
|
|
|
|
|
<span v-if="questsWaiting" class="font-bold text-blood-700 tabular-nums">({{ questsWaiting }})</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
2026-10-28 23:38:54 +00:00
|
|
|
|
<!-- Which village. -->
|
2026-10-29 00:26:08 +00:00
|
|
|
|
<div class="flex min-w-0 flex-1 items-center gap-1.5 px-2 py-1">
|
|
|
|
|
|
<form v-if="renaming !== null" class="flex items-center gap-1" @submit.prevent="rename">
|
|
|
|
|
|
<input v-model="renaming" type="text" maxlength="32" class="input w-40" :aria-label="$t('village.rename')" @keydown.esc="renaming = null" />
|
|
|
|
|
|
<button type="submit" class="btn btn-primary" :disabled="v.busy.value || !renaming.trim()">{{ $t('village.rename_save') }}</button>
|
|
|
|
|
|
<button type="button" class="btn btn-ghost" @click="renaming = null">{{ $t('village.rename_cancel') }}</button>
|
2026-10-28 23:38:54 +00:00
|
|
|
|
</form>
|
|
|
|
|
|
<template v-else>
|
2026-10-29 09:33:26 +00:00
|
|
|
|
<span v-if="others.length > 1" class="inline-flex shrink-0 items-center">
|
|
|
|
|
|
<button type="button" class="btn btn-ghost px-1" :title="$t('village.switcher.prev')" @click="step(-1)">‹<span class="sr-only">{{ $t('village.switcher.prev') }}</span></button>
|
|
|
|
|
|
<select
|
|
|
|
|
|
class="input w-auto max-w-48 py-0 font-bold"
|
|
|
|
|
|
:value="village.id"
|
|
|
|
|
|
:aria-label="$t('village.switcher.label')"
|
|
|
|
|
|
@change="switchTo(Number(($event.target as HTMLSelectElement).value))"
|
|
|
|
|
|
>
|
|
|
|
|
|
<option v-for="o in others" :key="o.id" :value="o.id">{{ o.name }}</option>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<button type="button" class="btn btn-ghost px-1" :title="$t('village.switcher.next')" @click="step(1)">›<span class="sr-only">{{ $t('village.switcher.next') }}</span></button>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<NuxtLink v-else :to="base" class="truncate font-bold text-wood-950 hover:text-blood-700">{{ village.name }}</NuxtLink>
|
2026-10-29 00:26:08 +00:00
|
|
|
|
<NuxtLink
|
|
|
|
|
|
:to="{ path: `/map/${village.world_id}`, query: { x: village.x, y: village.y } }"
|
|
|
|
|
|
class="shrink-0 font-bold text-wood-950 tabular-nums hover:text-blood-700"
|
|
|
|
|
|
:title="$t('village.on_map')"
|
|
|
|
|
|
>
|
|
|
|
|
|
({{ village.x }}|{{ village.y }}) {{ village.continent }}
|
|
|
|
|
|
</NuxtLink>
|
|
|
|
|
|
<span class="hidden shrink-0 text-ink-500 tabular-nums sm:inline">{{ $t('village.points', { points: village.points }) }}</span>
|
|
|
|
|
|
<button type="button" class="shrink-0 text-ink-400 hover:text-blood-700" :title="$t('village.rename')" @click="renaming = village.name">
|
|
|
|
|
|
<IconUi name="edit" class="size-3.5" />
|
|
|
|
|
|
<span class="sr-only">{{ $t('village.rename') }}</span>
|
|
|
|
|
|
</button>
|
2026-10-28 23:38:54 +00:00
|
|
|
|
</template>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-10-29 00:26:08 +00:00
|
|
|
|
<!-- The stock: four resources, the storage cap and the villagers, each in its own cell. -->
|
|
|
|
|
|
<div class="grid w-full grid-cols-5 border-t border-parchment-300 sm:flex sm:w-auto sm:border-t-0">
|
|
|
|
|
|
<NuxtLink v-for="r in (['wood', 'clay', 'iron', 'food'] as const)" :key="r" :to="`${base}/workforce`" class="cell flex hover:bg-parchment-100">
|
feat: rally point tabs, map village popups, report filters, beginner protection bar, keyboard shortcuts
Ideas taken from how Die Stämme works, in our own look: the rally point splits into
commands, troops and simulator; hovering a village on the map shows its owner, points
and distance, a click offers send troops and centre; reports filter by attacks,
defence and support; a dismissible bar counts down beginner protection; one key per
screen (V, H, T, P, W, M, R); resources in the village bar lead to the workforce.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 00:00:13 +00:00
|
|
|
|
<GameResource :resource="r" :amount="resources[r]" :cap="village.storage_cap" :rate="village.rates[r]" />
|
|
|
|
|
|
</NuxtLink>
|
2026-10-29 09:33:26 +00:00
|
|
|
|
<span v-if="village.loyalty < 100" class="cell flex font-semibold text-blood-700" :title="`${$t('village.loyalty')}: ${$t('village.loyalty_about')}`">
|
|
|
|
|
|
{{ $t('village.loyalty') }} <span class="tabular-nums">{{ village.loyalty }}</span>
|
|
|
|
|
|
</span>
|
2026-10-29 00:26:08 +00:00
|
|
|
|
<span class="cell hidden lg:flex" :title="$t('village.resources.cap')">
|
|
|
|
|
|
<IconBuilding type="storage" class="size-4 text-wood-800" />
|
|
|
|
|
|
<span class="tabular-nums">{{ village.storage_cap }}</span>
|
2026-10-28 23:38:54 +00:00
|
|
|
|
</span>
|
|
|
|
|
|
<NuxtLink
|
|
|
|
|
|
:to="`${base}/workforce`"
|
2026-10-29 00:26:08 +00:00
|
|
|
|
class="cell flex hover:bg-parchment-100"
|
2026-10-29 09:33:26 +00:00
|
|
|
|
:title="`${$t('village.population.villagers')}: ${village.population.villagers} · ${$t('village.population.upkeep')}: ${village.population.upkeep}/${village.population.food_budget}`"
|
2026-10-28 23:38:54 +00:00
|
|
|
|
>
|
2026-10-29 00:26:08 +00:00
|
|
|
|
<IconUi name="users" class="size-4 text-wood-800" />
|
|
|
|
|
|
<span class="tabular-nums">{{ village.population.villagers }}</span>
|
2026-10-28 23:38:54 +00:00
|
|
|
|
</NuxtLink>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-10-29 00:26:08 +00:00
|
|
|
|
<!-- Incoming troops: red for attacks, green for support, with the next arrival. -->
|
|
|
|
|
|
<NuxtLink
|
|
|
|
|
|
v-if="incoming.length"
|
|
|
|
|
|
:to="`${base}/rally`"
|
|
|
|
|
|
class="flex items-center gap-2 border-l border-wood-700 px-2 font-bold"
|
|
|
|
|
|
:class="attacks.length ? 'bg-blood-700 text-parchment-50' : 'bg-moss-600 text-parchment-50'"
|
|
|
|
|
|
:title="$t('village.incoming', { count: attacks.length })"
|
|
|
|
|
|
>
|
|
|
|
|
|
<span v-if="attacks.length" class="inline-flex items-center gap-1"><IconUi name="attack" class="size-4" />{{ attacks.length }}</span>
|
|
|
|
|
|
<span v-if="support" class="inline-flex items-center gap-1"><IconUi name="support" class="size-4" />{{ support }}</span>
|
|
|
|
|
|
<span v-if="nextAttack" class="tabular-nums">{{ formatDuration(v.secondsUntil(nextAttack.arrives_at)) }}</span>
|
|
|
|
|
|
</NuxtLink>
|
2026-10-28 23:38:54 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
@reference "~/assets/css/main.css";
|
|
|
|
|
|
|
2026-10-29 00:26:08 +00:00
|
|
|
|
.quick {
|
|
|
|
|
|
@apply flex items-center gap-1.5 border-r border-parchment-300 px-3 py-1 font-semibold text-wood-900 last:border-r-0 hover:bg-parchment-100 hover:text-blood-700;
|
|
|
|
|
|
}
|
|
|
|
|
|
.quick-active {
|
|
|
|
|
|
@apply bg-parchment-50 text-blood-700;
|
2026-10-28 23:38:54 +00:00
|
|
|
|
}
|
2026-10-29 00:26:08 +00:00
|
|
|
|
.cell {
|
|
|
|
|
|
@apply items-center justify-center gap-1 border-l border-parchment-300 px-2 py-1 first:border-l-0 sm:first:border-l;
|
2026-10-28 23:38:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
</style>
|