56 lines
2.7 KiB
Vue
56 lines
2.7 KiB
Vue
<script setup lang="ts">
|
|
import type { MapMovement, MapVillage } from '~/types/map'
|
|
|
|
defineProps<{
|
|
village: MapVillage | 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 }]; march: [id: number] }>()
|
|
const { current } = useCurrentWorld()
|
|
</script>
|
|
|
|
<template>
|
|
<div class="panel-body text-sm">
|
|
<template v-if="village">
|
|
<p class="font-display text-lg font-semibold">{{ village.name }}</p>
|
|
<dl class="mt-3 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5">
|
|
<dt class="text-ink-500">{{ $t('map.info.coordinates') }}</dt>
|
|
<dd class="font-semibold tabular-nums">{{ village.x }}|{{ village.y }} <span class="text-ink-500">{{ village.continent }}</span></dd>
|
|
<dt class="text-ink-500">{{ $t('map.info.owner') }}</dt>
|
|
<dd>
|
|
{{ village.player?.name ?? $t('map.barbarian') }}<span v-if="village.player?.tribe" class="ml-1 text-ink-500">[{{ village.player.tribe.tag }}]</span>
|
|
</dd>
|
|
<dt class="text-ink-500">{{ $t('map.info.relation') }}</dt>
|
|
<dd class="inline-flex items-center gap-1.5">
|
|
<MapLegendSwatch :colour="RELATION_COLOURS[village.relation]" />{{ $t(`map.legend.${village.relation}`) }}
|
|
</dd>
|
|
<dt class="text-ink-500">{{ $t('map.info.points') }}</dt>
|
|
<dd class="tabular-nums">{{ village.points }}</dd>
|
|
</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">
|
|
<NuxtLink v-if="village.own" :to="`/village/${village.id}`" class="btn btn-primary">{{ $t('map.info.open') }}</NuxtLink>
|
|
<NuxtLink
|
|
v-if="current?.villageId && current.villageId !== village.id"
|
|
:to="{ path: `/village/${current.villageId}/rally`, query: { x: village.x, y: village.y } }"
|
|
class="btn btn-outline"
|
|
>
|
|
<IconUi name="attack" class="size-4" />
|
|
{{ $t('map.info.send') }}
|
|
</NuxtLink>
|
|
<button type="button" class="btn btn-outline" @click="emit('center', { x: village.x, y: village.y })">
|
|
{{ $t('map.info.center') }}
|
|
</button>
|
|
</div>
|
|
</template>
|
|
<template v-else-if="at">
|
|
<p class="text-ink-700">{{ $t('map.info.empty') }}</p>
|
|
<p class="mt-1 font-semibold tabular-nums">{{ at.x }}|{{ at.y }} <span class="text-ink-500">{{ continentOf(at.x, at.y) }}</span></p>
|
|
</template>
|
|
<p v-else class="text-ink-500">{{ $t('map.info.hint') }}</p>
|
|
</div>
|
|
</template>
|