diff --git a/CLAUDE.md b/CLAUDE.md index 58e80b3..4b77eb2 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -8,9 +8,9 @@ This is the Nuxt client for a browser strategy game in the style of Tribal Wars. - **`ssr: false` for every target**, so one static build serves both the web and Steam. Code must not rely on Nuxt server routes or SSR-only APIs. - **Transport** is WS-first through the `ws` singleton from `@blax-software/networking`, the same as learn-atc. HTTP is only for login and register, which return the bearer token. Load the `blax-websockets` skill before you write `ws.send` or `ws.listen` code. - **Dense and plain, like the old browser strategy games** (the reference is Die Stämme; notes and screenshots in the sibling repo `game-village-politics-research` (`../game-village-politics-research/die-staemme/`), kept out of this repo). A 16 px root (17 px from 1800 px wide; rem sizes only, `text-sm` for body text, no fixed `text-[13px]`), square frames with thin lines, tan header bands, tight table rows (`.grid-table`), small squared buttons (`.btn-primary` dark wood, `.btn-attack` red for attacks only), thin notice bars. Actions are buttons, not text links: `.btn` for screen links and commands, `.btn-fill` for the "(20)" that fills an amount field; names inside lists and tables stay links. Bigger text must not add line wraps: keep rows `whitespace-nowrap` where they were one line. No rounded cards, pills, big padding or decorative icons: an icon only where it carries meaning. Theme and component classes live in `app/assets/css/main.css`; hand-written inline SVG graphics in `app/components/icon/`, colours in `app/utils/palette.ts`. No paid, hosted or licensed assets: no icon packs, web fonts or images from outside the repo, and nothing copied from Die Stämme. -- **The village is a ground-level land view** (`app/components/village/Diorama.vue`, geometry in `app/diorama/`): isometric low-poly, drawn as inline SVG, no WebGL. The land fills the frame edge to edge (no island, no sky), cut to the container's shape; narrow screens scroll sideways. There are no tiles or positions: the server only sends each building's `space` and the village's `space.used/max`, and the client lays everything out deterministically in id order. The village core sits in the middle (headquarters on the plaza, storage, hiding places and rally point around it, inside the wall ring when there is one, a dirt edge without). Resource sites stand outside in their zones: iron mines at the rocky hill (upper left), clay pits on clay ground (lower left), timber camps at the forest edge (lower right), farms with fields (right); dirt roads lead from the gates to each zone and forest fills the rest. Levels start at 1. Each type has a model per level tier (1–4, 5–14, 15+); the wall goes stakes → timber → stone with towers. Buildings are focusable buttons that open their details card, clickable anywhere on their outline (`hit`, a convex hull round their polygons and ground ring), the thin wall also along a wide band on its ring, and their level badges and countdowns as well; a type that doesn't stand yet keeps an invisible empty plot that opens its build card. Buildings never move or light up on hover: only a click outlines the ground under them. Ambient life is welcome and stays out of the way: flat ground shadows, smoke from chimneys, forges and kilns, villagers walking the roads to the zones they work in; all motion stops under `prefers-reduced-motion`. The same models draw the building portraits on screen headers, the HQ list and the building cards (`VillageBuildingPortrait`). The world map groups forests, lakes and rocky hills by smooth noise of the coordinates, and village markers grow in five sizes with points. Map coordinates run around 0|0, negative included (−500 to 499 on a 1000-field map, lowest value from `map.view`'s `min`); continents are named from the top-left like Die Stämme, so 0|0 is the corner of K44, K45, K54 and K55. Use `app/utils/map.ts` for bounds and continents, never `0` or `500` literals. +- **The village is a ground-level land view** (`app/components/village/Diorama.vue`, geometry in `app/diorama/`): isometric low-poly, drawn as inline SVG, no WebGL. The land fills the frame edge to edge (no island, no sky), cut to the container's shape; narrow screens scroll sideways. There are no tiles or positions: the server only sends each building's `space` and the village's `space.used/max`, and the client lays everything out deterministically in id order. The village core sits in the middle (headquarters on the plaza, storage, hiding places and rally point around it, inside the wall ring when there is one, a dirt edge without). Resource sites stand outside in their zones: iron mines at the rocky hill (upper left), clay pits on clay ground (lower left), timber camps at the forest edge (lower right), farms with fields (right); dirt roads lead from the gates to each zone and forest fills the rest. Levels start at 1. Each type has a model per level tier (1–4, 5–14, 15+); the wall goes stakes → timber → stone with towers. Buildings are focusable buttons that enter the building (`buildingRoute`): the headquarters opens construction, the rally point its commands, a military building its recruiting, every other building its own screen (`/village//building/`); each of these screens starts with `VillageBuildingHeader`: a close-up (`VillageCloseup`, `app/diorama/closeup.ts`: the building large on its ground, its props and forest, its assigned workers walking to where they work and back carrying what they make), what it does now and one level up (`effects`/`next_effects` from the server), workers, priority, upgrade and demolish. The open building stays outlined in the village, and clicking it again returns to the overview. Buildings are clickable anywhere on their outline (`hit`, a convex hull round their polygons and ground ring), the thin wall also along a wide band on its ring, and their level badges and countdowns as well; a type that doesn't stand yet keeps an invisible empty plot that opens its build card. Buildings never move or light up on hover: only a click outlines the ground under them. Ambient life is welcome and stays out of the way: flat ground shadows, smoke from chimneys, forges and kilns, villagers walking the roads to the zones they work in; all motion stops under `prefers-reduced-motion`. The same models draw the building portraits on screen headers, the HQ list and the building cards (`VillageBuildingPortrait`). The world map groups forests, lakes and rocky hills by smooth noise of the coordinates, and village markers grow in five sizes with points. Map coordinates run around 0|0, negative included (−500 to 499 on a 1000-field map, lowest value from `map.view`'s `min`); continents are named from the top-left like Die Stämme, so 0|0 is the corner of K44, K45, K54 and K55. Use `app/utils/map.ts` for bounds and continents, never `0` or `500` literals. - **Flat medieval colours only**, in the diorama and everywhere else: no gradients (CSS or SVG), no blur or backdrop-blur, no SVG filters or glows, no translucent overlays. Depth comes from the three flat shades per face in `app/diorama/iso.ts`, solid borders and hard shadows. Keep components small and typed, with state in composables (`useVillage`, `useWorld`). -- **The village fills the screen.** On the village's own screens (`/village//…`) `GameVillageFrame` draws the diorama fixed across the whole browser window and docks everything over it, solid and opaque: the menu and the village bar along the top, the overview boxes in a right column (on phones a bottom sheet on the overview), and the open screen (headquarters, recruit, rally point, workforce) in a `UiWindow` on the left that folds and closes back to the overview; on the overview the left slot holds the card of the building picked in the village (`useVillageSelection`). Screen grids inside a window use container queries (`@4xl:`), not viewport breakpoints. The village scales to fit, no pan: the frame measures what the bars, the right column, the phone tab bar and the bottom sheet cover (`inset`), `buildScene` fits the whole village into the rest, and ground and forest are generated for the whole stage, so nothing of the village is ever cut off. Windows are docked now and meant to become draggable later, so `UiWindow` holds no position logic. This is where the game deliberately leaves Die Stämme's look behind. +- **The village fills the screen.** On the village's own screens (`/village//…`) `GameVillageFrame` draws the diorama fixed across the whole browser window and docks everything over it, solid and opaque: the menu and the village bar along the top, the overview boxes in a right column (on phones a bottom sheet on the overview), and the open screen (headquarters, recruit, rally point, workforce) in a `UiWindow` on the left that folds and closes back to the overview; on the overview the left slot holds the build card of an empty plot picked in the village (`useVillageSelection`). Screen grids inside a window use container queries (`@4xl:`), not viewport breakpoints. The village scales to fit, no pan: the frame measures what the bars, the right column, the phone tab bar and the bottom sheet cover (`inset`), `buildScene` fits the whole village into the rest, and ground and forest are generated for the whole stage, so nothing of the village is ever cut off. Windows are docked now and meant to become draggable later, so `UiWindow` holds no position logic. This is where the game deliberately leaves Die Stämme's look behind. - **One game shell for the rest.** The map and reports sit in one centred column (1100 px). All world pages use `layouts/game.vue` (on village screens `GameVillageFrame` draws the same parts over the village): the dark main menu (`GameMenuBar`: village, map, reports with its count inline, each with a hover dropdown of its sub-pages; server clock; account dropdown), then the village header (`GameVillageBar`, in two pieces with the village showing between them: on the left the quick bar with the village's screens over the village row, on the right the stock in thin cells and incoming troops; the space between lets clicks through), thin notices, and the content in a `.frame`. On phones the screens move to a bottom tab bar (`GameTabBar`). The header's village is the URL's on village screens and the last opened one elsewhere; `GameVillageFrame` holds its one `useVillage()` and shares it through `useVillageContext()`. Pages outside a world use `layouts/default.vue` (menu only). A page has one of two shapes: a title with box tabs (`UiSubTabs`: buildings like the rally point) or a title with a sub-menu on the left (`UiSideMenu`: lists like reports). One key per screen (`useShortcuts`): V overview, H headquarters, T recruit, P rally point, W workforce, M map, R reports. The overview stays clean: the village and a narrow column of boxes (incoming attacks, production, units, population, construction); tables live on the building screens. The map shows a popup over a hovered village and actions under a clicked one. The village row starts with the quest book (`QuestBook`, a native `` without a veil): it opens by itself when `quests.claimable` goes up, and a goal's "show me" opens its screen, a building goal the headquarters with `?hint=` marking that row. - All user-facing text goes through i18n keys, with `en` as the first locale. Sources are `i18n/locales/` and `i18n/pages/` (`@blax-software/i18n` layout); register a new page file in `i18n/messageloader.ts`. vue-i18n reads a bare `|` as a plural separator and drops what follows, so coordinates in messages are written `"{x}{'|'}{y}"` inside a double-quoted string. diff --git a/app/components/game/VillageFrame.vue b/app/components/game/VillageFrame.vue index 868199e..e3fce51 100644 --- a/app/components/game/VillageFrame.vue +++ b/app/components/game/VillageFrame.vue @@ -38,18 +38,32 @@ const route = useRoute() const base = computed(() => `/village/${props.villageId}`) const stage = computed(() => route.path.startsWith(base.value)) const overview = computed(() => route.path === base.value || route.path === `${base.value}/`) -const { selected, plot, clear } = useVillageSelection() +const { plot, clear } = useVillageSelection() clear() -// Picking something in the village opens its card, which lives on the overview. -watch([selected, plot], ([b, p]) => { - if ((b || p) && stage.value && !overview.value) navigateTo(base.value) +// An empty plot's build card lives on the overview. +watch(plot, (p) => { + if (p && stage.value && !overview.value) navigateTo(base.value) +}) +// Clicking a building enters it: its screen opens in the window, and the building stays +// outlined in the village while it is open. Clicking it again goes back to the overview. +const openBuilding = computed(() => (v.village.value ? buildingOfRoute(v.village.value, route.path, route.query) : null)) +const selected = computed({ + get: () => openBuilding.value?.id ?? null, + set: (id) => { + const village = v.village.value + const building = id !== null ? village?.buildings.find((b) => b.id === id) : null + navigateTo(village && building ? buildingRoute(village, building) : base.value) + }, }) const { t } = useI18n() const screenTitle = computed(() => { + if (route.path.startsWith(`${base.value}/building/`) && openBuilding.value && v.village.value) { + return buildingName(v.village.value, openBuilding.value, t) + } const s = VILLAGE_SCREENS.find((s) => s.path && route.path.startsWith(`${base.value}${s.path}`)) return s ? t(`village.screens.${s.name}`) : '' }) -const picked = computed(() => !!(selected.value || plot.value)) +const picked = computed(() => !!plot.value) // What the bars, the right column and the phone tab bar cover, so the whole village fits diff --git a/app/components/village/BuildingCard.vue b/app/components/village/BuildingCard.vue deleted file mode 100644 index 5319829..0000000 --- a/app/components/village/BuildingCard.vue +++ /dev/null @@ -1,113 +0,0 @@ - - - - diff --git a/app/components/village/BuildingHeader.vue b/app/components/village/BuildingHeader.vue new file mode 100644 index 0000000..6b0fe23 --- /dev/null +++ b/app/components/village/BuildingHeader.vue @@ -0,0 +1,149 @@ + + + + diff --git a/app/components/village/Closeup.vue b/app/components/village/Closeup.vue new file mode 100644 index 0000000..9c6c613 --- /dev/null +++ b/app/components/village/Closeup.vue @@ -0,0 +1,54 @@ + + + + diff --git a/app/composables/useVillageSelection.ts b/app/composables/useVillageSelection.ts index c4dc671..faf7226 100644 --- a/app/composables/useVillageSelection.ts +++ b/app/composables/useVillageSelection.ts @@ -1,15 +1,13 @@ import type { BuildingType } from '~/types/game' /** - * What is picked in the fullscreen village: a building (its card opens in the window) - * or the empty plot of a type that doesn't stand yet (its build card). + * The empty plot picked in the fullscreen village: a type that doesn't stand yet, whose + * build card opens on the overview. Buildings open their own screens instead. */ export function useVillageSelection() { - const selected = useState('village.selected', () => null) const plot = useState('village.plot', () => null) const clear = () => { - selected.value = null plot.value = null } - return { selected, plot, clear } + return { plot, clear } } diff --git a/app/diorama/closeup.ts b/app/diorama/closeup.ts new file mode 100644 index 0000000..857780a --- /dev/null +++ b/app/diorama/closeup.ts @@ -0,0 +1,160 @@ +// A close-up of one building, for its own screen: the building larger, the ground and +// props of its kind around it, forest beyond, and its workers walking between the +// building and the spots where they work (trees for a timber camp, pits for a clay pit, +// rocks for an iron mine, fields for a farm, the wall walk for the wall). + +import type { BuildingType } from '~/types/game' +import { type Face, hash, plane, type Poly, project, rect, scale, toPolys, type V2, type V3 } from './iso' +import { broadleaf, buildingModel, bush, C, conifer, rock } from './models' +import { disc, ground, shadow, U, wallSegments } from './scene' + +export interface Closeup { + viewBox: string + width: number + height: number + terrain: Poly[] + decals: Poly[] + objects: { key: string; polys: Poly[] }[] + /** One per worker shown: a screen path walked there and back, with what they carry. */ + walks: { d: string; seconds: number; delay: number; carry: string | null }[] +} + +type Kind = 'timber' | 'clay' | 'iron' | 'farm' | 'wall' | 'core' +const KIND: Partial> = { timber_camp: 'timber', clay_pit: 'clay', iron_mine: 'iron', farm: 'farm', wall: 'wall' } +const GROUND: Record = { + timber: '#76703f', + clay: '#8d5a3b', + iron: '#7c776a', + farm: '#7f8f4b', + wall: '#8c7350', + core: '#a3885c', +} +/** What a worker carries home: logs, clay, ore, sheaves; core buildings move crates. */ +const CARRY: Record = { timber: C.wood, clay: C.clay, iron: C.ore, farm: C.wheat, wall: null, core: C.plank } +/** Workers drawn at most; more would crowd the scene. */ +const MAX_WALKERS = 8 + +const S = U * 1.7 +const deg = (d: number) => (d * Math.PI) / 180 +const at = (a: number, r: number): V2 => [Math.cos(a) * r, Math.sin(a) * r] +const screen = ([x, y]: V2, z = 1.2) => project([x, y, z]) +const line = (pts: V2[]) => pts.map((p, i) => `${i ? 'L' : 'M'}${screen(p).map((v) => v.toFixed(1)).join(' ')}`).join(' ') + +export function buildCloseup(type: BuildingType, level: number, workers: number, aspect = 2): Closeup { + const kind = KIND[type] ?? 'core' + const objects: { key: string; depth: number; polys: Poly[] }[] = [] + const decals: Face[] = [plane(disc(0, 0, S * 2.3, 16, 7, 0.5), GROUND[kind])] + const shadows: Face[] = [] + const taken: { x: number; y: number; r: number }[] = [{ x: 0, y: 0, r: S * 1.5 }] + /** Where workers go; the door is at the front, towards the viewer. */ + const spots: V2[] = [] + const door: V2 = at(deg(45), S * 0.95) + const put = (key: string, x: number, y: number, faces: Face[], r: number) => { + objects.push({ key, depth: x + y, polys: toPolys(faces) }) + taken.push({ x, y, r }) + } + + if (kind === 'wall') { + // A small fort: the wall round an empty yard, guards walking along it. + const Rw = S * 2.2 + wallSegments(Rw, level, [deg(45)]).forEach((seg, i) => objects.push({ key: `w${i}`, depth: seg.depth, polys: toPolys(seg.faces) })) + taken[0] = { x: 0, y: 0, r: Rw + U } + } else { + const model = buildingModel(type, level, S) + objects.push({ key: 'building', depth: 0, polys: toPolys(model.faces) }) + shadows.push(shadow(0, 0, S * 0.95, scale(GROUND[kind], 0.8), 3)) + } + + if (kind === 'timber') { + for (let i = 0; i < 6; i++) { + const [x, y] = at(deg(-80 + i * 34 + (hash(i, 1) - 0.5) * 14), S * (2.4 + 0.5 * hash(i, 2))) + put(`tree${i}`, x, y, conifer(x, y, U * (1.4 + 0.4 * hash(i, 3)), i), U * 0.7) + spots.push([x * 0.85, y * 0.85]) + } + } else if (kind === 'clay') { + for (let i = 0; i < 4; i++) { + const [x, y] = at(deg(-20 + i * 42), S * 2.2) + decals.push(plane(disc(x, y, U * 0.75, 9, 20 + i, 0.8), C.clayWet)) + spots.push([x, y]) + } + } else if (kind === 'iron') { + for (let i = 0; i < 5; i++) { + const [x, y] = at(deg(150 + i * 26), S * (2.5 + 0.3 * hash(i, 4))) + put(`rock${i}`, x, y, rock(x, y, U * (1.5 + 0.6 * hash(i, 5)), 40 + i, i % 2 ? C.stoneDark : C.rock), U * 0.9) + spots.push([x * 0.8, y * 0.8]) + } + } else if (kind === 'farm') { + for (let i = 0; i < 4; i++) { + const [x, y] = at(deg(-40 + i * 50), S * 2.5) + decals.push(plane(rect(x, y, U * 2.2, U * 1.5).map(([px, py]): V3 => [px, py, 0.7]), i % 2 ? C.wheat : C.field)) + taken.push({ x, y, r: U * 1.4 }) + spots.push([x, y]) + } + } else if (kind === 'wall') { + // Guards walk stretches of the wall walk. + for (let i = 0; i < 4; i++) spots.push(at(deg(i * 90 + 20), S * 2.0)) + } else { + for (let i = 0; i < 4; i++) spots.push(at(deg(-10 + i * 55), S * 2.0)) + } + + // Forest and bushes beyond, thicker further out. + const R = S * 2.75 + const f = U * 1.25 + for (let i = -14; i <= 14; i++) { + for (let j = -14; j <= 14; j++) { + const x = (i + hash(i, j, 61) * 0.8) * f + const y = (j + hash(i, j, 62) * 0.8) * f + const r = Math.hypot(x, y) + if (r < S * 2.6 || r > S * 7) continue + if (taken.some((t) => Math.hypot(x - t.x, y - t.y) < t.r + U * 0.4)) continue + if (Math.abs(Math.atan2(y, x) - deg(45)) < 0.25 && r < S * 5) continue + const density = 0.15 + 0.6 * Math.min(1, (r - S * 2.6) / (S * 2.5)) + if (hash(i, j, 63) > density) continue + const kindRoll = hash(i, j, 64) + const size = U * (1.0 + 0.5 * hash(i, j, 65)) + const seed = i * 131 + j + put(`t${i}:${j}`, x, y, kindRoll < 0.15 ? bush(x, y, size * 0.8, seed) : kindRoll < 0.7 ? conifer(x, y, size, seed) : broadleaf(x, y, size, seed), size * 0.3) + } + } + + // Frame: the building, its spots and a ring of land round them, widened to the stage. + const pts: V2[] = [] + for (let i = 0; i < 24; i++) pts.push(screen(at((i / 24) * Math.PI * 2, R), 0)) + let minX = Math.min(...pts.map((p) => p[0])) + let maxX = Math.max(...pts.map((p) => p[0])) + let minY = Math.min(...pts.map((p) => p[1])) - S * 1.2 + let maxY = Math.max(...pts.map((p) => p[1])) + let w = maxX - minX + let h = maxY - minY + if (w / h < aspect) { + minX -= (h * aspect - w) / 2 + w = h * aspect + } else { + minY -= (w / aspect - h) / 2 + h = w / aspect + } + maxX = minX + w + maxY = minY + h + const view = { x: minX, y: minY, w, h } + + const shown = Math.min(MAX_WALKERS, Math.max(0, workers)) + const walks: Closeup['walks'] = [] + for (let i = 0; i < shown && spots.length; i++) { + const spot = spots[i % spots.length]! + const path = kind === 'wall' ? [at(deg(i * 90), S * 2.0), at(deg(i * 90 + 45), S * 2.0), at(deg(i * 90 + 90), S * 2.0)] : [door, spot] + const length = Math.hypot(spot[0] - door[0], spot[1] - door[1]) + const seconds = Math.max(7, (length / U) * 2.4) + walks.push({ d: line(path), seconds, delay: -(i * seconds) / Math.max(1, shown), carry: CARRY[kind] }) + } + + objects.sort((a, b) => a.depth - b.depth) + return { + viewBox: `${view.x.toFixed(1)} ${view.y.toFixed(1)} ${w.toFixed(1)} ${h.toFixed(1)}`, + width: w, + height: h, + terrain: ground(view), + decals: [...decals, ...shadows].flatMap((face) => toPolys([face])), + objects: objects.map(({ key, polys }) => ({ key, polys })), + walks, + } +} diff --git a/app/diorama/scene.ts b/app/diorama/scene.ts index 35fa4f3..3145671 100644 --- a/app/diorama/scene.ts +++ b/app/diorama/scene.ts @@ -14,7 +14,7 @@ import { type Face, hash, ngon, plane, type Poly, prism, project, pyramid, scale import { broadleaf, buildingModel, bush, C, conifer, crane, rock, scaffold, well } from './models' /** World units per unit of building space, roughly. */ -const U = 24 +export const U = 24 const GOLDEN = Math.PI * (3 - Math.sqrt(5)) const deg = (d: number) => (d * Math.PI) / 180 const dir = (a: number): V2 => [Math.cos(a), Math.sin(a)] @@ -207,7 +207,7 @@ function inverse([X, Y]: V2): V2 { } /** A low-poly ground mesh that covers the view; vertices hash from their grid index, so it never shifts. */ -function ground(view: { x: number; y: number; w: number; h: number }): Poly[] { +export function ground(view: { x: number; y: number; w: number; h: number }): Poly[] { const g = U * 2.6 const corners = [ inverse([view.x, view.y]), @@ -244,7 +244,7 @@ function ground(view: { x: number; y: number; w: number; h: number }): Poly[] { return toPolys(faces).map((p) => ({ ...p, stroke: p.fill })) } -function disc(cx: number, cy: number, r: number, n: number, seed: number, z = 0.6): V3[] { +export function disc(cx: number, cy: number, r: number, n: number, seed: number, z = 0.6): V3[] { return ngon(cx, cy, r, n, hash(seed, 1) * 6).map(([x, y], i): V3 => { const k = 0.82 + 0.3 * hash(seed, i) return [cx + (x - cx) * k, cy + (y - cy) * k, z] @@ -286,7 +286,7 @@ function walkPath(a: number, r0: number, r1: number, seed: number, from: number, } /** 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 { +export 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) } @@ -317,7 +317,7 @@ function ringBand(r: number, width: number, color: string): Face[] { // The wall rings the village; its look follows the level like the buildings, and each // segment is its own object so it sorts correctly against buildings inside and out. -function wallSegments(Rv: number, level: number, gates: number[]): { faces: Face[]; depth: number }[] { +export function wallSegments(Rv: number, level: number, gates: number[]): { faces: Face[]; depth: number }[] { const steps = Math.max(28, Math.round((Math.PI * 2 * Rv) / (U * 0.55))) const gateHalf = (PATH_HALF + U * 0.3) / Rv const h = U * (0.5 + Math.min(level, 20) * 0.035) diff --git a/app/mock/server.ts b/app/mock/server.ts index 3be6c9e..b769648 100644 --- a/app/mock/server.ts +++ b/app/mock/server.ts @@ -581,6 +581,9 @@ function view(state: MockState, v: MockVillage, now: number): VillageState { production: p ? { resource: p.resource, per_hour: round(p.per_hour) } : null, upgrade: upgradeOffer(v, b), demolish: demolishOffer(v, b), + // Placeholder: production only; the backend lists every effect. + effects: p ? [{ key: 'production', value: round(p.per_hour), resource: p.resource }] : [], + next_effects: null, } }, ), diff --git a/app/pages/village/[id]/build.vue b/app/pages/village/[id]/build.vue index d081ef5..34eba68 100644 --- a/app/pages/village/[id]/build.vue +++ b/app/pages/village/[id]/build.vue @@ -7,13 +7,29 @@ const resources = computed(() => v.resources.value!) /** 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 { t } = useI18n() +/** A building's name opens its own screen. */ +function showBuilding(id: number) { + const b = village.value.buildings.find((x) => x.id === id) + if (b) navigateTo(buildingRoute(village.value, b)) +}