2026-10-28 18:54:20 +00:00
|
|
|
<script setup lang="ts">
|
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
|
|
|
import type { BuildingType, Resources, VillageState } from '~/types/game'
|
2026-10-29 15:08:57 +00:00
|
|
|
import { drillThrust, workInPlace } from '~/diorama/life'
|
2026-10-29 10:15:26 +00:00
|
|
|
import { buildScene, type SceneBuilding, type SceneInset, type ScenePlot } from '~/diorama/scene'
|
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
|
|
|
import type { BuildingTag } from '~/utils/buildingTags'
|
2026-10-28 18:54:20 +00:00
|
|
|
|
2026-10-28 20:03:51 +00:00
|
|
|
const props = defineProps<{
|
|
|
|
|
village: VillageState
|
|
|
|
|
/** Whole seconds until a server timestamp, on the server's clock. */
|
|
|
|
|
secondsUntil: (iso: string) => number
|
2026-10-29 09:56:52 +00:00
|
|
|
/** Fill the whole stage at any shape, without the sideways scroll of narrow frames. */
|
|
|
|
|
fill?: boolean
|
2026-10-29 10:15:26 +00:00
|
|
|
/** With `fill`: pixels at the edges that windows cover; the whole village fits into the rest. */
|
|
|
|
|
inset?: SceneInset
|
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
|
|
|
/** Projected stock, for the storage's tag. */
|
|
|
|
|
resources?: Resources | null
|
|
|
|
|
/** A window or card is open: a click in the village closes it instead of opening another. */
|
|
|
|
|
dismiss?: boolean
|
2026-10-28 20:03:51 +00:00
|
|
|
}>()
|
2026-10-28 18:54:20 +00:00
|
|
|
/** Id of the building whose details are open. */
|
|
|
|
|
const selected = defineModel<number | null>('selected', { default: null })
|
2026-10-28 21:14:56 +00:00
|
|
|
/** Type whose empty plot was picked, to build it. */
|
|
|
|
|
const plot = defineModel<BuildingType | null>('plot', { default: null })
|
2026-10-28 18:54:20 +00:00
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
2026-10-28 19:33:14 +00:00
|
|
|
// The scene is cut to the stage's shape, so the land always fills it edge to edge.
|
|
|
|
|
// On narrow screens the stage keeps a minimum width and scrolls sideways instead.
|
|
|
|
|
const scroller = ref<HTMLElement | null>(null)
|
|
|
|
|
const stage = ref<HTMLElement | null>(null)
|
|
|
|
|
const size = ref({ w: 1200, h: 520 })
|
|
|
|
|
const aspect = computed(() => Math.round((size.value.w / Math.max(1, size.value.h)) * 10) / 10)
|
2026-10-29 10:15:26 +00:00
|
|
|
const scene = computed(() =>
|
|
|
|
|
props.fill ? buildScene(props.village, { width: size.value.w, height: size.value.h, inset: props.inset }) : buildScene(props.village, aspect.value),
|
|
|
|
|
)
|
2026-10-28 18:54:20 +00:00
|
|
|
|
|
|
|
|
function measure() {
|
2026-10-28 19:33:14 +00:00
|
|
|
const el = stage.value
|
|
|
|
|
if (el && el.clientWidth && el.clientHeight) size.value = { w: el.clientWidth, h: el.clientHeight }
|
2026-10-28 18:54:20 +00:00
|
|
|
}
|
|
|
|
|
let observer: ResizeObserver | undefined
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
measure()
|
|
|
|
|
observer = new ResizeObserver(measure)
|
2026-10-28 19:33:14 +00:00
|
|
|
if (stage.value) observer.observe(stage.value)
|
|
|
|
|
// Start a scrolled phone view on the village centre.
|
|
|
|
|
const sc = scroller.value
|
|
|
|
|
if (sc) sc.scrollLeft = (sc.scrollWidth - sc.clientWidth) / 2
|
2026-10-28 18:54:20 +00:00
|
|
|
})
|
|
|
|
|
onBeforeUnmount(() => observer?.disconnect())
|
|
|
|
|
|
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>
2026-10-28 23:46:15 +00:00
|
|
|
// 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']
|
2026-10-29 15:43:23 +00:00
|
|
|
/** Soldiers wear the village colour under the shield. */
|
|
|
|
|
const UNIFORM = '#57391f'
|
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>
2026-10-28 23:46:15 +00:00
|
|
|
|
2026-10-28 19:33:14 +00:00
|
|
|
const name = (b: SceneBuilding) => t(`buildings.${b.type}`)
|
|
|
|
|
const label = (b: SceneBuilding) => t('village.diorama.label', { name: name(b), level: b.level })
|
2026-10-28 21:14:56 +00:00
|
|
|
const plotLabel = (p: ScenePlot) => t(p.another ? 'village.diorama.plot_another' : 'village.diorama.plot', { name: t(`buildings.${p.type}`) })
|
2026-10-28 18:54:20 +00:00
|
|
|
|
2026-10-28 21:14:56 +00:00
|
|
|
// Buildings stand still: hovering changes nothing but the cursor and the tooltip.
|
|
|
|
|
// A click opens the details and marks the ground under it.
|
2026-10-28 19:33:14 +00:00
|
|
|
function toggle(id: number) {
|
2026-10-28 21:14:56 +00:00
|
|
|
plot.value = null
|
2026-10-28 19:33:14 +00:00
|
|
|
selected.value = selected.value === id ? null : id
|
|
|
|
|
}
|
2026-10-28 21:14:56 +00:00
|
|
|
function pick(type: BuildingType) {
|
|
|
|
|
selected.value = null
|
|
|
|
|
plot.value = plot.value === type ? null : type
|
|
|
|
|
}
|
|
|
|
|
function clear() {
|
|
|
|
|
selected.value = null
|
|
|
|
|
plot.value = null
|
|
|
|
|
}
|
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
|
|
|
// A pointer click while something is open only closes it, so a stray click never swaps
|
|
|
|
|
// the window for another; keys still open what has focus.
|
|
|
|
|
const press = (id: number) => (props.dismiss ? clear() : toggle(id))
|
|
|
|
|
const pressPlot = (type: BuildingType) => (props.dismiss ? clear() : pick(type))
|
2026-10-28 18:54:20 +00:00
|
|
|
|
2026-10-28 19:33:14 +00:00
|
|
|
/** viewBox units per screen pixel: badges keep the same size however the scene is scaled. */
|
|
|
|
|
const k = computed(() => (scene.value.width / Math.max(1, size.value.w)) * (size.value.w < 900 ? 0.85 : 1))
|
2026-10-28 18:54:20 +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
|
|
|
// Every building wears a tag like the old village views: its level and the one number
|
|
|
|
|
// that says what it does now (app/utils/buildingTags.ts). Sizes are screen pixels, scaled
|
|
|
|
|
// by k into the scene, so tags read the same however the village is scaled.
|
|
|
|
|
const TAG = { h: 20, chip: 20, icon: 14, gap: 4, pad: 6, font: 12 }
|
|
|
|
|
const FONT = 'ui-sans-serif, system-ui, sans-serif'
|
|
|
|
|
let measurer: CanvasRenderingContext2D | null = null
|
|
|
|
|
const widths = new Map<string, number>()
|
|
|
|
|
function textWidth(text: string) {
|
|
|
|
|
if (!widths.has(text)) {
|
|
|
|
|
measurer ??= import.meta.client ? document.createElement('canvas').getContext('2d') : null
|
|
|
|
|
if (measurer) measurer.font = `700 ${TAG.font}px ${FONT}`
|
|
|
|
|
widths.set(text, measurer ? Math.ceil(measurer.measureText(text).width) : text.length * 7.5)
|
|
|
|
|
}
|
|
|
|
|
return widths.get(text)!
|
|
|
|
|
}
|
|
|
|
|
const TONES = {
|
|
|
|
|
plain: { fill: '#f3e7c9', stroke: '#57391f', text: '#2f2013', icon: '#57391f' },
|
|
|
|
|
warn: { fill: '#e8cd7c', stroke: '#8a6a1c', text: '#2f2013', icon: '#57391f' },
|
|
|
|
|
alarm: { fill: '#7b1e16', stroke: '#4a120d', text: '#f3e7c9', icon: '#f3e7c9' },
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Tags that would overlap move up above the one in front, nearest buildings first.
|
2026-10-28 19:33:14 +00:00
|
|
|
const badges = computed(() => {
|
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
|
|
|
const K = k.value
|
2026-10-28 19:33:14 +00:00
|
|
|
const list = scene.value.objects.flatMap((o) => (o.building?.focusable ? [o.building] : []))
|
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
|
|
|
const placed: { b: SceneBuilding; info: BuildingTag | null; x: number; y: number; w: number; h: number }[] = []
|
|
|
|
|
const overlaps = (x: number, y: number, w: number, h: number) =>
|
|
|
|
|
placed.some((p) => Math.abs(p.x - x) < (p.w + w) / 2 + 2 * K && Math.abs(p.y - y) < (p.h + h) / 2 + 2 * K)
|
2026-10-28 19:33:14 +00:00
|
|
|
for (const b of [...list].sort((p, q) => q.label[1] - p.label[1])) {
|
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
|
|
|
const building = props.village.buildings.find((x) => x.id === b.id)
|
|
|
|
|
const info = building && props.resources ? buildingTag(props.village, building, props.resources, props.secondsUntil, t) : null
|
|
|
|
|
const inner = info ? TAG.pad + (info.icon ? TAG.icon + TAG.gap : 0) + textWidth(info.text) + TAG.pad : 0
|
|
|
|
|
const w = (TAG.chip + inner) * K
|
|
|
|
|
const h = TAG.h * K
|
2026-10-28 19:33:14 +00:00
|
|
|
const [x] = b.label
|
|
|
|
|
let y = b.label[1]
|
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
|
|
|
for (let n = 0; n < 8 && overlaps(x, y, w, h); n++) y -= h * 1.2
|
|
|
|
|
placed.push({ b, info, x, y, w, h })
|
2026-10-28 19:33:14 +00:00
|
|
|
}
|
|
|
|
|
return placed
|
|
|
|
|
})
|
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
|
|
|
const tagTitle = (b: SceneBuilding, info: BuildingTag | null) => [label(b), info?.title].filter(Boolean).join(' · ')
|
2026-10-28 20:03:51 +00:00
|
|
|
|
2026-10-28 21:14:56 +00:00
|
|
|
// Countdowns sit right above what is being built: over the level badge, or over the
|
|
|
|
|
// scaffold of a new building.
|
2026-10-28 20:03:51 +00:00
|
|
|
// A timer that would cover another timer or a level badge moves up until it is clear.
|
|
|
|
|
const timers = computed(() => {
|
|
|
|
|
const K = k.value
|
2026-10-29 13:09:03 +00:00
|
|
|
const half = { w: 41 * K, h: 12.5 * K }
|
2026-10-28 20:03:51 +00:00
|
|
|
const placed: { x: number; y: number }[] = []
|
|
|
|
|
const hits = (x: number, y: number) =>
|
|
|
|
|
placed.some((p) => Math.abs(p.x - x) < half.w * 2 && Math.abs(p.y - y) < half.h * 2) ||
|
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
|
|
|
badges.value.some((p) => Math.abs(p.x - x) < half.w + p.w / 2 && Math.abs(p.y - y) < half.h + p.h / 2)
|
2026-10-28 20:03:51 +00:00
|
|
|
return scene.value.timers
|
|
|
|
|
.map((tm) => {
|
|
|
|
|
const badge = tm.buildingId !== null ? badges.value.find((p) => p.b.id === tm.buildingId) : undefined
|
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
|
|
|
const lift = badge ? 24 : 2
|
2026-10-28 20:03:51 +00:00
|
|
|
return { ...tm, x: badge?.x ?? tm.at[0], y: (badge?.y ?? tm.at[1]) - lift * K }
|
|
|
|
|
})
|
|
|
|
|
.sort((a, b) => b.y - a.y)
|
|
|
|
|
.map((tm) => {
|
|
|
|
|
let y = tm.y
|
|
|
|
|
for (let n = 0; n < 8 && hits(tm.x, y); n++) y -= half.h * 2.1
|
|
|
|
|
placed.push({ x: tm.x, y })
|
|
|
|
|
return { ...tm, y }
|
|
|
|
|
})
|
|
|
|
|
})
|
2026-10-28 19:33:14 +00:00
|
|
|
</script>
|
2026-10-28 18:54:20 +00:00
|
|
|
|
2026-10-28 19:33:14 +00:00
|
|
|
<template>
|
2026-10-29 09:56:52 +00:00
|
|
|
<div ref="scroller" class="h-full w-full overflow-y-hidden bg-[#74864a]" :class="fill ? 'overflow-x-hidden' : 'overflow-x-auto'">
|
|
|
|
|
<div ref="stage" class="h-full" :class="fill ? '' : 'min-w-[640px]'">
|
2026-10-28 19:33:14 +00:00
|
|
|
<svg
|
|
|
|
|
class="block h-full w-full select-none"
|
|
|
|
|
:viewBox="scene.viewBox"
|
|
|
|
|
preserveAspectRatio="xMidYMid slice"
|
|
|
|
|
role="group"
|
|
|
|
|
:aria-label="$t('village.diorama.title')"
|
2026-10-28 21:14:56 +00:00
|
|
|
@click="clear"
|
2026-10-28 19:33:14 +00:00
|
|
|
>
|
|
|
|
|
<g stroke-width="0.6" stroke-linejoin="round">
|
|
|
|
|
<polygon v-for="(p, i) in scene.terrain" :key="`t${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" />
|
2026-10-28 18:54:20 +00:00
|
|
|
</g>
|
|
|
|
|
|
2026-10-29 14:50:07 +00:00
|
|
|
<!-- Villagers going out to work and bringing the load home, under the buildings they
|
|
|
|
|
walk into; sheep and chickens wandering. -->
|
2026-10-29 14:27:40 +00:00
|
|
|
<g v-if="motion" class="pointer-events-none">
|
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>
2026-10-28 23:46:15 +00:00
|
|
|
<template v-for="(w, i) in scene.walks" :key="`walk-${i}-${w.d.length}`">
|
2026-10-29 14:50:07 +00:00
|
|
|
<VillageWorker
|
|
|
|
|
v-for="n in w.count"
|
|
|
|
|
:key="n"
|
|
|
|
|
:d="w.d"
|
|
|
|
|
:walk="w.walk"
|
|
|
|
|
:work="w.work"
|
|
|
|
|
:tool="w.tool"
|
|
|
|
|
:carry="w.carry"
|
|
|
|
|
:shirt="SHIRTS[(i * 3 + n) % SHIRTS.length]!"
|
|
|
|
|
:size="1.6"
|
|
|
|
|
:begin="-((n - 1) * (w.walk * 2 + w.work)) / w.count - i * 3"
|
|
|
|
|
/>
|
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>
2026-10-28 23:46:15 +00:00
|
|
|
</template>
|
2026-10-29 14:50:07 +00:00
|
|
|
<VillageAnimal v-for="(a, i) in scene.herds" :key="`herd-${i}`" :kind="a.kind" :d="a.d" :dur="a.dur" :begin="a.begin" :size="a.kind === 'sheep' ? 1.7 : 1.4" />
|
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>
2026-10-28 23:46:15 +00:00
|
|
|
</g>
|
|
|
|
|
|
2026-10-28 21:14:56 +00:00
|
|
|
<!-- Empty plots: nothing to see, but each opens its building type's build card. -->
|
|
|
|
|
<ellipse
|
|
|
|
|
v-for="p in scene.plots"
|
|
|
|
|
:key="p.key"
|
|
|
|
|
class="plot"
|
|
|
|
|
:class="{ 'is-selected': plot === p.type }"
|
|
|
|
|
v-bind="p.ring"
|
|
|
|
|
role="button"
|
|
|
|
|
tabindex="0"
|
|
|
|
|
:aria-label="plotLabel(p)"
|
|
|
|
|
:aria-pressed="plot === p.type"
|
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
|
|
|
@click.stop="pressPlot(p.type)"
|
2026-10-28 21:14:56 +00:00
|
|
|
@keydown.enter.prevent="pick(p.type)"
|
|
|
|
|
@keydown.space.prevent="pick(p.type)"
|
|
|
|
|
>
|
|
|
|
|
<title>{{ plotLabel(p) }}</title>
|
|
|
|
|
</ellipse>
|
|
|
|
|
|
2026-10-29 13:09:03 +00:00
|
|
|
<!-- The wall is thin: a wide band along its ring opens it too. -->
|
|
|
|
|
<ellipse
|
|
|
|
|
v-if="scene.wallBand"
|
|
|
|
|
class="band"
|
|
|
|
|
v-bind="scene.wallBand.ring"
|
|
|
|
|
:stroke-width="scene.wallBand.width"
|
|
|
|
|
aria-hidden="true"
|
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
|
|
|
@click.stop="press(scene.wallBand.id)"
|
2026-10-29 13:09:03 +00:00
|
|
|
/>
|
|
|
|
|
|
2026-10-28 19:33:14 +00:00
|
|
|
<template v-for="obj in scene.objects" :key="obj.key">
|
|
|
|
|
<g
|
|
|
|
|
v-if="obj.building"
|
2026-10-28 21:14:56 +00:00
|
|
|
v-memo="[obj, selected === obj.building.id]"
|
2026-10-28 19:33:14 +00:00
|
|
|
class="bld"
|
2026-10-28 21:14:56 +00:00
|
|
|
:class="{ 'is-selected': selected === obj.building.id }"
|
2026-10-28 19:33:14 +00:00
|
|
|
:role="obj.building.focusable ? 'button' : undefined"
|
|
|
|
|
:tabindex="obj.building.focusable ? 0 : -1"
|
|
|
|
|
:aria-hidden="obj.building.focusable ? undefined : 'true'"
|
|
|
|
|
:aria-label="obj.building.focusable ? label(obj.building) : undefined"
|
|
|
|
|
:aria-pressed="obj.building.focusable ? selected === obj.building.id : undefined"
|
|
|
|
|
stroke-width="0.6"
|
|
|
|
|
stroke-linejoin="round"
|
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
|
|
|
@click.stop="press(obj.building.id)"
|
2026-10-28 19:33:14 +00:00
|
|
|
@keydown.enter.prevent="toggle(obj.building.id)"
|
|
|
|
|
@keydown.space.prevent="toggle(obj.building.id)"
|
|
|
|
|
>
|
2026-10-29 13:09:03 +00:00
|
|
|
<polygon v-if="obj.building.hit" class="hit" :points="obj.building.hit" />
|
2026-10-28 19:33:14 +00:00
|
|
|
<ellipse v-if="obj.building.ring.rx" class="ring" v-bind="obj.building.ring" />
|
|
|
|
|
<polygon v-for="(p, i) in obj.polys" :key="i" :points="p.points" :fill="p.fill" :stroke="p.stroke" />
|
|
|
|
|
<title>{{ label(obj.building) }}</title>
|
|
|
|
|
</g>
|
2026-10-29 15:43:23 +00:00
|
|
|
<!-- Villagers who stay put: talking, hammering at a building in the works, drilling;
|
|
|
|
|
soldiers standing guard at the doors. -->
|
2026-10-29 14:50:07 +00:00
|
|
|
<g v-else-if="obj.life" class="pointer-events-none" :transform="`translate(${obj.life.at[0]} ${obj.life.at[1]})`">
|
2026-10-29 15:43:23 +00:00
|
|
|
<g v-if="obj.life.guard" transform="scale(1.6)">
|
|
|
|
|
<VillageWalker :shirt="UNIFORM" :facing="obj.life.facing" tool="spear" soldier />
|
|
|
|
|
</g>
|
|
|
|
|
<g v-else transform="scale(1.6)">
|
2026-10-29 14:50:07 +00:00
|
|
|
<animateTransform
|
|
|
|
|
v-if="motion && !obj.life.tool"
|
|
|
|
|
attributeName="transform"
|
|
|
|
|
type="translate"
|
|
|
|
|
values="0 0;0 -0.5;0 0;0 0"
|
|
|
|
|
keyTimes="0;0.15;0.3;1"
|
|
|
|
|
:dur="`${2.2 + (obj.life.shirt % 3) * 0.4}s`"
|
|
|
|
|
additive="sum"
|
|
|
|
|
repeatCount="indefinite"
|
|
|
|
|
/>
|
|
|
|
|
<VillageWalker
|
|
|
|
|
:shirt="SHIRTS[obj.life.shirt % SHIRTS.length]!"
|
|
|
|
|
:facing="obj.life.facing"
|
|
|
|
|
:tool="obj.life.tool"
|
2026-10-29 15:08:57 +00:00
|
|
|
:swing="motion && obj.life.tool ? (obj.life.drill ? drillThrust() : workInPlace()) : null"
|
2026-10-29 14:50:07 +00:00
|
|
|
/>
|
|
|
|
|
</g>
|
|
|
|
|
</g>
|
2026-10-29 15:08:57 +00:00
|
|
|
<!-- Villagers coming out of a door and going back in, porters bringing materials. -->
|
|
|
|
|
<g v-else-if="obj.walker" class="pointer-events-none">
|
|
|
|
|
<VillageWorker
|
|
|
|
|
v-if="motion"
|
|
|
|
|
:d="obj.walker.d"
|
|
|
|
|
:walk="obj.walker.walk"
|
|
|
|
|
:work="obj.walker.work"
|
|
|
|
|
:rest="obj.walker.rest"
|
|
|
|
|
:indoors="obj.walker.indoors"
|
|
|
|
|
:tool="obj.walker.tool"
|
|
|
|
|
:carry="obj.walker.carry"
|
2026-10-29 15:43:23 +00:00
|
|
|
:soldier="obj.walker.soldier"
|
|
|
|
|
:shirt="obj.walker.soldier ? UNIFORM : SHIRTS[obj.walker.shirt % SHIRTS.length]!"
|
2026-10-29 15:08:57 +00:00
|
|
|
:size="1.6"
|
|
|
|
|
:begin="obj.walker.begin"
|
|
|
|
|
/>
|
|
|
|
|
</g>
|
2026-10-28 19:33:14 +00:00
|
|
|
<g v-else v-memo="[obj]" stroke-width="0.6" stroke-linejoin="round">
|
|
|
|
|
<polygon v-for="(p, i) in obj.polys" :key="i" :points="p.points" :fill="p.fill" :stroke="p.stroke" />
|
|
|
|
|
<title v-if="obj.planned">{{ $t('village.diorama.planned') }}</title>
|
|
|
|
|
</g>
|
|
|
|
|
</template>
|
|
|
|
|
|
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>
2026-10-28 23:46:15 +00:00
|
|
|
<!-- 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>
|
|
|
|
|
|
2026-10-29 14:50:07 +00:00
|
|
|
<!-- Birds crossing now and then. -->
|
|
|
|
|
<g v-if="motion" class="pointer-events-none">
|
|
|
|
|
<VillageBird v-for="(b, i) in scene.birds" :key="`bird-${i}`" :d="b.d" :dur="b.dur" :begin="b.begin" :size="1.6" />
|
|
|
|
|
</g>
|
|
|
|
|
|
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
|
|
|
<!-- Building tags (level and what it does now) and countdowns. Flat colours only. -->
|
|
|
|
|
<g class="pointer-events-none" :font-family="FONT" text-anchor="middle">
|
2026-10-29 13:09:03 +00:00
|
|
|
<g
|
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
|
|
|
v-for="{ b, info, x, y, w } in badges"
|
2026-10-29 13:09:03 +00:00
|
|
|
:key="`badge-${b.id}`"
|
|
|
|
|
class="pointer-events-auto cursor-pointer"
|
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
|
|
|
:transform="`translate(${x - w / 2} ${y}) scale(${k})`"
|
|
|
|
|
@click.stop="press(b.id)"
|
2026-10-29 13:09:03 +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
|
|
|
<title>{{ tagTitle(b, info) }}</title>
|
|
|
|
|
<rect
|
|
|
|
|
:width="w / k"
|
|
|
|
|
:height="TAG.h"
|
|
|
|
|
:y="-TAG.h / 2"
|
|
|
|
|
:fill="TONES[info?.tone ?? 'plain'].fill"
|
|
|
|
|
:stroke="selected === b.id ? '#7b1e16' : TONES[info?.tone ?? 'plain'].stroke"
|
|
|
|
|
:stroke-width="selected === b.id ? 2.4 : 1.4"
|
2026-10-28 18:54:20 +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
|
|
|
<rect :width="TAG.chip" :height="TAG.h" :y="-TAG.h / 2" :fill="b.upgrading ? '#c49a2c' : '#57391f'" />
|
|
|
|
|
<text :x="TAG.chip / 2" :y="4.3" :font-size="TAG.font" font-weight="700" :fill="b.upgrading ? '#1f150c' : '#f3e7c9'">{{ b.level }}</text>
|
|
|
|
|
<template v-if="info">
|
|
|
|
|
<g v-if="info.icon" :transform="`translate(${TAG.chip + TAG.pad} ${-TAG.icon / 2})`" :style="{ color: TONES[info.tone].icon }">
|
|
|
|
|
<IconResource v-if="info.icon.kind === 'resource'" :resource="info.icon.name" :width="TAG.icon" :height="TAG.icon" />
|
|
|
|
|
<IconUnit v-else-if="info.icon.kind === 'unit'" :unit="info.icon.name" :width="TAG.icon" :height="TAG.icon" />
|
|
|
|
|
<IconUi v-else :name="info.icon.name" :width="TAG.icon" :height="TAG.icon" />
|
|
|
|
|
</g>
|
|
|
|
|
<text
|
|
|
|
|
:x="TAG.chip + TAG.pad + (info.icon ? TAG.icon + TAG.gap : 0)"
|
|
|
|
|
:y="4.3"
|
|
|
|
|
text-anchor="start"
|
|
|
|
|
:font-size="TAG.font"
|
|
|
|
|
font-weight="700"
|
|
|
|
|
:fill="TONES[info.tone].text"
|
|
|
|
|
>
|
|
|
|
|
{{ info.text }}
|
|
|
|
|
</text>
|
|
|
|
|
</template>
|
2026-10-28 18:54:20 +00:00
|
|
|
</g>
|
2026-10-28 20:03:51 +00:00
|
|
|
|
2026-10-29 13:09:03 +00:00
|
|
|
<g
|
|
|
|
|
v-for="tm in timers"
|
|
|
|
|
:key="`timer-${tm.orderId}`"
|
|
|
|
|
:class="tm.buildingId ? 'pointer-events-auto cursor-pointer' : ''"
|
|
|
|
|
:transform="`translate(${tm.x} ${tm.y})`"
|
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
|
|
|
@click.stop="tm.buildingId && press(tm.buildingId)"
|
2026-10-29 13:09:03 +00:00
|
|
|
>
|
|
|
|
|
<rect :x="-39 * k" :y="-11.5 * k" :width="78 * k" :height="22 * k" :rx="2 * k" fill="#2f2013" stroke="#c49a2c" :stroke-width="1.2 * k" />
|
|
|
|
|
<g :transform="`translate(${-27.5 * k} ${-0.5 * k}) scale(${1.15 * k})`" fill="none" stroke="#d9b44a" stroke-width="1.4" stroke-linecap="round">
|
2026-10-28 20:03:51 +00:00
|
|
|
<circle r="5" />
|
|
|
|
|
<path d="M0 -3v3l2 1.5" />
|
|
|
|
|
</g>
|
2026-10-29 13:09:03 +00:00
|
|
|
<text :x="7 * k" :y="4.6 * k" :font-size="13 * k" font-weight="700" fill="#f3e7c9" class="tabular-nums">
|
2026-10-28 20:03:51 +00:00
|
|
|
{{ formatDuration(secondsUntil(tm.finishesAt)) }}
|
|
|
|
|
</text>
|
|
|
|
|
</g>
|
2026-10-28 18:54:20 +00:00
|
|
|
</g>
|
2026-10-28 19:33:14 +00:00
|
|
|
</svg>
|
|
|
|
|
</div>
|
2026-10-28 18:54:20 +00:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2026-10-28 21:14:56 +00:00
|
|
|
/* Buildings are massive and stay put: no lift, no glow, nothing on hover. Only a click
|
|
|
|
|
(or keyboard focus) outlines the ground they stand on. */
|
|
|
|
|
.bld,
|
|
|
|
|
.plot {
|
2026-10-28 18:54:20 +00:00
|
|
|
cursor: pointer;
|
|
|
|
|
outline: none;
|
|
|
|
|
}
|
2026-10-28 21:14:56 +00:00
|
|
|
.ring,
|
2026-10-29 13:09:03 +00:00
|
|
|
.plot,
|
|
|
|
|
.hit {
|
2026-10-28 18:54:20 +00:00
|
|
|
fill: transparent;
|
|
|
|
|
stroke: transparent;
|
|
|
|
|
}
|
2026-10-29 13:09:03 +00:00
|
|
|
.band {
|
|
|
|
|
fill: none;
|
|
|
|
|
stroke: transparent;
|
|
|
|
|
pointer-events: stroke;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
2026-10-28 21:14:56 +00:00
|
|
|
.bld.is-selected .ring,
|
|
|
|
|
.plot.is-selected {
|
2026-10-28 19:33:14 +00:00
|
|
|
stroke: #7b1e16;
|
2026-10-28 18:54:20 +00:00
|
|
|
stroke-width: 2;
|
|
|
|
|
}
|
2026-10-28 21:14:56 +00:00
|
|
|
.bld:focus-visible .ring,
|
|
|
|
|
.plot:focus-visible {
|
2026-10-28 19:33:14 +00:00
|
|
|
stroke: #7b1e16;
|
2026-10-28 18:54:20 +00:00
|
|
|
stroke-width: 2;
|
|
|
|
|
stroke-dasharray: 4 3;
|
|
|
|
|
}
|
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>
2026-10-28 23:46:15 +00:00
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-10-28 18:54:20 +00:00
|
|
|
</style>
|