From a4185b66a7f1db2ae6dd9b8374c30778580c3424 Mon Sep 17 00:00:00 2001 From: "Fabian @ Blax Software" Date: Wed, 28 Oct 2026 19:58:42 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20Die=20St=C3=A4mme-style=20world=20map?= =?UTF-8?q?=20with=20coordinate=20rulers,=20continents=20and=20village=20i?= =?UTF-8?q?nfo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- app/components/map/InfoCard.vue | 43 +++++ app/components/map/VillageMarker.vue | 76 ++++++++ app/components/map/WorldMap.vue | 266 +++++++++++++++++++++++++++ app/composables/useMap.ts | 27 +++ app/pages/map/[worldId].vue | 160 ++++++++++++++++ app/types/map.ts | 27 +++ i18n/messageloader.ts | 3 +- i18n/pages/map.ts | 35 ++++ 8 files changed, 636 insertions(+), 1 deletion(-) create mode 100644 app/components/map/InfoCard.vue create mode 100644 app/components/map/VillageMarker.vue create mode 100644 app/components/map/WorldMap.vue create mode 100644 app/composables/useMap.ts create mode 100644 app/pages/map/[worldId].vue create mode 100644 app/types/map.ts create mode 100644 i18n/pages/map.ts diff --git a/app/components/map/InfoCard.vue b/app/components/map/InfoCard.vue new file mode 100644 index 0000000..e37fcd6 --- /dev/null +++ b/app/components/map/InfoCard.vue @@ -0,0 +1,43 @@ + + + diff --git a/app/components/map/VillageMarker.vue b/app/components/map/VillageMarker.vue new file mode 100644 index 0000000..b8599bc --- /dev/null +++ b/app/components/map/VillageMarker.vue @@ -0,0 +1,76 @@ + + + diff --git a/app/components/map/WorldMap.vue b/app/components/map/WorldMap.vue new file mode 100644 index 0000000..efbab19 --- /dev/null +++ b/app/components/map/WorldMap.vue @@ -0,0 +1,266 @@ + + + diff --git a/app/composables/useMap.ts b/app/composables/useMap.ts new file mode 100644 index 0000000..09bd007 --- /dev/null +++ b/app/composables/useMap.ts @@ -0,0 +1,27 @@ +import type { MapView } from '~/types/map' + +/** One world's map window. Only the newest request wins, so fast panning never shows an older window. */ +export function useMap(worldId: number) { + const view = ref(null) + const error = ref(null) + const busy = ref(false) + const errorText = useErrorText() + let latest = 0 + + /** Without x/y the server opens on the player's own village in this world. */ + async function load(at: { x: number; y: number } | null, w: number, h: number) { + const request = ++latest + busy.value = true + error.value = null + try { + const result = await ws.send('map.view', { world_id: worldId, w, h, ...at }) + if (request === latest) view.value = result + } catch (e) { + if (request === latest) error.value = errorText(e) + } finally { + if (request === latest) busy.value = false + } + } + + return { view, error, busy, load } +} diff --git a/app/pages/map/[worldId].vue b/app/pages/map/[worldId].vue new file mode 100644 index 0000000..541f0bb --- /dev/null +++ b/app/pages/map/[worldId].vue @@ -0,0 +1,160 @@ + + + diff --git a/app/types/map.ts b/app/types/map.ts new file mode 100644 index 0000000..57b7bd9 --- /dev/null +++ b/app/types/map.ts @@ -0,0 +1,27 @@ +// `map.view` payloads. Coordinates are map fields; continents are 100 × 100 (K55 holds 500|500). + +export interface MapVillage { + id: number + x: number + y: number + name: string + points: number + continent: string + /** null for barbarian villages. */ + player: { id: number; name: string } | null + own: boolean +} + +/** `map.view {world_id, x?, y?, w, h}`: the w × h window around center, kept inside the map. */ +export interface MapView { + world_id: number + /** The map is size × size fields. */ + size: number + center: { x: number; y: number } + /** Top-left field of the window. */ + x: number + y: number + w: number + h: number + villages: MapVillage[] +} diff --git a/i18n/messageloader.ts b/i18n/messageloader.ts index 3c10391..db1e462 100644 --- a/i18n/messageloader.ts +++ b/i18n/messageloader.ts @@ -2,11 +2,12 @@ import { mergeMessages } from '@blax-software/i18n' import networking from '@blax-software/networking/i18n' import en from './locales/en' import auth from './pages/auth' +import map from './pages/map' import village from './pages/village' import worlds from './pages/worlds' // Explicit imports instead of import.meta.glob: @nuxtjs/i18n also loads this file in the // Nitro build, where glob imports don't exist. Add new page files here, in path order. -export default mergeMessages({ en }, [auth, village, worlds], { packages: [networking] }) as { +export default mergeMessages({ en }, [auth, map, village, worlds], { packages: [networking] }) as { en: Record } diff --git a/i18n/pages/map.ts b/i18n/pages/map.ts new file mode 100644 index 0000000..f137a21 --- /dev/null +++ b/i18n/pages/map.ts @@ -0,0 +1,35 @@ +import type { TranslationFile } from '@blax-software/i18n' + +export default { + en: { + map: { + title: 'World map', + subtitle: 'Map', + aria: 'World map. Drag or use the arrow keys to move, click a field to select it.', + jump: 'Go', + home: 'My village', + zoom_in: 'Zoom in', + zoom_out: 'Zoom out', + controls: 'Drag or use the arrow keys (Shift for 5 fields) to move. Click a field for details.', + barbarian: 'Barbarians', + info: { + title: 'Field', + coordinates: 'Coordinates', + owner: 'Owner', + points: 'Points', + open: 'Open village', + center: 'Centre here', + empty: 'Empty field', + hint: 'Hover or click a field to see who lives there.', + }, + legend: { + title: 'Legend', + own: 'Your villages', + players: 'Other players', + barbarians: 'Barbarian villages', + // {'|'} is a literal pipe: a bare | separates plural forms in vue-i18n. + lines: "Thin lines mark sectors of 10 fields, thick lines the continents of 100 (K55 holds 500{'|'}500).", + }, + }, + }, +} satisfies TranslationFile