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)
|
2026-11-03 08:56:37 +00:00
|
|
|
|
/** Villagers free to staff a new building level, from the server. */
|
|
|
|
|
|
const idle = computed(() => props.village.population.idle)
|
2026-10-28 23:38:54 +00:00
|
|
|
|
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 13:09:03 +00:00
|
|
|
|
Above the village, in two pieces with the village showing between them: on the left the
|
|
|
|
|
|
quick bar with the village's screens and the village itself, on the right its stock in
|
|
|
|
|
|
thin cells (each leads to the workforce, where it is made) and incoming troops.
|
2026-10-28 23:38:54 +00:00
|
|
|
|
-->
|
|
|
|
|
|
<template>
|
2026-10-29 13:09:03 +00:00
|
|
|
|
<div class="pointer-events-none flex flex-wrap items-start justify-between gap-1 text-sm">
|
|
|
|
|
|
<div class="pointer-events-auto flex max-w-full min-w-0 flex-col items-start gap-1">
|
2026-10-29 14:25:26 +00:00
|
|
|
|
<nav class="float hidden border border-wood-700 bg-parchment-200 md:flex" :aria-label="$t('village.screens.label')">
|
2026-10-29 13:09:03 +00:00
|
|
|
|
<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>
|
2026-10-29 00:26:08 +00:00
|
|
|
|
|
2026-10-29 14:25:26 +00:00
|
|
|
|
<div class="float flex max-w-full min-w-0 items-stretch border border-wood-700 bg-parchment-200">
|
2026-10-29 13:09:03 +00:00
|
|
|
|
<!-- The quest book, with what waits in it. -->
|
|
|
|
|
|
<button
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
class="flex shrink-0 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-29 09:15:36 +00:00
|
|
|
|
|
2026-10-29 13:09:03 +00:00
|
|
|
|
<!-- Which village. -->
|
|
|
|
|
|
<div class="flex min-w-0 items-center gap-1.5 px-2 py-1 whitespace-nowrap">
|
|
|
|
|
|
<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>
|
|
|
|
|
|
</form>
|
|
|
|
|
|
<template v-else>
|
|
|
|
|
|
<span v-if="others.length > 1" class="inline-flex shrink-0 items-center">
|
|
|
|
|
|
<button type="button" class="btn btn-ghost px-1.5" :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.5 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.5" :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>
|
|
|
|
|
|
<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')"
|
2026-10-29 09:33:26 +00:00
|
|
|
|
>
|
2026-10-29 13:09:03 +00:00
|
|
|
|
({{ 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="btn btn-ghost shrink-0 px-1 text-ink-500" :title="$t('village.rename')" @click="renaming = village.name">
|
|
|
|
|
|
<IconUi name="edit" class="size-4" />
|
|
|
|
|
|
<span class="sr-only">{{ $t('village.rename') }}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</div>
|
2026-10-28 23:38:54 +00:00
|
|
|
|
</div>
|
2026-10-29 13:09:03 +00:00
|
|
|
|
</div>
|
2026-10-28 23:38:54 +00:00
|
|
|
|
|
2026-10-29 14:25:26 +00:00
|
|
|
|
<div class="float pointer-events-auto flex w-full items-stretch border border-wood-700 bg-parchment-200 sm:w-auto">
|
2026-10-29 00:26:08 +00:00
|
|
|
|
<!-- The stock: four resources, the storage cap and the villagers, each in its own cell. -->
|
2026-10-29 13:09:03 +00:00
|
|
|
|
<div class="grid flex-1 grid-cols-5 sm:flex">
|
2026-10-29 00:26:08 +00:00
|
|
|
|
<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-28 23:38:54 +00:00
|
|
|
|
<NuxtLink
|
|
|
|
|
|
:to="`${base}/workforce`"
|
2026-10-29 00:26:08 +00:00
|
|
|
|
class="cell flex hover:bg-parchment-100"
|
2026-11-03 08:56:37 +00:00
|
|
|
|
:title="`${$t('village.population.villagers')}: ${village.population.villagers} · ${$t('village.population.upkeep')}: ${$t('village.population.upkeep_of', { upkeep: village.population.upkeep, budget: village.population.food_budget })}`"
|
2026-10-28 23:38:54 +00:00
|
|
|
|
>
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
<IconUi name="users" class="size-4 shrink-0 text-wood-800 sm:size-5" />
|
|
|
|
|
|
<span class="flex flex-col leading-tight">
|
|
|
|
|
|
<span class="font-semibold tabular-nums">{{ village.population.villagers }}</span>
|
|
|
|
|
|
<span class="text-xs whitespace-nowrap text-ink-500 tabular-nums">{{ $t('village.resources.free', { free: idle }) }}</span>
|
|
|
|
|
|
</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 {
|
2026-10-29 13:09:03 +00:00
|
|
|
|
@apply flex items-center gap-1.5 border-r border-parchment-300 px-3 py-1.5 font-semibold text-wood-900 last:border-r-0 hover:bg-parchment-100 hover:text-blood-700;
|
2026-10-29 00:26:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
.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 {
|
feat: the village at a glance: a tag over every building with its live number, stock cells with amount, limit and rate, a click outside a window closes it
Camps show production, storage its fullest resource against the limit, the farm
free villagers, the HQ building space, military buildings what they train, the
rally point its troops (red under attack), wall, hiding place and watchtower their
effect. While a window or build card is open, a click in the village only closes
it; Esc closes too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 09:15:22 +00:00
|
|
|
|
@apply items-center justify-center gap-1 border-l border-parchment-300 px-1 py-1 first:border-l-0 sm:px-2;
|
2026-10-28 23:38:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
</style>
|