2026-10-28 21:14:56 +00:00
|
|
|
|
<script setup lang="ts">
|
2026-10-30 09:42:19 +00:00
|
|
|
|
import type { DockItem } from '~/components/ui/Dock.vue'
|
2026-10-30 10:24:02 +00:00
|
|
|
|
import type { BuildOrder, Movement, UnitType, VillageRole, VillageState } from '~/types/game'
|
2026-10-28 21:14:56 +00:00
|
|
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
|
|
village: VillageState
|
|
|
|
|
|
/** The village page path, for the links to its screens. */
|
|
|
|
|
|
base: string
|
|
|
|
|
|
secondsUntil: (iso: string) => number
|
|
|
|
|
|
}>()
|
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
|
|
|
|
|
|
const production = computed(() => (['wood', 'clay', 'iron', 'food'] as const).map((r) => ({ r, rate: props.village.rates[r] })))
|
|
|
|
|
|
const troops = computed(() => (Object.entries(props.village.troops) as [UnitType, number][]).filter(([, n]) => n > 0))
|
|
|
|
|
|
const idle = computed(() => props.village.population.villagers - props.village.population.workers - props.village.levy.militia)
|
|
|
|
|
|
const spaceShare = computed(() => props.village.space.used / props.village.space.max)
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
|
const incoming = computed(() => props.village.movements.filter((m) => m.direction === 'in' && m.type === 'attack'))
|
|
|
|
|
|
const commands = computed(() => props.village.movements.filter((m) => m.direction !== 'in').length)
|
2026-10-30 10:24:02 +00:00
|
|
|
|
/** Own groups under way, out and home, soonest first; they can be called back for a while. */
|
|
|
|
|
|
const own = computed(() => props.village.movements.filter((m) => m.direction !== 'in'))
|
|
|
|
|
|
const v = useVillageContextOrNull()
|
|
|
|
|
|
const command = (m: Movement) =>
|
|
|
|
|
|
m.direction === 'home'
|
|
|
|
|
|
? t('village.movements.return_from', { from: villageLabel(m.from) })
|
|
|
|
|
|
: t(m.type === 'attack' ? 'village.movements.attack_on' : 'village.movements.support_for', { target: villageLabel(m.to) })
|
|
|
|
|
|
const canCancel = (m: Movement) => !!m.cancel_until && props.secondsUntil(m.cancel_until) > 0
|
2026-10-29 15:22:52 +00:00
|
|
|
|
const spec = computed(() => props.village.specialisation)
|
2026-10-29 15:34:42 +00:00
|
|
|
|
const season = computed(() => props.village.season)
|
2026-10-29 15:22:52 +00:00
|
|
|
|
const roleSpace = computed(() => spec.value.roles.reduce((sum, r) => sum + (spec.value.space[r.role] ?? 0), 0))
|
|
|
|
|
|
const roleShare = (role: VillageRole) => (roleSpace.value ? Math.round((100 * (spec.value.space[role] ?? 0)) / roleSpace.value) : 0)
|
2026-10-30 09:42:19 +00:00
|
|
|
|
// Every box folds and moves (UiDock); the incoming attacks only while there are any.
|
|
|
|
|
|
const cards = computed<DockItem[]>(() => [
|
|
|
|
|
|
{ key: 'incoming', title: t('village.side.incoming'), alarm: true, show: incoming.value.length > 0 },
|
2026-10-30 10:24:02 +00:00
|
|
|
|
{ key: 'commands', title: t('village.movements.own'), show: own.value.length > 0 },
|
2026-10-30 09:42:19 +00:00
|
|
|
|
{ key: 'production', title: t('village.side.production') },
|
|
|
|
|
|
{ key: 'units', title: t('village.side.units') },
|
|
|
|
|
|
{ key: 'population', title: t('village.population.title') },
|
|
|
|
|
|
{ key: 'season', title: t('village.season.title') },
|
|
|
|
|
|
{ key: 'role', title: t('village.role.title') },
|
|
|
|
|
|
{ key: 'construction', title: t('village.side.construction') },
|
|
|
|
|
|
])
|
2026-10-29 15:22:52 +00:00
|
|
|
|
const bonuses = computed(() => Object.entries(spec.value.roles.find((r) => r.role === spec.value.role)?.bonuses ?? {}))
|
2026-10-28 21:14:56 +00:00
|
|
|
|
|
|
|
|
|
|
function order(o: BuildOrder) {
|
|
|
|
|
|
const type = t(`buildings.${o.type}`)
|
|
|
|
|
|
if (o.action === 'build') return type
|
2026-10-28 21:26:50 +00:00
|
|
|
|
return `${type} ${o.target_level < 1 ? '×' : `→ ${o.target_level}`}`
|
2026-10-28 21:14:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- The column beside the village: small boxes with the numbers that matter at a glance. -->
|
|
|
|
|
|
<template>
|
2026-10-30 09:42:19 +00:00
|
|
|
|
<aside class="p-2 text-sm">
|
|
|
|
|
|
<UiDock scope="overview" :cards="cards">
|
|
|
|
|
|
<template #incoming>
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
|
<ul class="side-body">
|
|
|
|
|
|
<li v-for="m in incoming" :key="m.id" class="flex items-center gap-2 text-blood-700">
|
|
|
|
|
|
<IconUi name="attack" class="size-4" />
|
2026-10-29 15:17:00 +00:00
|
|
|
|
<span class="min-w-0 flex-1 truncate">{{ m.raid ? $t('village.side.raiders', { from: `(${m.from.x}|${m.from.y})` }) : villageLabel(m.from) }}</span>
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
|
<span class="font-semibold tabular-nums">{{ formatDuration(secondsUntil(m.arrives_at)) }}</span>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
2026-10-30 09:42:19 +00:00
|
|
|
|
</template>
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
|
|
2026-10-30 10:24:02 +00:00
|
|
|
|
<template #commands>
|
|
|
|
|
|
<ul class="side-body">
|
|
|
|
|
|
<li v-for="m in own" :key="m.id">
|
|
|
|
|
|
<div class="flex items-center gap-2">
|
|
|
|
|
|
<IconUi :name="m.type === 'return' ? 'return' : m.type" class="size-4 shrink-0" />
|
|
|
|
|
|
<NuxtLink
|
|
|
|
|
|
:to="{ path: `/map/${village.world_id}`, query: { x: (m.direction === 'home' ? m.from : m.to).x, y: (m.direction === 'home' ? m.from : m.to).y } }"
|
|
|
|
|
|
class="min-w-0 flex-1 truncate hover:underline"
|
|
|
|
|
|
:title="command(m)"
|
|
|
|
|
|
>
|
|
|
|
|
|
{{ command(m) }}
|
|
|
|
|
|
</NuxtLink>
|
|
|
|
|
|
<span class="font-semibold tabular-nums">{{ formatDuration(secondsUntil(m.arrives_at)) }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="v && canCancel(m)" class="flex justify-end pb-0.5">
|
|
|
|
|
|
<button type="button" class="btn btn-outline px-1.5 py-0 text-xs tabular-nums" :disabled="v.busy.value" @click="v.cancelMovement(m.id)">
|
|
|
|
|
|
{{ $t('village.movements.cancel') }} · {{ formatDuration(secondsUntil(m.cancel_until!)) }}
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
2026-10-30 09:42:19 +00:00
|
|
|
|
<template #production>
|
2026-10-28 21:14:56 +00:00
|
|
|
|
<ul class="side-body">
|
|
|
|
|
|
<li v-for="{ r, rate } in production" :key="r" class="flex items-center gap-2">
|
|
|
|
|
|
<IconResource :resource="r" class="size-4" />
|
|
|
|
|
|
<span class="flex-1">{{ $t(`resources.${r}`) }}</span>
|
|
|
|
|
|
<span class="font-semibold tabular-nums" :class="rate < 0 ? 'text-blood-700' : ''">
|
|
|
|
|
|
{{ $t('village.resources.per_hour', { rate: formatRate(rate) }) }}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
2026-10-30 09:42:19 +00:00
|
|
|
|
</template>
|
2026-10-28 21:14:56 +00:00
|
|
|
|
|
2026-10-30 09:42:19 +00:00
|
|
|
|
<template #units>
|
2026-10-28 21:14:56 +00:00
|
|
|
|
<div class="side-body">
|
|
|
|
|
|
<ul v-if="troops.length || village.levy.militia">
|
|
|
|
|
|
<li v-for="[unit, count] in troops" :key="unit" class="flex items-center gap-2">
|
|
|
|
|
|
<IconUnit :unit="unit" class="size-4 text-wood-800" />
|
|
|
|
|
|
<span class="font-semibold tabular-nums">{{ count }}</span>
|
|
|
|
|
|
<span class="truncate">{{ $t(`units.${unit}`) }}</span>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
<li v-if="village.levy.militia" class="flex items-center gap-2">
|
|
|
|
|
|
<IconUnit unit="militia" class="size-4 text-wood-800" />
|
|
|
|
|
|
<span class="font-semibold tabular-nums">{{ village.levy.militia }}</span>
|
|
|
|
|
|
<span>{{ $t('village.levy.militia') }}</span>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
<p v-else class="text-ink-500">{{ $t('village.troops.none') }}</p>
|
|
|
|
|
|
<p v-if="village.population.training" class="text-xs text-ink-500">{{ $t('village.troops.training', { count: village.population.training }) }}</p>
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
|
<p v-if="commands" class="text-xs text-ink-500">{{ $t('village.side.commands') }}: {{ commands }}</p>
|
2026-10-29 13:09:03 +00:00
|
|
|
|
<div class="side-actions">
|
|
|
|
|
|
<NuxtLink :to="`${base}/recruit`" class="btn btn-outline">{{ $t('village.side.recruit') }}</NuxtLink>
|
|
|
|
|
|
<NuxtLink :to="`${base}/rally`" class="btn btn-outline">{{ $t('village.side.rally') }}</NuxtLink>
|
|
|
|
|
|
</div>
|
2026-10-28 21:14:56 +00:00
|
|
|
|
</div>
|
2026-10-30 09:42:19 +00:00
|
|
|
|
</template>
|
2026-10-28 21:14:56 +00:00
|
|
|
|
|
2026-10-30 09:42:19 +00:00
|
|
|
|
<template #population>
|
2026-10-28 21:14:56 +00:00
|
|
|
|
<dl class="grid grid-cols-[1fr_auto] gap-x-2 gap-y-1 px-2.5 py-1.5">
|
|
|
|
|
|
<dt>{{ $t('village.population.villagers') }}</dt>
|
|
|
|
|
|
<dd class="text-right font-semibold tabular-nums">{{ village.population.villagers }}</dd>
|
|
|
|
|
|
<dt>{{ $t('village.population.workers') }}</dt>
|
|
|
|
|
|
<dd class="text-right tabular-nums">{{ village.population.workers }}</dd>
|
|
|
|
|
|
<dt>{{ $t('village.population.idle') }}</dt>
|
|
|
|
|
|
<dd class="text-right tabular-nums">{{ idle }}</dd>
|
|
|
|
|
|
<dt>{{ $t('village.population.upkeep') }}</dt>
|
|
|
|
|
|
<dd class="text-right tabular-nums">{{ village.population.upkeep }}/{{ village.population.food_budget }}</dd>
|
|
|
|
|
|
</dl>
|
2026-10-30 09:42:19 +00:00
|
|
|
|
</template>
|
2026-10-28 21:14:56 +00:00
|
|
|
|
|
2026-10-30 09:42:19 +00:00
|
|
|
|
<template #season>
|
2026-10-29 15:34:42 +00:00
|
|
|
|
<div class="side-body">
|
|
|
|
|
|
<template v-if="season.winner">
|
|
|
|
|
|
<p class="font-semibold">{{ $t('village.season.won', { player: season.winner.name }) }}</p>
|
|
|
|
|
|
<div class="side-actions">
|
|
|
|
|
|
<NuxtLink to="/worlds" class="btn btn-outline">{{ $t('village.season.next') }}</NuxtLink>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<p v-else-if="!season.crowns.length">{{ $t('village.season.crowns_in', { time: formatSpan(secondsUntil(season.crowns_at), t) }) }}</p>
|
|
|
|
|
|
<template v-else>
|
|
|
|
|
|
<ul>
|
|
|
|
|
|
<li v-for="c in season.crowns" :key="c.id" class="flex items-center gap-2">
|
|
|
|
|
|
<NuxtLink :to="{ path: `/map/${village.world_id}`, query: { x: c.x, y: c.y } }" class="tabular-nums hover:underline">({{ c.x }}|{{ c.y }})</NuxtLink>
|
|
|
|
|
|
<span class="min-w-0 flex-1 truncate text-right">{{ c.player?.name ?? $t('village.season.barbarians') }}</span>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
<p v-if="season.holder && season.ends_at" class="font-semibold">
|
|
|
|
|
|
{{ $t('village.season.holds', { player: season.holder.name, time: formatSpan(secondsUntil(season.ends_at), t) }) }}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
<p v-else>{{ $t('village.season.nobody', { needed: season.needed }) }}</p>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<p v-if="!season.winner" class="text-xs text-ink-500">
|
|
|
|
|
|
{{ $t('village.season.rule', { needed: season.needed, count: season.count, time: formatSpan(season.hold_seconds, t) }) }}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</div>
|
2026-10-30 09:42:19 +00:00
|
|
|
|
</template>
|
2026-10-29 15:34:42 +00:00
|
|
|
|
|
2026-10-30 09:42:19 +00:00
|
|
|
|
<template #role>
|
2026-10-29 15:22:52 +00:00
|
|
|
|
<div class="side-body">
|
|
|
|
|
|
<p class="font-semibold">{{ spec.role ? $t(`village.role.${spec.role}`) : $t('village.role.none') }}</p>
|
|
|
|
|
|
<ul v-if="spec.role" class="text-moss-700">
|
|
|
|
|
|
<li v-for="[key, value] in bonuses" :key="key">{{ $t(`village.role.bonus.${key}`, { value: Math.round(value * 100) }) }}</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
<ul>
|
|
|
|
|
|
<li v-for="r in spec.roles" :key="r.role" class="flex items-center gap-2">
|
|
|
|
|
|
<span class="flex-1">{{ $t(`village.role.kinds.${r.role}`) }}</span>
|
|
|
|
|
|
<span class="tabular-nums">{{ $t('village.role.space', { space: spec.space[r.role] ?? 0, share: roleShare(r.role) }) }}</span>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
<p v-if="!spec.role" class="text-xs text-ink-500">{{ $t('village.role.hint', { min: spec.min_space, share: Math.round(spec.share * 100) }) }}</p>
|
|
|
|
|
|
</div>
|
2026-10-30 09:42:19 +00:00
|
|
|
|
</template>
|
2026-10-29 15:22:52 +00:00
|
|
|
|
|
2026-10-30 09:42:19 +00:00
|
|
|
|
<template #construction>
|
2026-10-28 21:14:56 +00:00
|
|
|
|
<div class="side-body">
|
|
|
|
|
|
<ol v-if="village.queue.length">
|
|
|
|
|
|
<li v-for="o in village.queue" :key="o.id" class="flex items-center gap-2">
|
|
|
|
|
|
<IconBuilding :type="o.type" class="size-4 text-wood-800" />
|
|
|
|
|
|
<span class="min-w-0 flex-1 truncate">{{ order(o) }}</span>
|
|
|
|
|
|
<span class="tabular-nums" :class="o.finishes_at ? 'font-semibold' : 'text-ink-500'">
|
|
|
|
|
|
{{ o.finishes_at ? formatDuration(secondsUntil(o.finishes_at)) : $t('village.queue.waiting') }}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ol>
|
|
|
|
|
|
<p v-else class="text-ink-500">{{ $t('village.queue.empty') }}</p>
|
|
|
|
|
|
<div class="pt-1">
|
|
|
|
|
|
<div class="mb-1 flex justify-between text-xs text-ink-500">
|
|
|
|
|
|
<span>{{ $t('village.diorama.space') }}</span>
|
|
|
|
|
|
<span class="tabular-nums">{{ village.space.used }}/{{ village.space.max }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<UiBar :value="spaceShare" :tone="spaceShare >= 1 ? 'rose' : 'emerald'" />
|
|
|
|
|
|
</div>
|
2026-10-29 13:09:03 +00:00
|
|
|
|
<div class="side-actions">
|
|
|
|
|
|
<NuxtLink :to="`${base}/build`" class="btn btn-outline">{{ $t('village.screens.build') }}</NuxtLink>
|
|
|
|
|
|
</div>
|
2026-10-28 21:14:56 +00:00
|
|
|
|
</div>
|
2026-10-30 09:42:19 +00:00
|
|
|
|
</template>
|
|
|
|
|
|
</UiDock>
|
2026-10-28 21:14:56 +00:00
|
|
|
|
</aside>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
@reference "~/assets/css/main.css";
|
|
|
|
|
|
|
|
|
|
|
|
.side-body {
|
2026-10-29 00:26:08 +00:00
|
|
|
|
@apply space-y-0.5 px-1.5 py-1;
|
2026-10-28 21:14:56 +00:00
|
|
|
|
}
|
2026-10-29 13:09:03 +00:00
|
|
|
|
/* Links to the screens as small buttons on one line, never wrapped. */
|
|
|
|
|
|
.side-actions {
|
|
|
|
|
|
@apply flex flex-nowrap gap-1 pt-1 whitespace-nowrap;
|
2026-10-28 21:14:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
</style>
|