feat: building portraits, screen headers and a livelier village: shadows, smoke, walkers, a pond

Each building screen opens with the building drawn as it stands, its level and what it
does; the HQ list and the building cards show the same portraits. In the village,
buildings and trees cast flat shadows, chimneys, forges and kilns smoke, villagers walk
the roads to the zones they work in (more where more work), and a pond lies in the
meadow. Motion stops for players who prefer reduced motion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Fabian @ Blax Software 2026-10-29 00:46:15 +01:00
parent 6ff529955b
commit 9df0ee10bc
13 changed files with 310 additions and 87 deletions

View File

@ -119,7 +119,7 @@ const demolishable = computed(() =>
<tr v-for="row in rows" :key="row.key" class="border-b border-parchment-300 last:border-b-0 even:bg-parchment-100"> <tr v-for="row in rows" :key="row.key" class="border-b border-parchment-300 last:border-b-0 even:bg-parchment-100">
<td class="px-3 py-1"> <td class="px-3 py-1">
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<IconBuildingTile :type="row.type" class="size-7" :class="row.kind === 'build' ? 'opacity-70' : ''" /> <VillagePortraitTile :type="row.type" :level="row.kind === 'upgrade' ? row.building.level : 1" class="size-11" />
<div class="min-w-0 leading-tight"> <div class="min-w-0 leading-tight">
<button <button
v-if="row.kind === 'upgrade'" v-if="row.kind === 'upgrade'"

View File

@ -22,7 +22,7 @@ const emit = defineEmits<{
<template> <template>
<section class="panel" :aria-label="$t(`buildings.${building.type}`)"> <section class="panel" :aria-label="$t(`buildings.${building.type}`)">
<div class="flex items-center gap-3 border-b-2 border-wood-700 bg-parchment-200 px-4 py-3"> <div class="flex items-center gap-3 border-b-2 border-wood-700 bg-parchment-200 px-4 py-3">
<IconBuildingTile :type="building.type" class="size-11" /> <VillagePortraitTile :type="building.type" :level="building.level" class="size-14" />
<div class="min-w-0 flex-1"> <div class="min-w-0 flex-1">
<h2 class="truncate font-display text-lg font-semibold text-wood-900" style="font-variant: small-caps">{{ $t(`buildings.${building.type}`) }}</h2> <h2 class="truncate font-display text-lg font-semibold text-wood-900" style="font-variant: small-caps">{{ $t(`buildings.${building.type}`) }}</h2>
<p class="text-xs text-ink-500"> <p class="text-xs text-ink-500">

View File

@ -0,0 +1,38 @@
<script setup lang="ts">
import type { BuildingType } from '~/types/game'
import { mix, plane, project, toPolys, type V3 } from '~/diorama/iso'
import { buildingModel } from '~/diorama/models'
const props = defineProps<{ type: BuildingType; level: number }>()
// The building as it stands in the village, on its own patch of grass: the same model
// and shading as the diorama, framed to its bounds.
const S = 24
const picture = computed(() => {
const model = buildingModel(props.type, Math.max(1, props.level), S)
const patch = Array.from({ length: 14 }, (_, i): V3 => {
const a = (i / 14) * Math.PI * 2
const r = S * (1.45 + 0.08 * Math.sin(i * 2.3))
return [Math.cos(a) * r, Math.sin(a) * r, 0]
})
const ground = toPolys([plane(patch, '#7f8f4b')])
const rim = toPolys([plane(patch.map(([x, y]): V3 => [x * 1.06, y * 1.06, -3]), mix('#7f8f4b', '#3e2b1a', 0.45))])
const polys = [...rim, ...ground, ...toPolys(model.faces)]
const pts = polys.flatMap((p) => p.points.split(' ').map((xy) => xy.split(',').map(Number) as [number, number]))
const top = project([0, 0, model.height])[1]
const xs = pts.map((p) => p[0])
const ys = [...pts.map((p) => p[1]), top]
const pad = 4
const x0 = Math.min(...xs) - pad
const y0 = Math.min(...ys) - pad
return { polys, viewBox: `${x0.toFixed(1)} ${y0.toFixed(1)} ${(Math.max(...xs) - x0 + pad).toFixed(1)} ${(Math.max(...ys) - y0 + pad).toFixed(1)}` }
})
</script>
<template>
<svg :viewBox="picture.viewBox" class="block" aria-hidden="true">
<g stroke-width="0.6" stroke-linejoin="round">
<polygon v-for="(p, i) in picture.polys" :key="i" :points="p.points" :fill="p.fill" :stroke="p.stroke" />
</g>
</svg>
</template>

View File

@ -36,6 +36,11 @@ onMounted(() => {
}) })
onBeforeUnmount(() => observer?.disconnect()) onBeforeUnmount(() => observer?.disconnect())
// Walkers and smoke only move for players who don't ask for reduced motion.
const motion = ref(false)
onMounted(() => (motion.value = !window.matchMedia('(prefers-reduced-motion: reduce)').matches))
const SHIRTS = ['#6b4f3a', '#7b1e16', '#3d5a26', '#57391f', '#5a5f63']
const name = (b: SceneBuilding) => t(`buildings.${b.type}`) const name = (b: SceneBuilding) => t(`buildings.${b.type}`)
const label = (b: SceneBuilding) => t('village.diorama.label', { name: name(b), level: b.level }) const label = (b: SceneBuilding) => t('village.diorama.label', { name: name(b), level: b.level })
const plotLabel = (p: ScenePlot) => t(p.another ? 'village.diorama.plot_another' : 'village.diorama.plot', { name: t(`buildings.${p.type}`) }) const plotLabel = (p: ScenePlot) => t(p.another ? 'village.diorama.plot_another' : 'village.diorama.plot', { name: t(`buildings.${p.type}`) })
@ -114,6 +119,28 @@ const timers = computed(() => {
<polygon v-for="(p, i) in scene.decals" :key="`d${i}`" :points="p.points" :fill="p.fill" :stroke="p.stroke" /> <polygon v-for="(p, i) in scene.decals" :key="`d${i}`" :points="p.points" :fill="p.fill" :stroke="p.stroke" />
</g> </g>
<!-- Villagers on their way to work and back, under the buildings they walk into. -->
<g v-if="motion" class="pointer-events-none" stroke="#2f2013" stroke-width="0.5">
<template v-for="(w, i) in scene.walks" :key="`walk-${i}-${w.d.length}`">
<g v-for="n in w.count" :key="n">
<g transform="scale(1.35)">
<rect x="-1.7" y="-7" width="3.4" height="5.4" rx="0.6" :fill="SHIRTS[(i * 3 + n) % SHIRTS.length]" />
<circle cy="-8.8" r="1.7" fill="#d8a982" />
<path d="M-1 -1.6v1.8M1 -1.6v1.8" fill="none" stroke-width="0.9" />
</g>
<animateMotion
:dur="`${w.seconds}s`"
:begin="`${-((n - 1) * w.seconds) / w.count - i * 3}s`"
repeatCount="indefinite"
keyPoints="0;1;0"
keyTimes="0;0.5;1"
calcMode="linear"
:path="w.d"
/>
</g>
</template>
</g>
<!-- Empty plots: nothing to see, but each opens its building type's build card. --> <!-- Empty plots: nothing to see, but each opens its building type's build card. -->
<ellipse <ellipse
v-for="p in scene.plots" v-for="p in scene.plots"
@ -159,6 +186,13 @@ const timers = computed(() => {
</g> </g>
</template> </template>
<!-- Smoke from chimneys, forges and kilns: flat puffs that rise, drift and shrink away. -->
<g v-if="motion" class="pointer-events-none" fill="#d6cfbf" stroke="#b3ab98" stroke-width="0.5">
<g v-for="(p, i) in scene.smoke" :key="`smoke-${i}`" :transform="`translate(${p[0]} ${p[1]})`">
<circle v-for="n in 3" :key="n" class="puff" r="5.5" :style="{ animationDelay: `${-(n * 1.3 + i * 0.9)}s` }" />
</g>
</g>
<!-- Level badges and countdowns. Flat colours only. --> <!-- Level badges and countdowns. Flat colours only. -->
<g class="pointer-events-none" font-family="ui-sans-serif, system-ui, sans-serif" text-anchor="middle"> <g class="pointer-events-none" font-family="ui-sans-serif, system-ui, sans-serif" text-anchor="middle">
<g v-for="{ b, x, y } in badges" :key="`badge-${b.id}`" :transform="`translate(${x} ${y})`"> <g v-for="{ b, x, y } in badges" :key="`badge-${b.id}`" :transform="`translate(${x} ${y})`">
@ -211,4 +245,22 @@ const timers = computed(() => {
stroke-width: 2; stroke-width: 2;
stroke-dasharray: 4 3; stroke-dasharray: 4 3;
} }
/* A puff starts small at the chimney, grows as it rises and drifts, then shrinks to nothing. */
.puff {
transform-box: fill-box;
transform-origin: center;
animation: puff 3.9s linear infinite;
}
@keyframes puff {
0% {
transform: translate(0, 0) scale(0.25);
}
55% {
transform: translate(-6px, -15px) scale(1);
}
100% {
transform: translate(-13px, -27px) scale(0);
}
}
</style> </style>

View File

@ -26,7 +26,7 @@ const reason = computed(() => {
<template> <template>
<section class="panel" :aria-label="$t(`buildings.${option.type}`)"> <section class="panel" :aria-label="$t(`buildings.${option.type}`)">
<div class="flex items-center gap-3 border-b-2 border-wood-700 bg-parchment-200 px-4 py-3"> <div class="flex items-center gap-3 border-b-2 border-wood-700 bg-parchment-200 px-4 py-3">
<IconBuildingTile :type="option.type" class="size-11 opacity-70" /> <VillagePortraitTile :type="option.type" :level="1" class="size-14" />
<div class="min-w-0 flex-1"> <div class="min-w-0 flex-1">
<h2 class="truncate font-display text-lg font-semibold text-wood-900" style="font-variant: small-caps">{{ $t(`buildings.${option.type}`) }}</h2> <h2 class="truncate font-display text-lg font-semibold text-wood-900" style="font-variant: small-caps">{{ $t(`buildings.${option.type}`) }}</h2>
<p class="text-xs text-ink-500"> <p class="text-xs text-ink-500">

View File

@ -0,0 +1,12 @@
<script setup lang="ts">
import type { BuildingType } from '~/types/game'
defineProps<{ type: BuildingType; level: number }>()
</script>
<!-- A building's picture on a framed patch of meadow, for lists, cards and screen headers. -->
<template>
<span class="grid shrink-0 place-items-center overflow-hidden rounded-sm border-2 border-wood-700 bg-[#9fb06a] p-px">
<VillageBuildingPortrait :type="type" :level="level" class="size-full" />
</span>
</template>

View File

@ -0,0 +1,28 @@
<script setup lang="ts">
import type { BuildingType } from '~/types/game'
defineProps<{
/** The building the screen belongs to, drawn as it stands; null when it doesn't stand yet. */
type: BuildingType
level: number | null
title: string
description: string
}>()
</script>
<!-- The top of a building screen, like Die Stämme's: the building's picture, its name and level, and what it does. -->
<template>
<header class="flex items-center gap-4">
<VillagePortraitTile :type="type" :level="level ?? 1" class="size-20 rounded-md p-1 shadow-hard sm:size-24" />
<div class="min-w-0">
<h1 class="font-display text-2xl leading-tight font-semibold text-wood-900" style="font-variant: small-caps">
{{ title }}
<span v-if="level !== null" class="ml-1 align-middle font-sans text-sm font-semibold text-ink-500" style="font-variant: normal">
{{ $t('village.buildings.level_n', { level }) }}
</span>
</h1>
<p class="mt-1 max-w-prose text-sm text-ink-700">{{ description }}</p>
<slot />
</div>
</header>
</template>

View File

@ -10,7 +10,7 @@
// deterministically and in id order, so buildings stay put when new ones are added. // deterministically and in id order, so buildings stay put when new ones are added.
import type { BuildingType, VillageState } from '~/types/game' import type { BuildingType, VillageState } from '~/types/game'
import { type Face, hash, ngon, plane, type Poly, prism, project, pyramid, toPolys, type V2, type V3 } from './iso' import { type Face, hash, ngon, plane, type Poly, prism, project, pyramid, scale, toPolys, type V2, type V3 } from './iso'
import { broadleaf, buildingModel, bush, C, conifer, crane, rock, scaffold, well } from './models' import { broadleaf, buildingModel, bush, C, conifer, crane, rock, scaffold, well } from './models'
/** World units per unit of building space, roughly. */ /** World units per unit of building space, roughly. */
@ -95,8 +95,16 @@ export interface Scene {
objects: SceneObject[] objects: SceneObject[]
plots: ScenePlot[] plots: ScenePlot[]
timers: SceneTimer[] timers: SceneTimer[]
/** Chimneys, forges and kilns that smoke, as screen points. */
smoke: V2[]
/** Roads villagers walk to work and back: a screen path, how many walk it, seconds per round trip. */
walks: { d: string; count: number; seconds: number }[]
} }
/** Buildings that smoke, from this level on. */
const SMOKY: Partial<Record<BuildingType, number>> = { headquarters: 1, barracks: 1, workshop: 1, academy: 1, clay_pit: 1, iron_mine: 5 }
const WATER = '#5f7f87'
/** A scene object with its painter order (x + y of its ground point). */ /** A scene object with its painter order (x + y of its ground point). */
type Ordered = SceneObject & { depth: number } type Ordered = SceneObject & { depth: number }
@ -218,26 +226,45 @@ function disc(cx: number, cy: number, r: number, n: number, seed: number, z = 0.
}) })
} }
/** The winding centre line of a road from radius r0 to r1 along angle `a`, with each point's distance out. */
function roadLine(a: number, r0: number, r1: number, seed: number): { x: number; y: number; t: number; k: number }[] {
const [dx, dy] = dir(a)
const px = -dy
const py = dx
const steps = Math.max(2, Math.ceil((r1 - r0) / (U * 1.4)))
return Array.from({ length: steps + 1 }, (_, k) => {
const t = r0 + ((r1 - r0) * k) / steps
const wobble = k === 0 ? 0 : (hash(seed, k, 5) - 0.5) * U * 0.4
return { x: dx * t + px * wobble, y: dy * t + py * wobble, t, k }
})
}
/** A dirt road from radius r0 to r1 along angle `a`, gently winding. */ /** A dirt road from radius r0 to r1 along angle `a`, gently winding. */
function road(a: number, r0: number, r1: number, half: number, seed: number): Face { function road(a: number, r0: number, r1: number, half: number, seed: number): Face {
const [dx, dy] = dir(a) const [dx, dy] = dir(a)
const px = -dy const px = -dy
const py = dx const py = dx
const steps = Math.max(2, Math.ceil((r1 - r0) / (U * 1.4)))
const left: V3[] = [] const left: V3[] = []
const right: V3[] = [] const right: V3[] = []
for (let k = 0; k <= steps; k++) { for (const { x, y, k } of roadLine(a, r0, r1, seed)) {
const t = r0 + ((r1 - r0) * k) / steps
const wobble = k === 0 ? 0 : (hash(seed, k, 5) - 0.5) * U * 0.4
const w = half * (0.85 + 0.3 * hash(seed, k, 6)) const w = half * (0.85 + 0.3 * hash(seed, k, 6))
const cx = dx * t + px * wobble left.push([x + px * w, y + py * w, 1.2])
const cy = dy * t + py * wobble right.push([x - px * w, y - py * w, 1.2])
left.push([cx + px * w, cy + py * w, 1.2])
right.push([cx - px * w, cy - py * w, 1.2])
} }
return plane([...left, ...right.reverse()], DIRT) return plane([...left, ...right.reverse()], DIRT)
} }
/** The screen path along a road between two radii, for villagers to walk. */
function walkPath(a: number, r0: number, r1: number, seed: number, from: number, to: number): string {
const pts = roadLine(a, r0, r1, seed).filter((p) => p.t >= from && p.t <= to)
return pts.map((p, i) => `${i ? 'L' : 'M'}${project([p.x, p.y, 1.2]).map((v) => v.toFixed(1)).join(' ')}`).join(' ')
}
/** A flat shadow on the ground, cast away from the light (to the right on screen). */
function shadow(x: number, y: number, r: number, color: string, seed: number): Face {
return plane(disc(x + r * 0.42, y - r * 0.32, r, 10, seed, 1.4), color)
}
/** A band around the village: worn earth under the wall, or the village's edge without one. */ /** A band around the village: worn earth under the wall, or the village's edge without one. */
function ringBand(r: number, width: number, color: string): Face[] { function ringBand(r: number, width: number, color: string): Face[] {
const n = 56 const n = 56
@ -367,6 +394,8 @@ export function buildScene(village: VillageState, aspect = 2.2): Scene {
const zoneEnd = (zone: Zone) => Math.max(Rv + U * 3, ...zoneSlots[zone].map((s) => Math.hypot(s.x, s.y) + s.r)) const zoneEnd = (zone: Zone) => Math.max(Rv + U * 3, ...zoneSlots[zone].map((s) => Math.hypot(s.x, s.y) + s.r))
const running = new Set(village.queue.filter((o) => o.builder !== null && o.building_id !== null).map((o) => o.building_id)) const running = new Set(village.queue.filter((o) => o.builder !== null && o.building_id !== null).map((o) => o.building_id))
const shadows: Face[] = []
const smoke: V2[] = []
const objects: Ordered[] = [] const objects: Ordered[] = []
const labelTops: number[] = [] const labelTops: number[] = []
/** Badge point per building id, and per queued new building (order id), for the timers. */ /** Badge point per building id, and per queued new building (order id), for the timers. */
@ -385,6 +414,10 @@ export function buildScene(village: VillageState, aspect = 2.2): Scene {
const label = project([slot.x, slot.y, model.height + 10]) const label = project([slot.x, slot.y, model.height + 10])
labelTops.push(label[1]) labelTops.push(label[1])
anchorOfBuilding.set(b.id, label) anchorOfBuilding.set(b.id, label)
const ground = b.type === 'headquarters' ? PLAZA : zone ? (ZONES[zone].ground ?? GRASS[0]!) : VILLAGE_GROUND
shadows.push(shadow(slot.x, slot.y, s * (zone ? 1.0 : 0.95), scale(ground, 0.8), b.id))
const smokyFrom = SMOKY[b.type]
if (smokyFrom !== undefined && b.level >= smokyFrom && !upgrading) smoke.push(project([slot.x - s * 0.35, slot.y + s * 0.3, model.height * 0.72]))
objects.push({ objects.push({
key: `b${b.id}`, key: `b${b.id}`,
depth: slot.x + slot.y, depth: slot.x + slot.y,
@ -480,6 +513,23 @@ export function buildScene(village: VillageState, aspect = 2.2): Scene {
// Landscape: a rocky hill behind the iron zone, then forest everywhere else. // Landscape: a rocky hill behind the iron zone, then forest everywhere else.
const taken: { x: number; y: number; r: number }[] = allSlots.map((s) => ({ x: s.x, y: s.y, r: s.r + U * 0.45 })) const taken: { x: number; y: number; r: number }[] = allSlots.map((s) => ({ x: s.x, y: s.y, r: s.r + U * 0.45 }))
// A pond in the meadow between the clay pits and the hill, with reeds on its bank.
const pondR = U * 1.5
const pondOut = Math.max(Rv + U * 2.6, zoneEnd('clay') * 0.85)
const [pondX, pondY] = [Math.cos(deg(150)) * pondOut, Math.sin(deg(150)) * pondOut]
if (!taken.some((t) => Math.hypot(pondX - t.x, pondY - t.y) < t.r + pondR)) {
decalFaces.push(plane(disc(pondX, pondY, pondR * 1.18, 14, 91, 0.9), '#7d7348'))
decalFaces.push(plane(disc(pondX, pondY, pondR, 14, 92, 1.0), WATER))
decalFaces.push(plane(disc(pondX - pondR * 0.25, pondY + pondR * 0.1, pondR * 0.45, 8, 93, 1.1), scale(WATER, 1.12)))
taken.push({ x: pondX, y: pondY, r: pondR * 1.3 })
for (let k = 0; k < 7; k++) {
const a = (k / 7) * Math.PI * 2 + hash(k, 94)
const [x, y] = [pondX + Math.cos(a) * pondR * 1.12, pondY + Math.sin(a) * pondR * 1.12]
const h = U * (0.3 + 0.25 * hash(k, 95))
objects.push({ key: `reed-${k}`, depth: x + y, polys: toPolys(prism(ngon(x, y, U * 0.05, 4), 0, h, '#5b6b2e', '#7a8a3a')) })
}
}
const iron = ZONES.iron const iron = ZONES.iron
const hillFrom = zoneEnd('iron') const hillFrom = zoneEnd('iron')
for (let k = 0; k < 11; k++) { for (let k = 0; k < 11; k++) {
@ -533,6 +583,7 @@ export function buildScene(village: VillageState, aspect = 2.2): Scene {
const seed = i * 131 + j const seed = i * 131 + j
const faces = kind < 0.1 ? bush(x, y, size * 0.8, seed) : kind < 0.62 ? conifer(x, y, size, seed) : broadleaf(x, y, size, seed) const faces = kind < 0.1 ? bush(x, y, size * 0.8, seed) : kind < 0.62 ? conifer(x, y, size, seed) : broadleaf(x, y, size, seed)
taken.push({ x, y, r: size * 0.3 }) taken.push({ x, y, r: size * 0.3 })
shadows.push(shadow(x, y, size * 0.34, scale(GRASS[3]!, 0.8), seed))
objects.push({ key: `t${i}:${j}`, depth: x + y, polys: toPolys(faces) }) objects.push({ key: `t${i}:${j}`, depth: x + y, polys: toPolys(faces) })
} }
} }
@ -554,6 +605,17 @@ export function buildScene(village: VillageState, aspect = 2.2): Scene {
if (at) timers.push({ orderId: o.id, finishesAt: o.finishes_at, at, buildingId: onBuilding ? o.building_id : null }) if (at) timers.push({ orderId: o.id, finishesAt: o.finishes_at, at, buildingId: onBuilding ? o.building_id : null })
} }
// Villagers walk from the plaza out to the zones they work in and back, more where more work.
const walks: Scene['walks'] = []
for (const zone of activeZones) {
const workers = village.buildings.filter((b) => ZONE_OF[b.type] === zone).reduce((n, b) => n + b.workers.assigned, 0)
if (!workers) continue
const end = zoneEnd(zone)
const d = walkPath(ZONES[zone].angle, hqRadius * 0.9, end + U * 0.5, ZONE_NAMES.indexOf(zone) + 2, hqRadius * 1.4, end - U * 1.2)
walks.push({ d, count: Math.min(3, Math.max(1, Math.round(workers / 6))), seconds: Math.max(16, ((end - hqRadius) / U) * 4.5) })
}
walks.push({ d: walkPath(FRONT, hqRadius * 0.9, Rz * 3, 1, hqRadius * 1.4, Rv + U * 5), count: 1, seconds: 40 })
objects.sort((a, b) => a.depth - b.depth) objects.sort((a, b) => a.depth - b.depth)
return { return {
viewBox: `${view.x.toFixed(1)} ${view.y.toFixed(1)} ${w.toFixed(1)} ${h.toFixed(1)}`, viewBox: `${view.x.toFixed(1)} ${view.y.toFixed(1)} ${w.toFixed(1)} ${h.toFixed(1)}`,
@ -561,9 +623,11 @@ export function buildScene(village: VillageState, aspect = 2.2): Scene {
height: h, height: h,
terrain: ground(view), terrain: ground(view),
// One at a time, so the layers keep the order they were added in. // One at a time, so the layers keep the order they were added in.
decals: decalFaces.flatMap((face) => toPolys([face])), decals: [...decalFaces, ...shadows].flatMap((face) => toPolys([face])),
objects: objects.map(({ key, polys, building, planned }) => ({ key, polys, building, planned })), objects: objects.map(({ key, polys, building, planned }) => ({ key, polys, building, planned })),
plots, plots,
timers, timers,
smoke,
walks,
} }
} }

View File

@ -5,12 +5,16 @@ const village = computed(() => v.village.value!)
const resources = computed(() => v.resources.value!) const resources = computed(() => v.resources.value!)
/** Show a building in the village overview, with its card open. */ /** Show a building in the village overview, with its card open. */
const hq = computed(() => village.value.buildings.find((b) => b.type === 'headquarters') ?? null)
const showInVillage = (id: number) => navigateTo({ path: `/village/${route.params.id}`, query: { b: id } }) const showInVillage = (id: number) => navigateTo({ path: `/village/${route.params.id}`, query: { b: id } })
</script> </script>
<!-- The headquarters screen: every building to construct, upgrade or tear down, and the queue. --> <!-- The headquarters screen: every building to construct, upgrade or tear down, and the queue. -->
<template> <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]"> <div class="mx-auto max-w-[96rem] space-y-6 px-4 py-6 sm:px-6">
<VillageScreenHeader type="headquarters" :level="hq?.level ?? null" :title="$t('buildings.headquarters')" :description="$t('village.about.build')" />
<div class="grid gap-6 lg:grid-cols-[minmax(0,1fr)_22rem] 2xl:grid-cols-[minmax(0,1fr)_26rem]">
<VillageBuildForm <VillageBuildForm
:options="village.buildable" :options="village.buildable"
:buildings="village.buildings" :buildings="village.buildings"
@ -31,4 +35,5 @@ const showInVillage = (id: number) => navigateTo({ path: `/village/${route.param
@cancel="v.cancel" @cancel="v.cancel"
/> />
</div> </div>
</div>
</template> </template>

View File

@ -5,11 +5,14 @@ const village = computed(() => v.village.value!)
/** `?x=&y=` from the map fills in the target. */ /** `?x=&y=` from the map fills in the target. */
const initialTarget = computed(() => (route.query.x && route.query.y ? { x: Number(route.query.x), y: Number(route.query.y) } : null)) const initialTarget = computed(() => (route.query.x && route.query.y ? { x: Number(route.query.x), y: Number(route.query.y) } : null))
const rallyPoint = computed(() => village.value.buildings.find((b) => b.type === 'rally_point') ?? null)
</script> </script>
<!-- The rally point: send troops, the troop movements, and support. --> <!-- The rally point: send troops, the troop movements, and support. -->
<template> <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]"> <div class="mx-auto max-w-[96rem] space-y-6 px-4 py-6 sm:px-6">
<VillageScreenHeader type="rally_point" :level="rallyPoint?.level ?? null" :title="$t('buildings.rally_point')" :description="$t('village.about.rally')" />
<div class="grid gap-6 lg:grid-cols-[minmax(0,1fr)_22rem] 2xl:grid-cols-[minmax(0,1fr)_26rem]">
<div class="min-w-0 space-y-6"> <div class="min-w-0 space-y-6">
<VillageSendTroops <VillageSendTroops
:key="`${route.query.x}|${route.query.y}`" :key="`${route.query.x}|${route.query.y}`"
@ -40,4 +43,5 @@ const initialTarget = computed(() => (route.query.x && route.query.y ? { x: Numb
@withdraw="v.withdraw" @withdraw="v.withdraw"
/> />
</div> </div>
</div>
</template> </template>

View File

@ -10,11 +10,19 @@ watch(
() => route.query.at, () => route.query.at,
(at) => (recruitAt.value = Number(at) || recruitAt.value), (at) => (recruitAt.value = Number(at) || recruitAt.value),
) )
const shown = computed(() => village.value.military.find((m) => m.building_id === recruitAt.value) ?? village.value.military[0] ?? null)
</script> </script>
<!-- Recruiting at every military building, the troops at home and the levy. --> <!-- Recruiting at every military building, the troops at home and the levy. -->
<template> <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]"> <div class="mx-auto max-w-[96rem] space-y-6 px-4 py-6 sm:px-6">
<VillageScreenHeader
:type="shown?.type ?? 'barracks'"
:level="shown?.level ?? null"
:title="shown ? $t(`buildings.${shown.type}`) : $t('village.screens.recruit')"
:description="$t('village.about.recruit')"
/>
<div class="grid gap-6 lg:grid-cols-[minmax(0,1fr)_22rem] 2xl:grid-cols-[minmax(0,1fr)_26rem]">
<VillageRecruit <VillageRecruit
v-if="village.military.length" v-if="village.military.length"
v-model:selected="recruitAt" v-model:selected="recruitAt"
@ -41,4 +49,5 @@ watch(
@end-levy="v.endLevy" @end-levy="v.endLevy"
/> />
</div> </div>
</div>
</template> </template>

View File

@ -3,13 +3,18 @@ const route = useRoute()
const v = useVillageContext() const v = useVillageContext()
const village = computed(() => v.village.value!) const village = computed(() => v.village.value!)
const farm = computed(() => [...village.value.buildings].filter((b) => b.type === 'farm').sort((a, b) => b.level - a.level)[0] ?? null)
const showInVillage = (id: number) => navigateTo({ path: `/village/${route.params.id}`, query: { b: id } }) const showInVillage = (id: number) => navigateTo({ path: `/village/${route.params.id}`, query: { b: id } })
</script> </script>
<!-- Who works where: staffing and priorities per building, and the population behind it. --> <!-- Who works where: staffing and priorities per building, and the population behind it. -->
<template> <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]"> <div class="mx-auto max-w-[96rem] space-y-6 px-4 py-6 sm:px-6">
<VillageScreenHeader type="farm" :level="farm?.level ?? null" :title="$t('village.screens.workforce')" :description="$t('village.about.workforce')" />
<div class="grid gap-6 lg:grid-cols-[minmax(0,1fr)_22rem] 2xl:grid-cols-[minmax(0,1fr)_26rem]">
<VillageBuildingTable :buildings="village.buildings" :busy="v.busy.value" @select="showInVillage" @priority="v.setPriority" /> <VillageBuildingTable :buildings="village.buildings" :busy="v.busy.value" @select="showInVillage" @priority="v.setPriority" />
<VillagePopulationPanel :population="village.population" :militia="village.levy.militia" /> <VillagePopulationPanel :population="village.population" :militia="village.levy.militia" />
</div> </div>
</div>
</template> </template>

View File

@ -17,6 +17,12 @@ export default {
workforce: 'Workforce', workforce: 'Workforce',
short: { overview: 'Village', build: 'Build', recruit: 'Recruit', rally: 'Rally', workforce: 'Workers' }, short: { overview: 'Village', build: 'Build', recruit: 'Recruit', rally: 'Rally', workforce: 'Workers' },
}, },
about: {
build: 'The heart of your village. Your builders put up new buildings here, upgrade them and tear them down. Every level builds faster and makes room for more.',
recruit: 'Barracks, stables, workshops and the academy train your army. Every soldier was a villager, and eats from your farms for as long as it serves.',
rally: 'Troops gather here before they march. Send attacks and support, follow your troop movements and see who is coming.',
workforce: 'Villagers staff your buildings, the farms first. Priorities decide who works where; understaffed buildings produce less.',
},
side: { side: {
production: 'Production', production: 'Production',
units: 'Units', units: 'Units',