diff --git a/CLAUDE.md b/CLAUDE.md index 048970a..ed6dc20 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -10,8 +10,8 @@ The game is called **Kronland** (`app.title`); Village Politics is its code name - **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, footpaths from every door to the nearest road or the plaza, and forest fills the rest. Levels start at 1. Each type has a model per level tier (1–4, 5–14, 15+) and looks like what it is: the headquarters flies the village flag with banners at its door, the storage is a barn, the stable has stalls with horses looking out and a paddock, the workshop wheels and siege engines in the making, the barracks a training yard (tents, then a hall with shields, then battlements); 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 tags and countdowns as well; a type that doesn't stand yet keeps an invisible empty plot that opens its build card. Every building wears a fixed tag (`buildingTag` in `app/utils/buildingTags.ts`): its level and the one live number that says what it does: camps their production, the storage its fullest resource against the limit, the farm the free villagers, the headquarters the building space, a military building what it trains and when that is done, the rally point the troops in the village (red while an attack comes), wall, hiding place and watchtower their effect; amber when worth a look, red when it needs action. Tags that would overlap move up. Buildings never move or light up on hover: only a click outlines the ground under them. While a window or the build card is open, a pointer click in the village only closes it, so a stray click never swaps it for another building's (keys still open what has focus); Esc closes it too. The village feels alive, and life stays out of the way: flat ground shadows, smoke from chimneys, forges and kilns; workers go out to their zone with their tool (`VillageWorker`, timing in `app/diorama/life.ts`: one SMIL clock per figure for the walk, stepping legs, the tool swing at work, the load on the way home and turning round), two villagers talk on the plaza, every order in the queue shows at its site (planks and stones piled up, a porter carrying more from the storage door, and while it runs a builder with a hammer, or a pick to tear down), units in training drill in front of their building with an instructor, villagers step out of their doors and go back in (a building's door is found by its `DOOR` colour; resting figures with `indoors` are out of sight), a guard paces inside the gate, soldiers stand guard at the doors while troops are in the village (two at the headquarters, one or two at every other door with a big army: `guardsAt`), sheep graze past the farms and chickens peck round the plaza (`VillageAnimal`), crows cross now and then and circle over the graves and the gallows (`VillageBird`); the close-up does the same for its building. **The times are hard, and the land shows it** (the look is grim and worn, never cheerful): tired olive grass, mud roads with wheel ruts and puddles, trodden mud between the houses, a ragged edge where the wall stands, mud splashed up the walls and rotten patches on most roofs (`mudline`, `roofRot` in `iso.ts`), stumps where the forest was cut and dead trees in it, a graveyard behind the village with a grave more as its points grow and the newest still open, the gallows by the main road, a burnt farmstead still smouldering, blood on the training yard and the rally ground. The land darkens a little away from the village into the forest (`fade` in `scene.ts`). People wear undyed and faded cloth, smoke is sooty (`SHIRTS`, `UNIFORM`, `SMOKE` in `models.ts`). Nothing gory beyond blood stains: no bodies. All motion stops under `prefers-reduced-motion`; people who stay put then stand still. 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. A ring and flag in the relation's colour mark every village (`RELATION_COLOURS` in `app/utils/relations.ts`, from `map.view`'s `relation`): own yellow, the village the player is in white, tribe blue, allies light blue, NAP purple, enemies red, other players dark red, barbarians grey. Every group the player knows of (`map.view`'s `movements`) is a line from origin to target, dashed for returns, with the group at its current position (`MapMarch`: one to five soldiers by the size tier, stepping in place, a banner in the line's colour); raiders wait at their camp until they march. 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` (overcast daylight: faces turned away drop to two thirds and cool a little), solid borders and hard shadows. The palette (`C` in `app/diorama/models.ts`, the ground colours in `scene.ts`, the map in `WorldMap.vue`) is muted, desaturated and worn, but it is daylight, never dusk; fire and blood are the only warm colours. In the diorama there are no outlines: a polygon strokes in its own fill only to close seams, detail comes from a few large shaded panels (`house()`: a stone plinth, half-timber beams on wooden walls, a framed door, framed windows with shutters, a ridge beam; `openings()` for stone halls; two-tier firs; people as shaded shapes in `VillageWalker`), not from many small nodes. Panels on a wall sort a step in front of that wall face's centroid depth. A face that must draw over its wall (doors, windows) sets `depth`; offsets and `shift()` carry it along. In the close-up, workers are sorted in among the objects by depth. Surfaces carry small repeating patterns generated in code at startup (`app/utils/patterns.ts` → `--pat-*` custom properties, set by `plugins/patterns.client.ts`, painted per `bg-parchment-*`/`bg-wood-*` class and on `.panel`, `.frame`, `.btn-primary` in `main.css`): parchment flecks, woven header bands with a stitched hem, wood grain; flat opaque shades a step off the surface, never images or opacity. Keep them minimal. One look for every part: each header band is `.panel-head` with a `.panel-title`, everything that floats over the village has the `.float` hard shadow and sits in a bordered frame, and every vertical scroll area is `.scroll-y`, whose bar always shows so content never shifts sideways; the one scrollbar style (wood handle with notches in a parchment track) lives in `main.css`. Every page keeps the page scrollbar, the fullscreen village included (an empty track there), so the usable width never changes when hopping between the village, the map and the reports. 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 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 opens fitted, with a strip of land round it: the frame measures what the bars, the right column, the phone tab bar and the bottom sheet cover (`inset`), and `buildScene` fits the whole village into the rest (`home`), so nothing of the village is cut off. From there the player pans and zooms (`useDioramaCamera`): drag or arrows to pan, the wheel, a pinch or the + − buttons at the bottom right of the free part to zoom (up to 4×), 0 or "Whole village" back home; a drag never opens a building. Ground and forest run on round the village (`bounds`: the view ×1.6, at most the village ×2.6, so phones grow sideways), opening into clearings further out; the camera never leaves them. Tags and countdowns keep their screen size at every zoom. The landing page's picture (`still`) has no camera and no land beyond its view. The player arranges it: every window drags by its title bar on wide screens (one offset for all windows, a double-click on the title bar puts it back: `useWindowOffset`), and the boxes of a dock (the overview's, the map's) are `UiDock` cards: a click on the header folds one, a drag moves it to another place in the column or out to float anywhere over the stage, and a floating box has a button back into the column (`useCardLayout`, per dock). Layouts live in localStorage, per browser; phones keep the boxes in their sheet, foldable but not draggable. This is where the game deliberately leaves Die Stämme's look behind. -- **One stage for the whole world.** Every page of a world shares that frame, so nothing moves when hopping between them: the reports open in the window over the village, and the map fills the screen under the menu bar itself (it reads `useStage()` for where the menu ends) and teleports its panels (centre and zoom, minimap with the jump form, field info, legend) into the right dock (`#stage-dock`); on phones a small strip with home and zoom floats over it. Only pages outside a world, or a world whose village isn't known yet, sit in the 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, tribe with its invites, ranking, each with a hover dropdown of its sub-pages; the chat toggle with its unread count; 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, each resource with its amount against the storage limit, its rate per hour and a fill bar, and the villagers with how many are free, then 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, K ranking, S tribe. The chat (`GameChat`, state in `useChat`) is a window of its own at the bottom left with a tab per channel (world, tribe, each conversation); it listens for `chat:message` while mounted and keeps its own drag position. 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. Groups on the march are clickable on their line and their figure: a card at the group (`MapMarchCard`) tells from where to where, what (own units or the size tier) and when it arrives, and calls an own command back while `cancel_until` runs. A clicked village lists the groups leaving it and coming to it (`MapMarchList`, in its popup and the field box). A group leaves the map when it arrives, and the map reloads then and whenever the village bar learns of a change, so its way home shows up. The overview has an own-commands box (out and home) with the call-back button. 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. +- **The village fills the screen on its overview.** On `/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), and on the left the build card of an empty plot picked in the village (`useVillageSelection`). Every other screen is a page of its own (next point). Screen grids use container queries (`@4xl:`, the page frame is the container), not viewport breakpoints. The village opens fitted, with a strip of land round it: the frame measures what the bars, the right column, the phone tab bar and the bottom sheet cover (`inset`), and `buildScene` fits the whole village into the rest (`home`), so nothing of the village is cut off. From there the player pans and zooms (`useDioramaCamera`): drag or arrows to pan, the wheel, a pinch or the + − buttons at the bottom right of the free part to zoom (up to 4×), 0 or "Whole village" back home; a drag never opens a building. Ground and forest run on round the village (`bounds`: the view ×1.6, at most the village ×2.6, so phones grow sideways), opening into clearings further out; the camera never leaves them. Tags and countdowns keep their screen size at every zoom. The landing page's picture (`still`) has no camera and no land beyond its view. The player arranges it: a window (the chat) drags by its title bar on wide screens (a double-click there puts it back: `useWindowOffset`), and the boxes of a dock (the overview's, the map's) are `UiDock` cards: a click on the header folds one, a drag moves it to another place in the column or out to float anywhere over the stage, and a floating box has a button back into the column (`useCardLayout`, per dock). Layouts live in localStorage, per browser; phones keep the boxes in their sheet, foldable but not draggable. This is where the game deliberately leaves Die Stämme's look behind. +- **Screens are pages.** Every other screen of a world is a page of its own, like the old browser games: the building screens (headquarters, recruit, rally point, workforce, and `/village//building/` for the rest), the reports, the ranking and the tribe render in the centred column (1100 px) under the menu, the village bar and the notices (`GameVillageNotices`), and the page scrolls; the world's pages (not the building screens, which have their own header) carry a title band. Clicking a building in the village opens its page; Overview (V) goes back to the village. The map fills the screen under the menu bar itself (it reads `useStage()` for where the menu ends) and teleports its panels (centre and zoom, minimap with the jump form, field info, legend) into the right dock (`#stage-dock`); on phones a small strip with home and zoom floats over it. Pages outside a world, or of a world whose village isn't known yet, sit in the same column with the menu only. All world pages use `layouts/game.vue` (`GameVillageFrame` draws the same parts, over the village on its overview): the dark main menu (`GameMenuBar`: village, map, reports with its count inline, tribe with its invites, ranking, each with a hover dropdown of its sub-pages; the chat toggle with its unread count; 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, each resource with its amount against the storage limit, its rate per hour and a fill bar, and the villagers with how many are free, then 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, K ranking, S tribe. The chat (`GameChat`, state in `useChat`) is a window of its own at the bottom left with a tab per channel (world, tribe, each conversation); it listens for `chat:message` while mounted and keeps its own drag position. 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. Groups on the march are clickable on their line and their figure: a card at the group (`MapMarchCard`) tells from where to where, what (own units or the size tier) and when it arrives, and calls an own command back while `cancel_until` runs. A clicked village lists the groups leaving it and coming to it (`MapMarchList`, in its popup and the field box). A group leaves the map when it arrives, and the map reloads then and whenever the village bar learns of a change, so its way home shows up. The overview has an own-commands box (out and home) with the call-back button. 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. ## Mock server diff --git a/app/components/game/VillageFrame.vue b/app/components/game/VillageFrame.vue index 7bbc878..d430c23 100644 --- a/app/components/game/VillageFrame.vue +++ b/app/components/game/VillageFrame.vue @@ -69,6 +69,13 @@ const screenTitle = computed(() => { return s ? t(`village.screens.${s.name}`) : '' }) const picked = computed(() => !!plot.value) +/** + * Every screen but the overview and the map is a page of its own: the building screens, + * the reports, the ranking, the tribe. The village shows only on its overview. + */ +const page = computed(() => !overview.value && !onMap.value) +/** The world's pages carry their title in a band; building screens have their own header. */ +const pageTitle = computed(() => (route.path.startsWith(`${base.value}/`) ? '' : screenTitle.value)) // A village of ours was taken ("geadelt"): say so, and leave its screens for another // village, or for the worlds page where a fresh start waits. @@ -87,7 +94,6 @@ function onEscape(e: KeyboardEvent) { const el = e.target as HTMLElement | null if (el && ['INPUT', 'TEXTAREA', 'SELECT'].includes(el.tagName)) return if (picked.value) clear() - else if (!overview.value && !onMap.value) navigateTo(base.value) } onMounted(() => window.addEventListener('keydown', onEscape)) onBeforeUnmount(() => window.removeEventListener('keydown', onEscape)) @@ -151,6 +157,22 @@ useShortcuts(() => { -->