feat: Kronland: landing page with a live demo village, careful registration (name rules, password twice, terms), imprint, privacy and terms pages

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Fabian @ Blax Software 2026-10-30 11:17:34 +01:00
parent 0ba6c6026c
commit 62d9673eb6
30 changed files with 876 additions and 72 deletions

View File

@ -0,0 +1,16 @@
<script setup lang="ts">
const operator = useRuntimeConfig().public.OPERATOR_NAME
const year = new Date().getFullYear()
</script>
<!-- The legal links under the public pages. -->
<template>
<footer class="border-t-2 border-wood-900 bg-wood-900 px-4 py-3 text-sm text-parchment-200">
<div class="mx-auto flex max-w-[1100px] flex-wrap items-center gap-x-5 gap-y-1">
<span>© {{ year }} {{ operator }}</span>
<NuxtLink to="/imprint" class="hover:text-gold-400">{{ $t('legal.imprint.title') }}</NuxtLink>
<NuxtLink to="/privacy" class="hover:text-gold-400">{{ $t('legal.privacy.title') }}</NuxtLink>
<NuxtLink to="/terms" class="hover:text-gold-400">{{ $t('legal.terms.title') }}</NuxtLink>
</div>
</footer>
</template>

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import type { MapVillage } from '~/types/map' import type { MapMovement, MapVillage } from '~/types/map'
const props = defineProps<{ const props = defineProps<{
village: MapVillage village: MapVillage
@ -7,8 +7,11 @@ const props = defineProps<{
from: { id: number; x: number; y: number } | null from: { id: number; x: number; y: number } | null
/** With actions (a click), or just the facts (hovering). */ /** With actions (a click), or just the facts (hovering). */
actions?: boolean actions?: boolean
/** Groups on the map, for those leaving or coming to the village (on a click). */
movements?: MapMovement[]
now?: number
}>() }>()
const emit = defineEmits<{ center: []; close: [] }>() const emit = defineEmits<{ center: []; close: []; march: [id: number] }>()
const distance = computed(() => (props.from ? Math.hypot(props.village.x - props.from.x, props.village.y - props.from.y) : null)) const distance = computed(() => (props.from ? Math.hypot(props.village.x - props.from.x, props.village.y - props.from.y) : null))
const own = computed(() => props.village.own) const own = computed(() => props.village.own)
@ -36,6 +39,14 @@ const own = computed(() => props.village.own)
<dd class="tabular-nums">{{ $t('village.rally.fields', { fields: distance.toFixed(1) }) }}</dd> <dd class="tabular-nums">{{ $t('village.rally.fields', { fields: distance.toFixed(1) }) }}</dd>
</template> </template>
</dl> </dl>
<MapMarchList
v-if="actions && movements && now"
class="border-t border-parchment-300 px-3 py-1.5 text-xs"
:village-id="village.id"
:movements="movements"
:now="now"
@march="emit('march', $event)"
/>
<div v-if="actions" class="flex flex-wrap gap-1.5 border-t border-parchment-300 px-3 py-2"> <div v-if="actions" class="flex flex-wrap gap-1.5 border-t border-parchment-300 px-3 py-2">
<NuxtLink <NuxtLink
v-if="from && from.id !== village.id" v-if="from && from.id !== village.id"

View File

@ -1,13 +1,15 @@
<script setup lang="ts"> <script setup lang="ts">
import type { MapVillage } from '~/types/map' import type { MapMovement, MapVillage } from '~/types/map'
defineProps<{ defineProps<{
village: MapVillage | null village: MapVillage | null
at: { x: number; y: number } | null at: { x: number; y: number } | null
/** Groups on the map the player knows of, for the ones to and from this village. */
movements?: MapMovement[]
now?: number
}>() }>()
const emit = defineEmits<{ center: [at: { x: number; y: number }] }>() const emit = defineEmits<{ center: [at: { x: number; y: number }]; march: [id: number] }>()
const { current } = useCurrentWorld() const { current } = useCurrentWorld()
</script> </script>
<template> <template>
@ -28,6 +30,7 @@ const { current } = useCurrentWorld()
<dt class="text-ink-500">{{ $t('map.info.points') }}</dt> <dt class="text-ink-500">{{ $t('map.info.points') }}</dt>
<dd class="tabular-nums">{{ village.points }}</dd> <dd class="tabular-nums">{{ village.points }}</dd>
</dl> </dl>
<MapMarchList v-if="movements && now" class="mt-3" :village-id="village.id" :movements="movements" :now="now" @march="emit('march', $event)" />
<div class="mt-4 flex flex-wrap gap-2"> <div class="mt-4 flex flex-wrap gap-2">
<NuxtLink v-if="village.own" :to="`/village/${village.id}`" class="btn btn-primary">{{ $t('map.info.open') }}</NuxtLink> <NuxtLink v-if="village.own" :to="`/village/${village.id}`" class="btn btn-primary">{{ $t('map.info.open') }}</NuxtLink>
<NuxtLink <NuxtLink

View File

@ -0,0 +1,66 @@
<script setup lang="ts">
import type { UnitType } from '~/types/game'
import type { MapMovement } from '~/types/map'
const props = defineProps<{
march: MapMovement
/** The clock, for the countdowns. */
now: number
busy?: boolean
error?: string | null
}>()
const emit = defineEmits<{ close: []; cancel: []; center: [at: { x: number; y: number }] }>()
const { t } = useI18n()
const title = computed(() => {
const m = props.march
return t(`map.march.${m.raid ? 'raid' : m.type}`, { from: m.from.name, to: m.to.name })
})
const seconds = (iso: string) => Math.max(0, Math.ceil((Date.parse(iso) - props.now) / 1000))
const cancelLeft = computed(() => (props.march.cancel_until ? seconds(props.march.cancel_until) : 0))
const colour = computed(() => (props.march.raid ? MARCH_COLOURS.raid : MARCH_COLOURS[props.march.type]))
</script>
<!-- A group on the march, clicked on the map: where it comes from and goes, what it is, when it arrives, and calling it back. -->
<template>
<div class="w-64 rounded-sm border-2 border-wood-950 bg-parchment-50 text-sm text-ink-900 shadow-hard">
<div class="flex items-start gap-2 border-b border-wood-700 bg-parchment-200 px-3 py-1.5">
<span class="mt-1 inline-block h-1 w-4 shrink-0" :style="{ background: colour }" />
<p class="min-w-0 flex-1 font-semibold">{{ title }}</p>
<button type="button" class="text-ink-500 hover:text-blood-700" :aria-label="$t('common.close')" @click="emit('close')">
<IconUi name="close" class="size-4" />
</button>
</div>
<dl class="grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 px-3 py-1.5 text-xs">
<dt class="text-ink-500">{{ $t('map.march.from') }}</dt>
<dd class="truncate">
<button type="button" class="hover:underline" @click="emit('center', march.from)">{{ march.from.name }} ({{ march.from.x }}|{{ march.from.y }})</button>
</dd>
<dt class="text-ink-500">{{ $t('map.march.to') }}</dt>
<dd class="truncate">
<button type="button" class="hover:underline" @click="emit('center', march.to)">{{ march.to.name }} ({{ march.to.x }}|{{ march.to.y }})</button>
</dd>
<template v-if="march.units">
<dt class="text-ink-500">{{ $t('map.march.troops') }}</dt>
<dd class="flex flex-wrap gap-x-2 gap-y-0.5">
<span v-for="[unit, count] in unitRows(march.units)" :key="unit" class="inline-flex items-center gap-1 tabular-nums">
<IconUnit :unit="unit as UnitType" class="size-3.5" />{{ count }}
</span>
</dd>
</template>
<template v-else>
<dt class="text-ink-500">{{ $t('map.march.size') }}</dt>
<dd>{{ $t(`map.march.sizes.${march.size}`) }}</dd>
</template>
<dt class="text-ink-500">{{ $t('map.march.arrives') }}</dt>
<dd class="tabular-nums">
{{ formatArrival(Date.parse(march.arrives_at), now, t) }} · <span class="font-semibold">{{ formatDuration(seconds(march.arrives_at)) }}</span>
</dd>
</dl>
<div v-if="cancelLeft > 0" class="flex items-center gap-2 border-t border-parchment-300 px-3 py-2">
<button type="button" class="btn btn-outline px-2 py-1 text-xs" :disabled="busy" @click="emit('cancel')">{{ $t('map.march.cancel') }}</button>
<span class="text-xs text-ink-500 tabular-nums">{{ $t('map.march.cancel_until', { time: formatDuration(cancelLeft) }) }}</span>
</div>
<p v-if="error" class="alert mx-3 mb-2" role="alert">{{ error }}</p>
</div>
</template>

View File

@ -0,0 +1,41 @@
<script setup lang="ts">
import type { MapMovement } from '~/types/map'
const props = defineProps<{
/** The village whose groups to list: those leaving it and those coming to it. */
villageId: number
movements: MapMovement[]
now: number
}>()
const emit = defineEmits<{ march: [id: number] }>()
const { t } = useI18n()
/** Groups under way to or from the village, soonest first; arrived ones are gone. */
const marches = computed(() =>
props.movements
.filter((m) => (m.from.id === props.villageId || m.to.id === props.villageId) && Date.parse(m.arrives_at) > props.now)
.sort((a, b) => Date.parse(a.arrives_at) - Date.parse(b.arrives_at)),
)
const label = (m: MapMovement) => {
const out = m.from.id === props.villageId
const other = out ? m.to : m.from
return `${t(`map.march.legend.${m.raid ? 'raid' : m.type}`)} ${t(out ? 'map.march.out' : 'map.march.in', { village: `${other.name} (${other.x}|${other.y})` })}`
}
const left = (m: MapMovement) => formatDuration(Math.max(0, Math.ceil((Date.parse(m.arrives_at) - props.now) / 1000)))
</script>
<!-- Groups leaving or coming to a village on the map; a click opens the group's card. -->
<template>
<div v-if="marches.length">
<p class="mb-1 text-xs font-semibold tracking-wide text-ink-500 uppercase">{{ $t('map.march.under_way') }}</p>
<ul class="space-y-0.5">
<li v-for="m in marches" :key="m.id">
<button type="button" class="flex w-full items-center gap-2 text-left hover:underline" @click="emit('march', m.id)">
<span class="inline-block h-1 w-3 shrink-0" :style="{ background: m.raid ? MARCH_COLOURS.raid : MARCH_COLOURS[m.type] }" />
<span class="min-w-0 flex-1 truncate">{{ label(m) }}</span>
<span class="font-semibold tabular-nums">{{ left(m) }}</span>
</button>
</li>
</ul>
</div>
</template>

View File

@ -20,6 +20,8 @@ const props = defineProps<{
current?: number | null current?: number | null
/** The clock, for where groups on the march are. */ /** The clock, for where groups on the march are. */
now: number now: number
/** Id of the group on the march that was clicked. */
march?: number | null
}>() }>()
const emit = defineEmits<{ const emit = defineEmits<{
select: [at: { x: number; y: number }] select: [at: { x: number; y: number }]
@ -29,6 +31,8 @@ const emit = defineEmits<{
dragend: [] dragend: []
/** Whole fields, from the arrow keys. */ /** Whole fields, from the arrow keys. */
pan: [dx: number, dy: number] pan: [dx: number, dy: number]
/** A group on the march or its line was clicked. */
march: [id: number]
}>() }>()
const { t } = useI18n() const { t } = useI18n()
@ -126,12 +130,13 @@ const tier = (points: number): 1 | 2 | 3 | 4 | 5 => (points < 150 ? 1 : points <
const relation = (v: MapVillage): MarkerRelation => (v.id === props.current ? 'current' : (v.relation ?? (v.own ? 'own' : v.player ? 'none' : 'barbarian'))) const relation = (v: MapVillage): MarkerRelation => (v.id === props.current ? 'current' : (v.relation ?? (v.own ? 'own' : v.player ? 'none' : 'barbarian')))
// Groups on the march: a line from village to village and the group where it is now, // Groups on the march: a line from village to village and the group where it is now,
// moving straight at constant speed (raiders wait at their camp until they march). // moving straight at constant speed (raiders wait at their camp until they march). A group
// leaves the map when it arrives; the page reloads then and shows what comes of it.
const motion = ref(false) const motion = ref(false)
onMounted(() => (motion.value = !window.matchMedia('(prefers-reduced-motion: reduce)').matches)) onMounted(() => (motion.value = !window.matchMedia('(prefers-reduced-motion: reduce)').matches))
const centre = (p: { x: number; y: number }) => [(p.x + 0.5) * props.field, (p.y + 0.5) * props.field] as const const centre = (p: { x: number; y: number }) => [(p.x + 0.5) * props.field, (p.y + 0.5) * props.field] as const
const marches = computed(() => const marches = computed(() =>
(props.view?.movements ?? []).map((m: MapMovement) => { (props.view?.movements ?? []).filter((m) => Date.parse(m.arrives_at) > props.now).map((m: MapMovement) => {
const [ax, ay] = centre(m.from) const [ax, ay] = centre(m.from)
const [bx, by] = centre(m.to) const [bx, by] = centre(m.to)
const start = Date.parse(m.sent_at) const start = Date.parse(m.sent_at)
@ -331,11 +336,35 @@ function onKey(e: KeyboardEvent) {
<MapVillageMarker :tier="tier(f.village!.points)" :relation="relation(f.village!)" :crown="f.village!.crown" /> <MapVillageMarker :tier="tier(f.village!.points)" :relation="relation(f.village!)" :crown="f.village!.crown" />
</g> </g>
<!-- Groups on the march, over the villages. --> <!-- Groups on the march, over the villages; the line and the group open the group's card. -->
<g v-for="g in marches" :key="`m${g.m.id}`"> <g v-for="g in marches" :key="`m${g.m.id}`">
<line :x1="g.ax" :y1="g.ay" :x2="g.bx" :y2="g.by" :stroke="g.colour" stroke-width="2.5" :stroke-dasharray="g.m.type === 'return' ? '6 5' : undefined" stroke-linecap="round" /> <line v-if="g.m.id === march" :x1="g.ax" :y1="g.ay" :x2="g.bx" :y2="g.by" stroke="#1f150c" stroke-width="6" stroke-linecap="round" />
<line :x1="g.ax" :y1="g.ay" :x2="g.bx" :y2="g.by" :stroke="g.colour" :stroke-width="g.m.id === march ? 3.5 : 2.5" :stroke-dasharray="g.m.type === 'return' ? '6 5' : undefined" stroke-linecap="round" />
<circle :cx="g.bx" :cy="g.by" r="4" :fill="g.colour" /> <circle :cx="g.bx" :cy="g.by" r="4" :fill="g.colour" />
<g :transform="`translate(${g.x} ${g.y}) scale(${Math.max(0.6, field / 55)})`" class="pointer-events-auto" @pointerdown.stop> <line
:x1="g.ax"
:y1="g.ay"
:x2="g.bx"
:y2="g.by"
stroke="transparent"
stroke-width="14"
pointer-events="stroke"
class="cursor-pointer"
@pointerdown.stop
@click="emit('march', g.m.id)"
>
<title>{{ marchTitle(g.m) }}</title>
</line>
<g
:transform="`translate(${g.x} ${g.y}) scale(${Math.max(0.6, field / 55)})`"
class="pointer-events-auto cursor-pointer"
role="button"
tabindex="0"
:aria-label="marchTitle(g.m)"
@pointerdown.stop
@click="emit('march', g.m.id)"
@keydown.enter.stop="emit('march', g.m.id)"
>
<title>{{ marchTitle(g.m) }}</title> <title>{{ marchTitle(g.m) }}</title>
<MapMarch :size="g.m.size" :colour="g.colour" :flip="g.flip" :motion="motion && !g.waiting" /> <MapMarch :size="g.m.size" :colour="g.colour" :flip="g.flip" :motion="motion && !g.waiting" />
</g> </g>

View File

@ -11,6 +11,8 @@ const props = defineProps<{
secondsUntil: (iso: string) => number secondsUntil: (iso: string) => number
/** Fill the whole stage at any shape, without the sideways scroll of narrow frames. */ /** Fill the whole stage at any shape, without the sideways scroll of narrow frames. */
fill?: boolean fill?: boolean
/** A picture only (the landing page): no zoom controls. */
still?: boolean
/** With `fill`: pixels at the edges that windows cover; the whole village fits into the rest. */ /** With `fill`: pixels at the edges that windows cover; the whole village fits into the rest. */
inset?: SceneInset inset?: SceneInset
/** Projected stock, for the storage's tag. */ /** Projected stock, for the storage's tag. */
@ -49,6 +51,18 @@ onMounted(() => {
}) })
onBeforeUnmount(() => observer?.disconnect()) onBeforeUnmount(() => observer?.disconnect())
// On a stage the player pans and zooms over the land round the village.
const { view, viewBox, panning, zoomIn, zoomOut, reset, canZoomIn, canZoomOut, atHome } = useDioramaCamera({
id: () => props.village.id,
stage,
home: () => scene.value.home,
bounds: () => scene.value.bounds,
inset: () => props.inset ?? { top: 0, right: 0, bottom: 0, left: 0 },
enabled: () => !!props.fill,
})
/** The zoom buttons sit in the bottom right corner of the part no window covers. */
const controlsAt = computed(() => ({ right: `${(props.inset?.right ?? 0) + 8}px`, bottom: `${(props.inset?.bottom ?? 0) + 8}px` }))
// Walkers and smoke only move for players who don't ask for reduced motion. // Walkers and smoke only move for players who don't ask for reduced motion.
const motion = ref(false) const motion = ref(false)
onMounted(() => (motion.value = !window.matchMedia('(prefers-reduced-motion: reduce)').matches)) onMounted(() => (motion.value = !window.matchMedia('(prefers-reduced-motion: reduce)').matches))
@ -76,8 +90,8 @@ function clear() {
const press = (id: number) => (props.dismiss ? clear() : toggle(id)) const press = (id: number) => (props.dismiss ? clear() : toggle(id))
const pressPlot = (type: BuildingType) => (props.dismiss ? clear() : pick(type)) const pressPlot = (type: BuildingType) => (props.dismiss ? clear() : pick(type))
/** viewBox units per screen pixel: badges keep the same size however the scene is scaled. */ /** viewBox units per screen pixel: badges keep the same size however the scene is scaled or zoomed. */
const k = computed(() => (scene.value.width / Math.max(1, size.value.w)) * (size.value.w < 900 ? 0.85 : 1)) const k = computed(() => (view.value.w / Math.max(1, size.value.w)) * (size.value.w < 900 ? 0.85 : 1))
// Every building wears a tag like the old village views: its level and the one number // 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 // that says what it does now (app/utils/buildingTags.ts). Sizes are screen pixels, scaled
@ -149,11 +163,11 @@ const timers = computed(() => {
</script> </script>
<template> <template>
<div ref="scroller" class="h-full w-full overflow-y-hidden bg-[#6a7049]" :class="fill ? 'overflow-x-hidden' : 'overflow-x-auto'"> <div ref="scroller" class="relative h-full w-full overflow-y-hidden bg-[#6a7049]" :class="fill ? 'overflow-x-hidden' : 'overflow-x-auto'">
<div ref="stage" class="h-full" :class="fill ? '' : 'min-w-[640px]'"> <div ref="stage" class="h-full" :class="[fill ? 'pan touch-none' : 'min-w-[640px]', { panning }]">
<svg <svg
class="block h-full w-full select-none" class="block h-full w-full select-none"
:viewBox="scene.viewBox" :viewBox="viewBox"
preserveAspectRatio="xMidYMid slice" preserveAspectRatio="xMidYMid slice"
role="group" role="group"
:aria-label="$t('village.diorama.title')" :aria-label="$t('village.diorama.title')"
@ -352,10 +366,35 @@ const timers = computed(() => {
</g> </g>
</svg> </svg>
</div> </div>
<!-- Zoom: the wheel, a pinch, + − 0 or these; drag the land to look round. -->
<div v-if="fill && !still" class="float absolute z-[1] flex border border-wood-900 bg-parchment-200" :style="controlsAt">
<button type="button" class="btn btn-ghost" :disabled="atHome" :title="$t('village.diorama.whole_key')" @click="reset">
{{ $t('village.diorama.whole') }}
</button>
<button type="button" class="btn btn-ghost px-2.5" :disabled="!canZoomOut" :aria-label="$t('village.diorama.zoom_out')" :title="$t('village.diorama.zoom_out_key')" @click="zoomOut">
−
</button>
<button type="button" class="btn btn-ghost px-2.5" :disabled="!canZoomIn" :aria-label="$t('village.diorama.zoom_in')" :title="$t('village.diorama.zoom_in_key')" @click="zoomIn">
+
</button>
</div>
</div> </div>
</template> </template>
<style scoped> <style scoped>
/* The land drags; while it does, nothing under the pointer looks clickable. */
.pan {
cursor: grab;
}
.panning,
.panning .bld,
.panning .plot,
.panning .band,
.panning .cursor-pointer {
cursor: grabbing;
}
/* Buildings are massive and stay put: no lift, no glow, nothing on hover. Only a click /* 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. */ (or keyboard focus) outlines the ground they stand on. */
.bld, .bld,

View File

@ -32,8 +32,8 @@ export function useAuth() {
user, user,
isLoggedIn: () => gameAuth.token() !== null, isLoggedIn: () => gameAuth.token() !== null,
login: async (email: string, password: string) => signedIn(await gameAuth.login(email, password)), login: async (email: string, password: string) => signedIn(await gameAuth.login(email, password)),
register: async (name: string, email: string, password: string) => register: async (name: string, email: string, password: string, terms: boolean) =>
signedIn(await gameAuth.register(name, email, password)), signedIn(await gameAuth.register(name, email, password, terms)),
logout() { logout() {
gameAuth.logout() gameAuth.logout()
user.value = null user.value = null

View File

@ -0,0 +1,232 @@
import type { SceneInset, View } from '~/diorama/scene'
/** How far the camera goes in, as a multiple of the view that fits the whole village. */
const MAX_ZOOM = 4
/** One step of the buttons and keys. */
const STEP = 1.4
/** Pixels a pointer moves before a press becomes a drag, so a shaky click still clicks. */
const DRAG_FROM = 5
interface Camera {
zoom: number
/** Where the view's centre sits, in viewBox units from the home view's centre. */
dx: number
dy: number
}
const HOME: Camera = { zoom: 1, dx: 0, dy: 0 }
// Per village while the app runs, so the view stays put when hopping to the map and back.
const cameras = reactive(new Map<number, Camera>())
const fit = (v: number, lo: number, hi: number) => (lo > hi ? (lo + hi) / 2 : Math.min(hi, Math.max(lo, v)))
/**
* Pan and zoom over the village: the view is the home view (the whole village in the free
* part of the stage) zoomed in or out round a centre, and never leaves the drawn land.
* Drag pans, the wheel and a pinch zoom at the pointer, + − 0 and the arrows work from
* the keyboard. A drag never ends in a click, so it opens nothing.
*/
export function useDioramaCamera(opts: {
id: () => number
stage: Ref<HTMLElement | null>
home: () => View
bounds: () => View
inset: () => SceneInset
enabled: () => boolean
}) {
const minZoom = computed(() => {
const home = opts.home()
const bounds = opts.bounds()
return Math.min(1, Math.max(home.w / bounds.w, home.h / bounds.h))
})
/** The camera inside its limits: zoom in range, the view on the land. */
function clamp(c: Camera): Camera {
const home = opts.home()
const bounds = opts.bounds()
const zoom = Math.min(MAX_ZOOM, Math.max(minZoom.value, c.zoom))
const w = home.w / zoom
const h = home.h / zoom
const hx = home.x + home.w / 2
const hy = home.y + home.h / 2
const cx = fit(hx + c.dx, bounds.x + w / 2, bounds.x + bounds.w - w / 2)
const cy = fit(hy + c.dy, bounds.y + h / 2, bounds.y + bounds.h - h / 2)
return { zoom, dx: cx - hx, dy: cy - hy }
}
const camera = computed<Camera>({
get: () => (opts.enabled() ? clamp(cameras.get(opts.id()) ?? HOME) : HOME),
set: (c) => {
cameras.set(opts.id(), clamp(c))
},
})
const view = computed<View>(() => {
const home = opts.home()
const { zoom, dx, dy } = camera.value
const w = home.w / zoom
const h = home.h / zoom
return { x: home.x + home.w / 2 + dx - w / 2, y: home.y + home.h / 2 + dy - h / 2, w, h }
})
const viewBox = computed(() => {
const v = view.value
return `${v.x.toFixed(1)} ${v.y.toFixed(1)} ${v.w.toFixed(1)} ${v.h.toFixed(1)}`
})
/** Moves the land with the pointer by (px, py) screen pixels. */
function panBy(px: number, py: number) {
const el = opts.stage.value
if (!el?.clientWidth) return
const perPixel = view.value.w / el.clientWidth
const c = camera.value
camera.value = { ...c, dx: c.dx - px * perPixel, dy: c.dy - py * perPixel }
}
/** Zooms by `factor`, keeping the land under the screen point (x, y) where it is. */
function zoomAt(factor: number, x: number, y: number) {
const el = opts.stage.value
if (!el) return
const rect = el.getBoundingClientRect()
const fx = (x - rect.left) / Math.max(1, rect.width)
const fy = (y - rect.top) / Math.max(1, rect.height)
const home = opts.home()
const v = view.value
const zoom = Math.min(MAX_ZOOM, Math.max(minZoom.value, camera.value.zoom * factor))
const w = home.w / zoom
const h = home.h / zoom
const px = v.x + fx * v.w
const py = v.y + fy * v.h
camera.value = { zoom, dx: px - fx * w + w / 2 - (home.x + home.w / 2), dy: py - fy * h + h / 2 - (home.y + home.h / 2) }
}
/** Zooms round the middle of the part of the stage that windows don't cover. */
function zoomBy(factor: number) {
const el = opts.stage.value
if (!el) return
const rect = el.getBoundingClientRect()
const inset = opts.inset()
zoomAt(factor, rect.left + inset.left + (rect.width - inset.left - inset.right) / 2, rect.top + inset.top + (rect.height - inset.top - inset.bottom) / 2)
}
const zoomIn = () => zoomBy(STEP)
const zoomOut = () => zoomBy(1 / STEP)
const reset = () => (camera.value = HOME)
const canZoomIn = computed(() => camera.value.zoom < MAX_ZOOM - 1e-3)
const canZoomOut = computed(() => camera.value.zoom > minZoom.value + 1e-3)
const atHome = computed(() => {
const c = camera.value
return Math.abs(c.zoom - 1) < 1e-3 && Math.abs(c.dx) < 0.5 && Math.abs(c.dy) < 0.5
})
// One pointer drags, two pinch. A press that never moved past DRAG_FROM stays a click.
const pointers = new Map<number, [number, number]>()
const panning = ref(false)
let moved = false
let swallowClick = false
function onPointerDown(e: PointerEvent) {
if (!opts.enabled() || (e.pointerType === 'mouse' && e.button !== 0)) return
if (!pointers.size) {
moved = false
swallowClick = false
}
pointers.set(e.pointerId, [e.clientX, e.clientY])
}
function onPointerMove(e: PointerEvent) {
const last = pointers.get(e.pointerId)
if (!last) return
// Released outside the window before the drag began: no pointerup ever came.
if (e.pointerType === 'mouse' && !(e.buttons & 1)) {
pointers.delete(e.pointerId)
return
}
const now: [number, number] = [e.clientX, e.clientY]
if (pointers.size === 1) {
if (!moved && Math.hypot(now[0] - last[0], now[1] - last[1]) < DRAG_FROM) return
if (!moved) opts.stage.value?.setPointerCapture(e.pointerId)
moved = true
panning.value = true
panBy(now[0] - last[0], now[1] - last[1])
} else if (pointers.size === 2) {
const other = [...pointers].find(([id]) => id !== e.pointerId)![1]
if (!moved) for (const id of pointers.keys()) opts.stage.value?.setPointerCapture(id)
moved = true
panning.value = true
const before = Math.hypot(last[0] - other[0], last[1] - other[1])
const after = Math.hypot(now[0] - other[0], now[1] - other[1])
panBy((now[0] - last[0]) / 2, (now[1] - last[1]) / 2)
if (before > 0) zoomAt(after / before, (now[0] + other[0]) / 2, (now[1] + other[1]) / 2)
}
pointers.set(e.pointerId, now)
}
function onPointerUp(e: PointerEvent) {
if (!pointers.delete(e.pointerId) || pointers.size) return
panning.value = false
// The click that follows a drag lands on whatever is under the pointer; drop it.
if (moved && e.type === 'pointerup') swallowClick = true
}
function onClick(e: MouseEvent) {
if (!swallowClick) return
swallowClick = false
e.stopPropagation()
e.preventDefault()
}
function onWheel(e: WheelEvent) {
if (!opts.enabled()) return
e.preventDefault()
const lines = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? 400 : 1
// A trackpad pinch comes as a wheel with ctrl and small steps.
const speed = e.ctrlKey ? 0.01 : 0.0015
zoomAt(Math.exp(-e.deltaY * lines * speed), e.clientX, e.clientY)
}
// A building reached by Tab that lies outside the free part of the view comes into it.
function onFocusIn(e: FocusEvent) {
const el = e.target
const stage = opts.stage.value
if (!opts.enabled() || !(el instanceof SVGGraphicsElement) || !stage?.clientWidth) return
const box = el.getBBox()
const x = box.x + box.width / 2
const y = box.y + box.height / 2
const v = view.value
const perPixel = v.w / stage.clientWidth
const inset = opts.inset()
const free = { x: v.x + inset.left * perPixel, y: v.y + inset.top * perPixel, r: v.x + v.w - inset.right * perPixel, b: v.y + v.h - inset.bottom * perPixel }
if (x > free.x && x < free.r && y > free.y && y < free.b) return
const c = camera.value
camera.value = { ...c, dx: c.dx + x - (free.x + free.r) / 2, dy: c.dy + y - (free.y + free.b) / 2 }
}
function onKey(e: KeyboardEvent) {
if (!opts.enabled() || e.ctrlKey || e.metaKey || e.altKey || document.querySelector('dialog[open]')) return
const el = e.target as HTMLElement | null
if (el && (el.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(el.tagName))) return
// Arrows pan only while nothing else has focus, so they keep scrolling lists in windows.
const free = !el || el === document.body || !!opts.stage.value?.contains(el)
const step = e.shiftKey ? 240 : 80
const arrows: Record<string, [number, number]> = { ArrowLeft: [step, 0], ArrowRight: [-step, 0], ArrowUp: [0, step], ArrowDown: [0, -step] }
if (e.key === '+' || e.key === '=') zoomIn()
else if (e.key === '-' || e.key === '_') zoomOut()
else if (e.key === '0') reset()
else if (arrows[e.key] && free) panBy(...arrows[e.key]!)
else return
e.preventDefault()
}
onMounted(() => {
const el = opts.stage.value
if (!el) return
el.addEventListener('pointerdown', onPointerDown)
el.addEventListener('pointermove', onPointerMove)
el.addEventListener('pointerup', onPointerUp)
el.addEventListener('pointercancel', onPointerUp)
el.addEventListener('click', onClick, true)
el.addEventListener('wheel', onWheel, { passive: false })
el.addEventListener('focusin', onFocusIn)
window.addEventListener('keydown', onKey)
})
onBeforeUnmount(() => window.removeEventListener('keydown', onKey))
return { view, viewBox, panning, zoomIn, zoomOut, reset, canZoomIn, canZoomOut, atHome }
}

View File

@ -140,11 +140,23 @@ export interface SceneTimer {
buildingId: number | null buildingId: number | null
} }
/** A rectangle in viewBox units. */
export interface View {
x: number
y: number
w: number
h: number
}
export interface Scene { export interface Scene {
viewBox: string viewBox: string
/** viewBox size, for keeping badges a fixed size on screen. */ /** viewBox size, for keeping badges a fixed size on screen. */
width: number width: number
height: number height: number
/** The view that fits the whole village into the free part of the stage (the viewBox). */
home: View
/** Where the land is drawn: the camera pans and zooms out inside it. */
bounds: View
terrain: Poly[] terrain: Poly[]
decals: Poly[] decals: Poly[]
objects: SceneObject[] objects: SceneObject[]
@ -492,6 +504,23 @@ export function wallSegments(Rv: number, level: number, gates: number[]): { face
return out return out
} }
/** How much land a stage's scene draws round its home view, as a multiple of its size. */
const SURROUNDINGS = 1.6
/** Smooth value noise in world units: neighbouring points get similar values, so it comes in patches. */
function patches(x: number, y: number, size: number, seed: number): number {
const gx = x / size
const gy = y / size
const i = Math.floor(gx)
const j = Math.floor(gy)
const ease = (t: number) => t * t * (3 - 2 * t)
const u = ease(gx - i)
const v = ease(gy - j)
const top = hash(i, j, seed) * (1 - u) + hash(i + 1, j, seed) * u
const bottom = hash(i, j + 1, seed) * (1 - u) + hash(i + 1, j + 1, seed) * u
return top * (1 - v) + bottom * v
}
/** Pixels at the stage's edges that windows cover; the village fits into the rest. */ /** Pixels at the stage's edges that windows cover; the village fits into the rest. */
export interface SceneInset { export interface SceneInset {
top: number top: number
@ -503,7 +532,8 @@ export interface SceneInset {
/** /**
* The scene for a stage: either just its shape (`aspect`, the village filling the frame), * The scene for a stage: either just its shape (`aspect`, the village filling the frame),
* or its size in pixels with the covered edges, so the whole village lands in the free * or its size in pixels with the covered edges, so the whole village lands in the free
* part and land and forest run on under the windows to every edge. * part and land and forest run on under the windows to every edge. A stage's scene also
* draws the land round that view (`bounds`), for the camera to pan over and zoom out to.
*/ */
export function buildScene(village: VillageState, frame: number | { width: number; height: number; inset?: SceneInset } = 2.2): Scene { export function buildScene(village: VillageState, frame: number | { width: number; height: number; inset?: SceneInset } = 2.2): Scene {
const aspect = typeof frame === 'number' ? frame : frame.width / Math.max(1, frame.height) const aspect = typeof frame === 'number' ? frame : frame.width / Math.max(1, frame.height)
@ -657,23 +687,27 @@ export function buildScene(village: VillageState, frame: number | { width: numbe
let maxX = Math.max(...pts.map((p) => p[0])) let maxX = Math.max(...pts.map((p) => p[0]))
let minY = Math.min(...pts.map((p) => p[1]), ...labelTops) - U * 1.2 let minY = Math.min(...pts.map((p) => p[1]), ...labelTops) - U * 1.2
let maxY = Math.max(...pts.map((p) => p[1])) + U * 0.8 let maxY = Math.max(...pts.map((p) => p[1])) + U * 0.8
const padX = (maxX - minX) * 0.04 // Room round the village, so a strip of the land outside shows at every edge.
const padX = (maxX - minX) * 0.09
const padY = (maxY - minY) * 0.07
minX -= padX minX -= padX
maxX += padX maxX += padX
minY -= padY
maxY += padY
let w = maxX - minX let w = maxX - minX
let h = maxY - minY let h = maxY - minY
const midX = (minX + maxX) / 2
const midY = (minY + maxY) / 2
if (typeof frame !== 'number') { if (typeof frame !== 'number') {
// Fit the village into the free part of the stage; the view spans the whole stage. // Fit the village into the free part of the stage; the view spans the whole stage.
const inset = frame.inset ?? { top: 0, right: 0, bottom: 0, left: 0 } const inset = frame.inset ?? { top: 0, right: 0, bottom: 0, left: 0 }
const freeW = Math.max(120, frame.width - inset.left - inset.right) const freeW = Math.max(120, frame.width - inset.left - inset.right)
const freeH = Math.max(120, frame.height - inset.top - inset.bottom) const freeH = Math.max(120, frame.height - inset.top - inset.bottom)
const perUnit = Math.min(freeW / w, freeH / h) const perUnit = Math.min(freeW / w, freeH / h)
const cx = (minX + maxX) / 2
const cy = (minY + maxY) / 2
w = frame.width / perUnit w = frame.width / perUnit
h = frame.height / perUnit h = frame.height / perUnit
minX = cx - (inset.left + freeW / 2) / perUnit minX = midX - (inset.left + freeW / 2) / perUnit
minY = cy - (inset.top + freeH / 2) / perUnit minY = midY - (inset.top + freeH / 2) / perUnit
} else if (w / h < aspect) { } else if (w / h < aspect) {
const extra = h * aspect - w const extra = h * aspect - w
minX -= extra / 2 minX -= extra / 2
@ -685,7 +719,17 @@ export function buildScene(village: VillageState, frame: number | { width: numbe
} }
maxX = minX + w maxX = minX + w
maxY = minY + h maxY = minY + h
const view = { x: minX, y: minY, w, h } const view: View = { x: minX, y: minY, w, h }
// On a stage the land runs on round the view, centred on the village, never less than the view.
let bounds = view
if (typeof frame !== 'number') {
const bx = Math.min(view.x, midX - (w * SURROUNDINGS) / 2)
const by = Math.min(view.y, midY - (h * SURROUNDINGS) / 2)
bounds = { x: bx, y: by, w: Math.max(maxX, midX + (w * SURROUNDINGS) / 2) - bx, h: Math.max(maxY, midY + (h * SURROUNDINGS) / 2) - by }
}
const { x: bX, y: bY, w: bW, h: bH } = bounds
// The main road runs on out of the land, wherever its edge is.
const roadEnd = Math.max(Rz * 3, (bY + bH) / Math.SQRT1_2 + U * 4)
// Decals on the ground, back to front by layer. // Decals on the ground, back to front by layer.
const decalFaces: Face[] = [plane(disc(0, 0, Rv + U * 0.25, 40, 7, 0.5), VILLAGE_GROUND)] const decalFaces: Face[] = [plane(disc(0, 0, Rv + U * 0.25, 40, 7, 0.5), VILLAGE_GROUND)]
@ -700,7 +744,7 @@ export function buildScene(village: VillageState, frame: number | { width: numbe
const r = (Rv - U) * Math.sqrt(hash(k, 82)) const r = (Rv - U) * Math.sqrt(hash(k, 82))
decalFaces.push(blot(Math.cos(a) * r, Math.sin(a) * r, U * (0.6 + 0.7 * hash(k, 83)), 9, 800 + k, 0.55, mix(VILLAGE_GROUND, DIRT, 0.6))) decalFaces.push(blot(Math.cos(a) * r, Math.sin(a) * r, U * (0.6 + 0.7 * hash(k, 83)), 9, 800 + k, 0.55, mix(VILLAGE_GROUND, DIRT, 0.6)))
} }
decalFaces.push(road(FRONT, hqRadius * 0.9, Rz * 3, PATH_HALF, 1), ...ruts(FRONT, hqRadius * 0.9, Rz * 3, PATH_HALF, 1)) decalFaces.push(road(FRONT, hqRadius * 0.9, roadEnd, PATH_HALF, 1), ...ruts(FRONT, hqRadius * 0.9, roadEnd, PATH_HALF, 1))
for (const zone of activeZones) { for (const zone of activeZones) {
const seed = ZONE_NAMES.indexOf(zone) + 2 const seed = ZONE_NAMES.indexOf(zone) + 2
decalFaces.push(road(ZONES[zone].angle, hqRadius * 0.9, zoneEnd(zone) + U * 0.5, ZONE_PATH_HALF, seed), ...ruts(ZONES[zone].angle, hqRadius * 0.9, zoneEnd(zone), ZONE_PATH_HALF, seed)) decalFaces.push(road(ZONES[zone].angle, hqRadius * 0.9, zoneEnd(zone) + U * 0.5, ZONE_PATH_HALF, seed), ...ruts(ZONES[zone].angle, hqRadius * 0.9, zoneEnd(zone), ZONE_PATH_HALF, seed))
@ -867,7 +911,7 @@ export function buildScene(village: VillageState, frame: number | { width: numbe
for (const o of hard) objects.push({ key: o.key, depth: o.x + o.y, polys: toPolys(o.faces) }) for (const o of hard) objects.push({ key: o.key, depth: o.x + o.y, polys: toPolys(o.faces) })
const f = U * 1.25 const f = U * 1.25
const cornersW = [inverse([view.x, view.y]), inverse([view.x + w, view.y]), inverse([view.x, view.y + h]), inverse([view.x + w, view.y + h])] const cornersW = [inverse([bX, bY]), inverse([bX + bW, bY]), inverse([bX, bY + bH]), inverse([bX + bW, bY + bH])]
const fi0 = Math.floor(Math.min(...cornersW.map((c) => c[0])) / f) const fi0 = Math.floor(Math.min(...cornersW.map((c) => c[0])) / f)
const fi1 = Math.ceil(Math.max(...cornersW.map((c) => c[0])) / f) const fi1 = Math.ceil(Math.max(...cornersW.map((c) => c[0])) / f)
const fj0 = Math.floor(Math.min(...cornersW.map((c) => c[1])) / f) const fj0 = Math.floor(Math.min(...cornersW.map((c) => c[1])) / f)
@ -878,7 +922,7 @@ export function buildScene(village: VillageState, frame: number | { width: numbe
const x = (i + hash(i, j, 61) * 0.8) * f const x = (i + hash(i, j, 61) * 0.8) * f
const y = (j + hash(i, j, 62) * 0.8) * f const y = (j + hash(i, j, 62) * 0.8) * f
const [X, Y] = project([x, y, 0]) const [X, Y] = project([x, y, 0])
if (X < view.x - U || X > view.x + w + U || Y < view.y || Y > view.y + h + U * 2) continue if (X < bX - U || X > bX + bW + U || Y < bY || Y > bY + bH + U * 2) continue
const r = Math.hypot(x, y) const r = Math.hypot(x, y)
if (r < Rv + U * 1.5) continue if (r < Rv + U * 1.5) continue
if (roadClear(x, y)) continue if (roadClear(x, y)) continue
@ -891,6 +935,8 @@ export function buildScene(village: VillageState, frame: number | { width: numbe
if (inSector(x, y, 'farm', deg(6)) && r < zoneEnd('farm') + U * 1.5) density *= 0.15 if (inSector(x, y, 'farm', deg(6)) && r < zoneEnd('farm') + U * 1.5) density *= 0.15
if (inSector(x, y, 'iron', deg(10))) density *= 0.45 if (inSector(x, y, 'iron', deg(10))) density *= 0.45
if (inSector(x, y, 'clay', deg(4)) && r < zoneEnd('clay') + U) density *= 0.4 if (inSector(x, y, 'clay', deg(4)) && r < zoneEnd('clay') + U) density *= 0.4
// Further out the forest opens into clearings here and there.
if (r > Rz * 1.15) density *= 0.1 + 0.9 * Math.min(1, Math.max(0, (patches(x, y, U * 8, 67) - 0.38) / 0.2))
const size = U * (1.0 + 0.55 * hash(i, j, 65)) const size = U * (1.0 + 0.55 * hash(i, j, 65))
const seed = i * 131 + j const seed = i * 131 + j
if (hash(i, j, 63) > Math.min(density, 0.88)) { if (hash(i, j, 63) > Math.min(density, 0.88)) {
@ -1026,7 +1072,8 @@ export function buildScene(village: VillageState, frame: number | { width: numbe
// the gallows. // the gallows.
const birds: Scene['birds'] = [0, 1].map((k) => { const birds: Scene['birds'] = [0, 1].map((k) => {
const y0 = view.y + h * (0.12 + 0.1 * k) const y0 = view.y + h * (0.12 + 0.1 * k)
return { d: `M${(view.x - U * 2).toFixed(1)} ${y0.toFixed(1)} L${(view.x + w + U * 2).toFixed(1)} ${(y0 - h * 0.08).toFixed(1)}`, dur: 30 + k * 11, begin: -k * 17 } const across = bW / w
return { d: `M${(bX - U * 2).toFixed(1)} ${y0.toFixed(1)} L${(bX + bW + U * 2).toFixed(1)} ${(y0 - h * 0.08 * across).toFixed(1)}`, dur: (30 + k * 11) * across, begin: -k * 17 * across }
}) })
const circle = ([x, y]: V2, rx: number, k: number) => { const circle = ([x, y]: V2, rx: number, k: number) => {
const [cx, cy] = project([x, y, U * (3.2 + k)]) const [cx, cy] = project([x, y, U * (3.2 + k)])
@ -1043,7 +1090,9 @@ export function buildScene(village: VillageState, frame: number | { width: numbe
viewBox: `${view.x.toFixed(1)} ${view.y.toFixed(1)} ${w.toFixed(1)} ${h.toFixed(1)}`, viewBox: `${view.x.toFixed(1)} ${view.y.toFixed(1)} ${w.toFixed(1)} ${h.toFixed(1)}`,
width: w, width: w,
height: h, height: h,
terrain: ground(view, { r0: Rz * 0.9, r1: Rz * 1.8 }), home: view,
bounds,
terrain: ground(bounds, { r0: Rz * 0.9, r1: Rz * 1.8 }),
// One at a time, so the layers keep the order they were added in. // One at a time, so the layers keep the order they were added in.
decals: [...decalFaces, ...shadows].flatMap((face) => toPolys([face])), decals: [...decalFaces, ...shadows].flatMap((face) => toPolys([face])),
// Wall segments keep their own outlines; the band below covers the stretches between. // Wall segments keep their own outlines; the band below covers the stretches between.

View File

@ -1,8 +1,12 @@
const PUBLIC_PATHS = ['/login', '/register'] /** Pages for visitors: the landing page and the account forms send players on to their worlds. */
const GUEST_PATHS = ['/', '/login', '/register']
/** Pages anyone may read. */
const OPEN_PATHS = ['/imprint', '/privacy', '/terms']
export default defineNuxtRouteMiddleware((to) => { export default defineNuxtRouteMiddleware((to) => {
const loggedIn = gameAuth.token() !== null const loggedIn = gameAuth.token() !== null
const isPublic = PUBLIC_PATHS.includes(to.path) if (OPEN_PATHS.includes(to.path)) return
if (!loggedIn && !isPublic) return navigateTo('/login') const isGuest = GUEST_PATHS.includes(to.path)
if (loggedIn && isPublic) return navigateTo('/worlds') if (!loggedIn && !isGuest) return navigateTo('/login')
if (loggedIn && isGuest) return navigateTo('/worlds')
}) })

View File

@ -1670,9 +1670,10 @@ export function createMockServer(): { ws: GameWs; auth: GameAuth } {
addUser(state, email.split('@')[0] || email, email) addUser(state, email.split('@')[0] || email, email)
return signIn(state, user) return signIn(state, user)
}, },
async register(name, email, password) { async register(name, email, password, terms) {
await delay() await delay()
if (!name || !email || !password) fail('invalid_credentials') if (!name || !email || !password) fail('invalid_credentials')
if (!terms) fail('terms_required')
const state = load() const state = load()
if (state.users.some((u) => u.email.toLowerCase() === email.toLowerCase())) fail('email_taken') if (state.users.some((u) => u.email.toLowerCase() === email.toLowerCase())) fail('email_taken')
return signIn(state, addUser(state, name, email)) return signIn(state, addUser(state, name, email))

29
app/pages/imprint.vue Normal file
View File

@ -0,0 +1,29 @@
<script setup lang="ts">
const op = useRuntimeConfig().public
</script>
<template>
<div>
<article class="mx-auto max-w-3xl space-y-4 px-4 py-8 text-sm leading-relaxed">
<h1 class="font-display text-3xl font-semibold text-wood-900" style="font-variant: small-caps">{{ $t('legal.imprint.title') }}</h1>
<section class="panel">
<dl class="grid grid-cols-[auto_1fr] gap-x-6 gap-y-2 p-4">
<dt class="text-ink-500">{{ $t('legal.imprint.operator') }}</dt>
<dd class="font-semibold">{{ op.OPERATOR_NAME }}</dd>
<template v-if="op.OPERATOR_ADDRESS">
<dt class="text-ink-500">{{ $t('legal.imprint.address') }}</dt>
<dd class="whitespace-pre-line">{{ op.OPERATOR_ADDRESS }}</dd>
</template>
<dt class="text-ink-500">{{ $t('legal.imprint.email') }}</dt>
<dd><a :href="`mailto:${op.OPERATOR_EMAIL}`" class="font-semibold text-blood-700 underline">{{ op.OPERATOR_EMAIL }}</a></dd>
<template v-if="op.OPERATOR_REGISTER">
<dt class="text-ink-500">{{ $t('legal.imprint.register') }}</dt>
<dd class="whitespace-pre-line">{{ op.OPERATOR_REGISTER }}</dd>
</template>
</dl>
</section>
<p class="text-ink-700">{{ $t('legal.imprint.content') }}</p>
</article>
<GameFooter />
</div>
</template>

View File

@ -1,7 +1,54 @@
<script setup lang="ts"> <script setup lang="ts">
await navigateTo('/worlds', { replace: true }) // The public face: the game's own village as the picture, what it is about, and the way in.
const demo = demoVillage()
const FEATURES = [
{ key: 'space', icon: 'headquarters' },
{ key: 'raids', icon: 'wall' },
{ key: 'tribes', icon: 'rally_point' },
{ key: 'crowns', icon: 'academy' },
] as const
</script> </script>
<template> <template>
<div /> <div>
<section class="relative h-[min(38rem,72dvh)] overflow-hidden border-b-2 border-wood-900 bg-[#74864a]">
<div class="pointer-events-none absolute inset-0" aria-hidden="true">
<VillageDiorama :village="demo" :seconds-until="() => 0" fill still />
</div>
<div class="float absolute top-1/2 left-4 w-[min(30rem,calc(100%-2rem))] -translate-y-1/2 border-2 border-wood-900 bg-parchment-100 p-5 sm:left-10">
<h1 class="font-display text-5xl font-semibold text-wood-900" style="font-variant: small-caps">{{ $t('app.title') }}</h1>
<p class="mt-2 text-lg font-semibold text-blood-700">{{ $t('auth.tagline') }}</p>
<p class="mt-3 text-sm text-ink-700">{{ $t('landing.pitch') }}</p>
<div class="mt-5 flex flex-wrap gap-2">
<NuxtLink to="/register" class="btn btn-primary px-5 py-2 text-base">{{ $t('landing.play') }}</NuxtLink>
<NuxtLink to="/login" class="btn btn-outline px-5 py-2 text-base">{{ $t('landing.login') }}</NuxtLink>
</div>
<p class="mt-3 text-xs text-ink-500">{{ $t('landing.free') }}</p>
</div>
</section>
<section class="mx-auto grid max-w-[1100px] gap-3 px-4 py-8 sm:grid-cols-2 lg:grid-cols-4">
<article v-for="f in FEATURES" :key="f.key" class="panel">
<div class="panel-head justify-start gap-2">
<IconBuildingTile :type="f.icon" class="size-7" />
<h2 class="panel-title">{{ $t(`landing.features.${f.key}.title`) }}</h2>
</div>
<p class="panel-body text-sm">{{ $t(`landing.features.${f.key}.text`) }}</p>
</article>
</section>
<section class="mx-auto max-w-[1100px] px-4 pb-10">
<div class="panel">
<div class="panel-head"><h2 class="panel-title">{{ $t('landing.how.title') }}</h2></div>
<ol class="grid gap-x-6 gap-y-3 p-4 text-sm sm:grid-cols-2 lg:grid-cols-4">
<li v-for="n in 4" :key="n" class="flex gap-3">
<span class="grid size-8 shrink-0 place-items-center border-2 border-wood-900 bg-wood-800 font-display text-lg text-gold-400">{{ n }}</span>
<span>{{ $t(`landing.how.step${n}`) }}</span>
</li>
</ol>
</div>
</section>
<GameFooter />
</div>
</template> </template>

View File

@ -23,6 +23,7 @@ async function submit() {
</script> </script>
<template> <template>
<div>
<UiAuthCard :title="$t('auth.login.title')"> <UiAuthCard :title="$t('auth.login.title')">
<p v-if="mock" class="mb-4 rounded-sm border border-gold-600 bg-parchment-200 px-3 py-2 text-xs text-wood-900">{{ $t('auth.mock_hint') }}</p> <p v-if="mock" class="mb-4 rounded-sm border border-gold-600 bg-parchment-200 px-3 py-2 text-xs text-wood-900">{{ $t('auth.mock_hint') }}</p>
<form class="space-y-4" @submit.prevent="submit"> <form class="space-y-4" @submit.prevent="submit">
@ -41,4 +42,6 @@ async function submit() {
<NuxtLink to="/register" class="font-semibold text-blood-700 hover:underline">{{ $t('auth.login.to_register') }}</NuxtLink> <NuxtLink to="/register" class="font-semibold text-blood-700 hover:underline">{{ $t('auth.login.to_register') }}</NuxtLink>
</template> </template>
</UiAuthCard> </UiAuthCard>
<GameFooter />
</div>
</template> </template>

40
app/pages/privacy.vue Normal file
View File

@ -0,0 +1,40 @@
<script setup lang="ts">
const op = useRuntimeConfig().public
</script>
<template>
<div>
<article class="mx-auto max-w-3xl space-y-4 px-4 py-8 text-sm leading-relaxed">
<h1 class="font-display text-3xl font-semibold text-wood-900" style="font-variant: small-caps">{{ $t('legal.privacy.title') }}</h1>
<section class="panel">
<div class="panel-head"><h2 class="panel-title">{{ $t('legal.privacy.who.title') }}</h2></div>
<p class="panel-body whitespace-pre-line">{{ $t('legal.privacy.who.body', { name: op.OPERATOR_NAME, email: op.OPERATOR_EMAIL }) }}</p>
</section>
<section class="panel">
<div class="panel-head"><h2 class="panel-title">{{ $t('legal.privacy.data.title') }}</h2></div>
<p class="panel-body whitespace-pre-line">{{ $t('legal.privacy.data.body', { name: op.OPERATOR_NAME, email: op.OPERATOR_EMAIL }) }}</p>
</section>
<section class="panel">
<div class="panel-head"><h2 class="panel-title">{{ $t('legal.privacy.why.title') }}</h2></div>
<p class="panel-body whitespace-pre-line">{{ $t('legal.privacy.why.body', { name: op.OPERATOR_NAME, email: op.OPERATOR_EMAIL }) }}</p>
</section>
<section class="panel">
<div class="panel-head"><h2 class="panel-title">{{ $t('legal.privacy.browser.title') }}</h2></div>
<p class="panel-body whitespace-pre-line">{{ $t('legal.privacy.browser.body', { name: op.OPERATOR_NAME, email: op.OPERATOR_EMAIL }) }}</p>
</section>
<section class="panel">
<div class="panel-head"><h2 class="panel-title">{{ $t('legal.privacy.host.title') }}</h2></div>
<p class="panel-body whitespace-pre-line">{{ $t('legal.privacy.host.body', { name: op.OPERATOR_NAME, email: op.OPERATOR_EMAIL }) }}</p>
</section>
<section class="panel">
<div class="panel-head"><h2 class="panel-title">{{ $t('legal.privacy.keep.title') }}</h2></div>
<p class="panel-body whitespace-pre-line">{{ $t('legal.privacy.keep.body', { name: op.OPERATOR_NAME, email: op.OPERATOR_EMAIL }) }}</p>
</section>
<section class="panel">
<div class="panel-head"><h2 class="panel-title">{{ $t('legal.privacy.rights.title') }}</h2></div>
<p class="panel-body whitespace-pre-line">{{ $t('legal.privacy.rights.body', { name: op.OPERATOR_NAME, email: op.OPERATOR_EMAIL }) }}</p>
</section>
</article>
<GameFooter />
</div>
</template>

View File

@ -1,49 +1,75 @@
<script setup lang="ts"> <script setup lang="ts">
import type { GameError } from '~/types/game'
const { register } = useAuth() const { register } = useAuth()
const errorText = useErrorText() const errorText = useErrorText()
const { t } = useI18n()
const mock = isMockServer const mock = isMockServer
const name = ref('') const form = reactive({ name: '', email: '', password: '', again: '', terms: false })
const email = ref('') /** The field the server (or the form) refused, and why. */
const password = ref('') const problem = ref<{ field: string | null; text: string } | null>(null)
const error = ref<string | null>(null)
const busy = ref(false) const busy = ref(false)
async function submit() { async function submit() {
if (form.password !== form.again) {
problem.value = { field: 'again', text: t('auth.password_mismatch') }
return
}
busy.value = true busy.value = true
error.value = null problem.value = null
try { try {
await register(name.value, email.value, password.value) await register(form.name, form.email, form.password, form.terms)
await navigateTo('/worlds') await navigateTo('/worlds')
} catch (e) { } catch (e) {
error.value = errorText(e) problem.value = { field: (e as GameError)?.field ?? null, text: errorText(e) }
} finally { } finally {
busy.value = false busy.value = false
} }
} }
const wrong = (field: string) => problem.value?.field === field
</script> </script>
<template> <template>
<div>
<UiAuthCard :title="$t('auth.register.title')"> <UiAuthCard :title="$t('auth.register.title')">
<p v-if="mock" class="mb-4 rounded-sm border border-gold-600 bg-parchment-200 px-3 py-2 text-xs text-wood-900">{{ $t('auth.mock_hint') }}</p> <p v-if="mock" class="mb-4 border border-gold-600 bg-parchment-200 px-3 py-2 text-xs text-wood-900">{{ $t('auth.mock_hint') }}</p>
<form class="space-y-4" @submit.prevent="submit"> <form class="space-y-4" novalidate @submit.prevent="submit">
<label class="block"> <label class="block">
<span class="label">{{ $t('auth.name') }}</span> <span class="label">{{ $t('auth.name') }}</span>
<input v-model="name" class="input" type="text" autocomplete="nickname" required /> <input v-model="form.name" class="input" :class="wrong('name') ? 'border-blood-700' : ''" type="text" autocomplete="nickname" maxlength="24" required :aria-invalid="wrong('name')" />
<span class="mt-1 block text-xs" :class="wrong('name') ? 'font-semibold text-blood-700' : 'text-ink-500'">{{ wrong('name') ? problem!.text : $t('auth.name_hint') }}</span>
</label> </label>
<label class="block"> <label class="block">
<span class="label">{{ $t('auth.email') }}</span> <span class="label">{{ $t('auth.email') }}</span>
<input v-model="email" class="input" type="email" autocomplete="email" required /> <input v-model="form.email" class="input" :class="wrong('email') ? 'border-blood-700' : ''" type="email" autocomplete="email" required :aria-invalid="wrong('email')" />
<span v-if="wrong('email')" class="mt-1 block text-xs font-semibold text-blood-700">{{ problem!.text }}</span>
</label> </label>
<label class="block"> <label class="block">
<span class="label">{{ $t('auth.password') }}</span> <span class="label">{{ $t('auth.password') }}</span>
<input v-model="password" class="input" type="password" autocomplete="new-password" required /> <input v-model="form.password" class="input" :class="wrong('password') ? 'border-blood-700' : ''" type="password" autocomplete="new-password" required :aria-invalid="wrong('password')" />
<span class="mt-1 block text-xs" :class="wrong('password') ? 'font-semibold text-blood-700' : 'text-ink-500'">{{ wrong('password') ? problem!.text : $t('auth.password_hint') }}</span>
</label> </label>
<p v-if="error" class="alert" role="alert">{{ error }}</p> <label class="block">
<span class="label">{{ $t('auth.password_again') }}</span>
<input v-model="form.again" class="input" :class="wrong('again') ? 'border-blood-700' : ''" type="password" autocomplete="new-password" required :aria-invalid="wrong('again')" />
<span v-if="wrong('again')" class="mt-1 block text-xs font-semibold text-blood-700">{{ problem!.text }}</span>
</label>
<label class="flex items-start gap-2 text-sm">
<input v-model="form.terms" type="checkbox" class="mt-1" :aria-invalid="wrong('terms')" />
<i18n-t keypath="auth.terms" tag="span" :class="wrong('terms') ? 'font-semibold text-blood-700' : ''">
<template #terms><NuxtLink to="/terms" target="_blank" class="font-semibold text-blood-700 underline">{{ $t('auth.terms_link') }}</NuxtLink></template>
<template #privacy><NuxtLink to="/privacy" target="_blank" class="font-semibold text-blood-700 underline">{{ $t('auth.privacy_link') }}</NuxtLink></template>
</i18n-t>
</label>
<p v-if="problem && !problem.field" class="alert" role="alert">{{ problem.text }}</p>
<p v-else-if="problem?.field === 'terms'" class="alert" role="alert">{{ problem.text }}</p>
<button type="submit" class="btn btn-primary w-full py-2" :disabled="busy">{{ $t('auth.register.submit') }}</button> <button type="submit" class="btn btn-primary w-full py-2" :disabled="busy">{{ $t('auth.register.submit') }}</button>
</form> </form>
<template #footer> <template #footer>
<NuxtLink to="/login" class="font-semibold text-blood-700 hover:underline">{{ $t('auth.register.to_login') }}</NuxtLink> <NuxtLink to="/login" class="font-semibold text-blood-700 hover:underline">{{ $t('auth.register.to_login') }}</NuxtLink>
</template> </template>
</UiAuthCard> </UiAuthCard>
<GameFooter />
</div>
</template> </template>

40
app/pages/terms.vue Normal file
View File

@ -0,0 +1,40 @@
<script setup lang="ts">
const op = useRuntimeConfig().public
</script>
<template>
<div>
<article class="mx-auto max-w-3xl space-y-4 px-4 py-8 text-sm leading-relaxed">
<h1 class="font-display text-3xl font-semibold text-wood-900" style="font-variant: small-caps">{{ $t('legal.terms.title') }}</h1>
<section class="panel">
<div class="panel-head"><h2 class="panel-title">{{ $t('legal.terms.game.title') }}</h2></div>
<p class="panel-body whitespace-pre-line">{{ $t('legal.terms.game.body', { name: op.OPERATOR_NAME, email: op.OPERATOR_EMAIL }) }}</p>
</section>
<section class="panel">
<div class="panel-head"><h2 class="panel-title">{{ $t('legal.terms.account.title') }}</h2></div>
<p class="panel-body whitespace-pre-line">{{ $t('legal.terms.account.body', { name: op.OPERATOR_NAME, email: op.OPERATOR_EMAIL }) }}</p>
</section>
<section class="panel">
<div class="panel-head"><h2 class="panel-title">{{ $t('legal.terms.fair.title') }}</h2></div>
<p class="panel-body whitespace-pre-line">{{ $t('legal.terms.fair.body', { name: op.OPERATOR_NAME, email: op.OPERATOR_EMAIL }) }}</p>
</section>
<section class="panel">
<div class="panel-head"><h2 class="panel-title">{{ $t('legal.terms.chat.title') }}</h2></div>
<p class="panel-body whitespace-pre-line">{{ $t('legal.terms.chat.body', { name: op.OPERATOR_NAME, email: op.OPERATOR_EMAIL }) }}</p>
</section>
<section class="panel">
<div class="panel-head"><h2 class="panel-title">{{ $t('legal.terms.breach.title') }}</h2></div>
<p class="panel-body whitespace-pre-line">{{ $t('legal.terms.breach.body', { name: op.OPERATOR_NAME, email: op.OPERATOR_EMAIL }) }}</p>
</section>
<section class="panel">
<div class="panel-head"><h2 class="panel-title">{{ $t('legal.terms.leave.title') }}</h2></div>
<p class="panel-body whitespace-pre-line">{{ $t('legal.terms.leave.body', { name: op.OPERATOR_NAME, email: op.OPERATOR_EMAIL }) }}</p>
</section>
<section class="panel">
<div class="panel-head"><h2 class="panel-title">{{ $t('legal.terms.changes.title') }}</h2></div>
<p class="panel-body whitespace-pre-line">{{ $t('legal.terms.changes.body', { name: op.OPERATOR_NAME, email: op.OPERATOR_EMAIL }) }}</p>
</section>
</article>
<GameFooter />
</div>
</template>

View File

@ -532,6 +532,8 @@ export interface VillageUpdated {
export interface GameError { export interface GameError {
message: string message: string
code?: string code?: string
/** The form field a refused registration points at. */
field?: string
} }
/** A screen a quest goal points at that is not a building's row on the headquarters screen. */ /** A screen a quest goal points at that is not a building's row on the headquarters screen. */

View File

@ -33,6 +33,8 @@ export interface MapMovement {
arrives_at: string arrives_at: string
size: 'tiny' | 'small' | 'medium' | 'large' | 'huge' size: 'tiny' | 'small' | 'medium' | 'large' | 'huge'
units: Record<string, number> | null units: Record<string, number> | null
/** Until when an own attack or support can be called back; null once it can't. */
cancel_until?: string | null
} }
/** `map.view {world_id, x?, y?, w, h}`: the w × h window around center, kept inside the map. */ /** `map.view {world_id, x?, y?, w, h}`: the w × h window around center, kept inside the map. */

24
app/utils/demoVillage.ts Normal file
View File

@ -0,0 +1,24 @@
import type { Building, BuildingType, VillageState } from '~/types/game'
const SPACE: Partial<Record<BuildingType, number>> = {
headquarters: 9, storage: 4, farm: 4, timber_camp: 4, clay_pit: 4, iron_mine: 4, hiding_place: 1, wall: 0, rally_point: 1, barracks: 6, stable: 6, workshop: 6,
}
/**
* A grown village for the landing page: the diorama draws it like any other, so visitors
* see the game itself. Only the parts the scene reads are filled in.
*/
export function demoVillage(): VillageState {
const levels: [BuildingType, number][] = [
['headquarters', 14], ['storage', 11], ['storage', 7], ['farm', 10], ['farm', 6], ['timber_camp', 9], ['timber_camp', 7],
['clay_pit', 8], ['clay_pit', 6], ['iron_mine', 8], ['hiding_place', 3], ['wall', 9], ['rally_point', 1], ['barracks', 7], ['stable', 4], ['workshop', 2],
]
const buildings = levels.map(([type, level], i): Building => ({
id: i + 1, type, level, space: SPACE[type] ?? 4, priority: 5,
workers: { assigned: 4, required: 4 }, staffing: 1, production: null, upgrade: null, demolish: null, effects: [], next_effects: null,
}))
return {
id: 0, points: 2400, buildings, queue: [], troops: { spear: 160, sword: 90, light_cavalry: 30 },
support: { here: [], away: [] }, military: [], buildable: [], movements: [],
} as unknown as VillageState
}

View File

@ -13,7 +13,7 @@ export type GameWs = Pick<
export interface GameAuth { export interface GameAuth {
token(): string | null token(): string | null
login(email: string, password: string): Promise<AuthResult> login(email: string, password: string): Promise<AuthResult>
register(name: string, email: string, password: string): Promise<AuthResult> register(name: string, email: string, password: string, terms: boolean): Promise<AuthResult>
logout(): void logout(): void
} }
@ -71,15 +71,15 @@ export function setupNetworking(options: NetworkingOptions) {
// Pass the server's `{ code, message }` on, like a refused WS intent. // Pass the server's `{ code, message }` on, like a refused WS intent.
const refused = (e: any): never => { const refused = (e: any): never => {
throw { message: e?.response?.data?.message ?? e?.message, code: e?.response?.data?.code } satisfies GameError throw { message: e?.response?.data?.message ?? e?.message, code: e?.response?.data?.code, field: e?.response?.data?.field ?? undefined } satisfies GameError
} }
gameAuth = { gameAuth = {
token: () => api.bearerToken || null, token: () => api.bearerToken || null,
login: async (email, password) => login: async (email, password) =>
signIn((await api.post<AuthResult>('auth/login', { email, password }).catch(refused)).data), signIn((await api.post<AuthResult>('auth/login', { email, password }).catch(refused)).data),
register: async (name, email, password) => register: async (name, email, password, terms) =>
signIn((await api.post<AuthResult>('auth/register', { name, email, password }).catch(refused)).data), signIn((await api.post<AuthResult>('auth/register', { name, email, password, terms }).catch(refused)).data),
logout() { logout() {
api.setBearer(null) api.setBearer(null)
client.resetConnection() client.resetConnection()

View File

@ -1,6 +1,6 @@
export default { export default {
app: { app: {
title: 'Village Politics', title: 'Kronland',
menu: 'Main menu', menu: 'Main menu',
account: 'Account', account: 'Account',
server_time: 'Server time', server_time: 'Server time',
@ -85,6 +85,11 @@ export default {
pact_active: 'A pact holds: end it first.', pact_active: 'A pact holds: end it first.',
already_member: 'Already in your tribe.', already_member: 'Already in your tribe.',
no_tribe: 'You are not in a tribe.', no_tribe: 'You are not in a tribe.',
name_invalid: 'Names are 3 to 24 letters, digits, spaces, dots, dashes or underscores.',
name_taken: 'That name is taken.',
email_invalid: 'That is not an email address.',
password_short: 'Passwords are at least 8 characters.',
terms_required: 'Accept the terms of play to start.',
chat_length: 'Messages are 1 to 500 characters.', chat_length: 'Messages are 1 to 500 characters.',
chat_slow: 'Slow down a little.', chat_slow: 'Slow down a little.',
no_space: 'Not enough building space.', no_space: 'Not enough building space.',

View File

@ -3,6 +3,8 @@ import networking from '@blax-software/networking/i18n'
import en from './locales/en' import en from './locales/en'
import auth from './pages/auth' import auth from './pages/auth'
import chat from './pages/chat' import chat from './pages/chat'
import landing from './pages/landing'
import legal from './pages/legal'
import map from './pages/map' import map from './pages/map'
import quests from './pages/quests' import quests from './pages/quests'
import ranking from './pages/ranking' import ranking from './pages/ranking'
@ -13,6 +15,6 @@ import worlds from './pages/worlds'
// Explicit imports instead of import.meta.glob: @nuxtjs/i18n also loads this file in the // 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. // Nitro build, where glob imports don't exist. Add new page files here, in path order.
export default mergeMessages({ en }, [auth, chat, map, quests, ranking, reports, tribe, village, worlds], { packages: [networking] }) as { export default mergeMessages({ en }, [auth, chat, landing, legal, map, quests, ranking, reports, tribe, village, worlds], { packages: [networking] }) as {
en: Record<string, any> en: Record<string, any>
} }

View File

@ -7,7 +7,14 @@ export default {
email: 'Email', email: 'Email',
password: 'Password', password: 'Password',
mock_hint: 'Mock server: any email and password work.', mock_hint: 'Mock server: any email and password work.',
tagline: 'Plan your village, one building at a time.', tagline: 'Build your village. Forge your tribe. Take the crown.',
password_again: 'Password again',
password_mismatch: 'The two passwords differ.',
name_hint: '3 to 24 letters, digits, spaces, dots, dashes or underscores. Everyone in the worlds sees it.',
password_hint: 'At least 8 characters.',
terms: 'I accept the {terms} and have read the {privacy}.',
terms_link: 'terms of play',
privacy_link: 'privacy notice',
login: { login: {
title: 'Log in', title: 'Log in',
submit: 'Log in', submit: 'Log in',

25
i18n/pages/landing.ts Normal file
View File

@ -0,0 +1,25 @@
import type { TranslationFile } from '@blax-software/i18n'
export default {
en: {
landing: {
pitch: 'A browser strategy game of villages and tribes. Your village has room for only so much: decide what it becomes, hold off the raiders, make pacts or enemies, and fight for the crown forts that decide each world.',
play: 'Play for free',
login: 'Log in',
free: 'Free to play in the browser. No download, no ads.',
features: {
space: { title: 'Room for choices', text: 'No fixed building list: a village has building space and you fill it. Ten farms or three barracks? Many camps, or one big one? Every village becomes what you make of it.' },
raids: { title: 'Raiders at the gate', text: 'Barbarian camps gather bands against you, announced hours ahead. Build a wall and an army, or strike the camp first and take its stock.' },
tribes: { title: 'Tribes and pacts', text: 'Found a tribe, talk in its chat, seal alliances and non-aggression pacts with others. A pact only ends after a notice period, so betrayal takes planning.' },
crowns: { title: 'Seasons and crowns', text: 'Every world is a season. When the crown forts rise around its centre, whoever holds most of them long enough wins the world.' },
},
how: {
title: 'How a world plays',
step1: 'Pick a world and where on its edge you start. Beginner protection keeps you safe for the first days.',
step2: 'Grow your village: resources, workers, building space. The quest book shows the way.',
step3: 'Raise an army, scout and raid barbarians, hold off their raiders, join or found a tribe.',
step4: 'Mint coins, train noblemen, take villages, and fight for the crowns until the season ends.',
},
},
},
} satisfies TranslationFile

40
i18n/pages/legal.ts Normal file
View File

@ -0,0 +1,40 @@
import type { TranslationFile } from '@blax-software/i18n'
// Plain texts for the public pages. The operator reviews them before launch.
export default {
en: {
legal: {
imprint: {
title: 'Imprint',
operator: 'Operator',
address: 'Address',
email: 'Email',
register: 'Company register',
content: 'The operator is responsible for the content of this game. Players are responsible for what they write in names, descriptions and the chat.',
},
privacy: {
title: 'Privacy notice',
who: { title: 'Who is responsible', body: '{name} runs this game and is responsible for the data described here. Write to {email} with any question about your data.' },
data: {
title: 'What we keep',
body: 'Your account: the player name you chose, your email address, your password (only as a one-way hash), and when you accepted the terms.\nYour game: villages, troops, reports, quests, tribe membership and diplomacy, and the chat messages you write (others in the channel can read them).\nTechnical records: the server logs requests with IP address and time, to keep the game secure and to find errors.',
},
why: { title: 'Why', body: 'We use your account and game data to run the game you signed up for (Art. 6 (1) (b) GDPR). Technical records serve the security and operation of the game (Art. 6 (1) (f) GDPR). We do not sell data, show no advertising and use no tracking or analytics.' },
browser: { title: 'In your browser', body: 'Your browser stores your login token and how you arranged the game\'s windows (local storage). Nothing of it is used to follow you elsewhere.' },
host: { title: 'Hosting', body: 'The game runs on servers the operator rents from Hetzner Online GmbH, which processes the data only on the operator\'s behalf.' },
keep: { title: 'How long', body: 'Account data stays until you delete your account. Game data stays with its world until that world is reset; when you delete your account, your villages turn barbarian and your name goes from the world. Technical records are kept only briefly.' },
rights: { title: 'Your rights', body: 'You may ask what we keep about you, have it corrected or deleted, restrict or object to its use, and receive it in a common format. Deleting your account is possible at any time in the account settings. You may also complain to a data protection authority, in Austria the Datenschutzbehörde (dsb.gv.at).' },
},
terms: {
title: 'Terms of play',
game: { title: 'The game', body: '{name} offers this game for free in the browser. Each world is a season: it ends when a player holds the crown forts long enough, and a new world opens. Rules, balance and features change as the game develops, and there is no claim to the game being available at all times.' },
account: { title: 'Your account', body: 'One account per person. Keep your password to yourself. Player names, tribe names and descriptions must not insult anyone, pretend to be someone else, or break the law.' },
fair: { title: 'Fair play', body: 'Play yourself: no bots, scripts or other automation, no second accounts, no sharing accounts to push one player, and no exploiting bugs. Report a bug to {email} instead.' },
chat: { title: 'Chat', body: 'Stay civil: no insults, threats, harassment, spam, advertising or illegal content.' },
breach: { title: 'If rules are broken', body: 'The operator may remove content, rename players or tribes, and suspend or delete accounts that break these terms.' },
leave: { title: 'Leaving', body: 'You can delete your account at any time in the account settings. Your villages then turn barbarian.' },
changes: { title: 'Changes', body: 'These terms may change; the game will tell you when they do.' },
},
},
},
} satisfies TranslationFile

View File

@ -33,6 +33,16 @@ export default {
raid: 'Raiders from {from} on {to}', raid: 'Raiders from {from} on {to}',
sizes: { tiny: 'tiny group', small: 'small group', medium: 'medium army', large: 'large army', huge: 'huge army' }, sizes: { tiny: 'tiny group', small: 'small group', medium: 'medium army', large: 'large army', huge: 'huge army' },
legend: { attack: 'Attack', support: 'Support', return: 'Return', raid: 'Raiders' }, legend: { attack: 'Attack', support: 'Support', return: 'Return', raid: 'Raiders' },
from: 'From',
to: 'To',
size: 'Size',
troops: 'Troops',
arrives: 'Arrives',
cancel: 'Call back',
cancel_until: 'Can be called back for {time}',
under_way: 'Troops under way',
out: '→ {village}',
in: '← {village}',
}, },
legend: { legend: {
title: 'Legend', title: 'Legend',

View File

@ -286,6 +286,12 @@ export default {
plot_another: '{name}: room for another', plot_another: '{name}: room for another',
space: 'Building space', space: 'Building space',
space_value: '{used} / {max}', space_value: '{used} / {max}',
whole: 'Whole village',
whole_key: 'Whole village (0)',
zoom_in: 'Zoom in',
zoom_in_key: 'Zoom in (+, mouse wheel)',
zoom_out: 'Zoom out',
zoom_out_key: 'Zoom out (−, mouse wheel)',
}, },
build: { build: {
tab_construct: 'Construct', tab_construct: 'Construct',

View File

@ -41,6 +41,11 @@ export default defineNuxtConfig({
PUSHER_APP_KEY: 'village-politics', PUSHER_APP_KEY: 'village-politics',
// true swaps the backend for the in-browser fake in app/mock/ (UI work without a backend). // true swaps the backend for the in-browser fake in app/mock/ (UI work without a backend).
MOCK_SERVER: false, MOCK_SERVER: false,
// The operator for the imprint, privacy and terms pages (set per server in .env).
OPERATOR_NAME: 'Blax Software',
OPERATOR_ADDRESS: '',
OPERATOR_EMAIL: 'office@blax.at',
OPERATOR_REGISTER: '',
}, },
}, },
}) })