diff --git a/CLAUDE.md b/CLAUDE.md index 159ea44..6bc8928 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -10,7 +10,7 @@ This is the Nuxt client for a browser strategy game in the style of Tribal Wars. - **Light Tailwind UI** (Tailwind 4, theme and component classes like `.panel`, `.btn` in `app/assets/css/main.css`) with simple hand-written inline SVG graphics (`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. - **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; 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. - **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 page is laid out like Die Stämme**: a compact strip with the stock and the screens (Overview, Headquarters, Recruit, Rally point, Workforce) and a red badge for incoming attacks, each screen a child route of `pages/village/[id].vue` sharing one `useVillage()` through `useVillageContext()`. The overview stays clean: the village and a narrow column of boxes (incoming attacks, production, units, population, construction); tables live on the building screens. Reports are a world-level page (`pages/reports/[worldId]`) linked from the header with the unread count. +- **One game shell, like Die Stämme.** Pages inside a world (village screens, map, reports) use `layouts/game.vue`: the dark menu bar (`GameMenuBar`: village, map, reports with the unread count, server clock, account menu), then the sticky village bar (`GameVillageBar`: which village, stock with storage meters, incoming troops, and the village's screens as tabs: Overview, Headquarters, Recruit, Rally point, Workforce). On phones the screens move to a bottom tab bar (`GameTabBar`). The bar'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()`, so the map and reports keep the village on top. Pages outside a world use `layouts/default.vue` (menu bar only). The overview stays clean: the village and a narrow column of boxes (incoming attacks, production, units, population, construction); tables live on the building screens. - 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`. ## Mock server diff --git a/app/app.vue b/app/app.vue index a88ee73..482ad43 100644 --- a/app/app.vue +++ b/app/app.vue @@ -1,24 +1,6 @@ + - - diff --git a/app/components/game/MenuBar.vue b/app/components/game/MenuBar.vue new file mode 100644 index 0000000..4c8bb84 --- /dev/null +++ b/app/components/game/MenuBar.vue @@ -0,0 +1,118 @@ + + + + + + diff --git a/app/components/game/Resource.vue b/app/components/game/Resource.vue new file mode 100644 index 0000000..c222a0b --- /dev/null +++ b/app/components/game/Resource.vue @@ -0,0 +1,41 @@ + + + + diff --git a/app/components/game/TabBar.vue b/app/components/game/TabBar.vue new file mode 100644 index 0000000..c5d9103 --- /dev/null +++ b/app/components/game/TabBar.vue @@ -0,0 +1,26 @@ + + + + diff --git a/app/components/game/VillageBar.vue b/app/components/game/VillageBar.vue new file mode 100644 index 0000000..1dd95db --- /dev/null +++ b/app/components/game/VillageBar.vue @@ -0,0 +1,125 @@ + + + + + + diff --git a/app/components/game/VillageFrame.vue b/app/components/game/VillageFrame.vue new file mode 100644 index 0000000..ee59b46 --- /dev/null +++ b/app/components/game/VillageFrame.vue @@ -0,0 +1,31 @@ + + + diff --git a/app/components/icon/Ui.vue b/app/components/icon/Ui.vue index 747e69e..c1e7400 100644 --- a/app/components/icon/Ui.vue +++ b/app/components/icon/Ui.vue @@ -16,6 +16,7 @@ export type UiIconName = | 'report' | 'eye' | 'edit' + | 'home' defineProps<{ name: UiIconName }>() @@ -72,6 +73,10 @@ defineProps<{ name: UiIconName }>() + + + + diff --git a/app/components/village/ResourceBar.vue b/app/components/village/ResourceBar.vue deleted file mode 100644 index 4b63fe3..0000000 --- a/app/components/village/ResourceBar.vue +++ /dev/null @@ -1,31 +0,0 @@ - - - - diff --git a/app/composables/useServerClock.ts b/app/composables/useServerClock.ts new file mode 100644 index 0000000..1456e67 --- /dev/null +++ b/app/composables/useServerClock.ts @@ -0,0 +1,14 @@ +/** + * The server's clock: the client clock plus the offset the last server snapshot showed. + * Shared, so the header clock and every countdown agree. + */ +export function useServerClock() { + const offset = useState('clock.offset', () => 0) + const clock = useNow() + const now = computed(() => clock.value + offset.value) + + /** Call with a snapshot's `server_time`. */ + const sync = (serverTime: string) => (offset.value = Date.parse(serverTime) - Date.now()) + + return { now, sync } +} diff --git a/app/composables/useVillage.ts b/app/composables/useVillage.ts index c345783..0522282 100644 --- a/app/composables/useVillage.ts +++ b/app/composables/useVillage.ts @@ -12,19 +12,16 @@ export function useVillage(villageId: number) { const error = ref(null) const busy = ref(false) const errorText = useErrorText() - const clock = useNow() const unreadReports = useUnreadReports() - - // Server time minus client time, so projections use the server's clock. - const offset = ref(0) - const now = computed(() => clock.value + offset.value) + // Projections and countdowns run on the server's clock. + const { now, sync } = useServerClock() async function run(event: string, data: object = {}) { busy.value = true error.value = null try { const state = await ws.send(event, { village_id: villageId, ...data }) - offset.value = Date.parse(state.server_time) - Date.now() + sync(state.server_time) village.value = state unreadReports.value = state.unread_reports return true diff --git a/app/layouts/default.vue b/app/layouts/default.vue new file mode 100644 index 0000000..826ada9 --- /dev/null +++ b/app/layouts/default.vue @@ -0,0 +1,9 @@ + + diff --git a/app/layouts/game.vue b/app/layouts/game.vue new file mode 100644 index 0000000..7556399 --- /dev/null +++ b/app/layouts/game.vue @@ -0,0 +1,27 @@ + + + + diff --git a/app/pages/map/[worldId].vue b/app/pages/map/[worldId].vue index b830758..0bfb5d2 100644 --- a/app/pages/map/[worldId].vue +++ b/app/pages/map/[worldId].vue @@ -1,6 +1,8 @@ - - diff --git a/app/pages/worlds.vue b/app/pages/worlds.vue index d3cc5e8..a419d86 100644 --- a/app/pages/worlds.vue +++ b/app/pages/worlds.vue @@ -29,7 +29,7 @@ async function resetMock() {

{{ $t('common.loading') }}

{{ $t('worlds.none') }}

    -
  • +
  • @@ -40,16 +40,18 @@ async function resetMock() { {{ $t('worlds.joined') }}

    - - {{ $t('worlds.map') }} +
    + + {{ $t('worlds.map') }} +
diff --git a/app/utils/screens.ts b/app/utils/screens.ts new file mode 100644 index 0000000..4d6ff93 --- /dev/null +++ b/app/utils/screens.ts @@ -0,0 +1,10 @@ +import type { BuildingType } from '~/types/game' + +/** A village's own screens, like the building links of Die Stämme: the bar's tabs and the phone's tab bar. */ +export const VILLAGE_SCREENS: { name: 'overview' | 'build' | 'recruit' | 'rally' | 'workforce'; path: string; icon: BuildingType }[] = [ + { name: 'overview', path: '', icon: 'headquarters' }, + { name: 'build', path: '/build', icon: 'storage' }, + { name: 'recruit', path: '/recruit', icon: 'barracks' }, + { name: 'rally', path: '/rally', icon: 'rally_point' }, + { name: 'workforce', path: '/workforce', icon: 'farm' }, +] diff --git a/i18n/locales/en.ts b/i18n/locales/en.ts index 10ee06e..f26aa54 100644 --- a/i18n/locales/en.ts +++ b/i18n/locales/en.ts @@ -1,6 +1,9 @@ export default { app: { title: 'Village Politics', + menu: 'Main menu', + account: 'Account', + server_time: 'Server time', map: 'Map', reports: 'Reports', unread_reports: '{count} unread reports', diff --git a/i18n/pages/village.ts b/i18n/pages/village.ts index 9c4b149..ade8632 100644 --- a/i18n/pages/village.ts +++ b/i18n/pages/village.ts @@ -15,6 +15,7 @@ export default { recruit: 'Recruit', rally: 'Rally point', workforce: 'Workforce', + short: { overview: 'Village', build: 'Build', recruit: 'Recruit', rally: 'Rally', workforce: 'Workers' }, }, side: { production: 'Production', @@ -35,6 +36,8 @@ export default { title: 'Resources', cap: 'Storage cap', per_hour: '{rate}/h', + full: 'storage full', + full_in: 'full in {time}', }, population: { title: 'Population',