56 lines
2.3 KiB
Vue
56 lines
2.3 KiB
Vue
<script setup lang="ts">
|
|
import type { SupportGroup, UnitType } from '~/types/game'
|
|
|
|
defineProps<{
|
|
here: SupportGroup[]
|
|
away: SupportGroup[]
|
|
worldId: number
|
|
busy: boolean
|
|
}>()
|
|
const emit = defineEmits<{ sendHome: [homeVillageId: number]; withdraw: [hostVillageId: number] }>()
|
|
</script>
|
|
|
|
<!-- Support standing here (the host feeds it) and own troops standing elsewhere. -->
|
|
<template>
|
|
<section class="panel">
|
|
<div class="panel-head">
|
|
<h2 class="panel-title">{{ $t('village.support.title') }}</h2>
|
|
</div>
|
|
<div class="panel-body space-y-4 text-sm">
|
|
<div
|
|
v-for="list in [
|
|
{ key: 'here', groups: here, action: 'send_home' },
|
|
{ key: 'away', groups: away, action: 'withdraw' },
|
|
]"
|
|
:key="list.key"
|
|
>
|
|
<h3 class="mb-1 text-xs font-semibold tracking-wide text-ink-500 uppercase">{{ $t(`village.support.${list.key}`) }}</h3>
|
|
<ul v-if="list.groups.length" class="divide-y divide-parchment-300">
|
|
<li v-for="g in list.groups" :key="g.village.id" class="flex items-start gap-2 py-1.5">
|
|
<div class="min-w-0 flex-1">
|
|
<NuxtLink :to="{ path: `/map/${worldId}`, query: { x: g.village.x, y: g.village.y } }" class="font-semibold hover:underline">
|
|
{{ villageLabel(g.village) }}
|
|
</NuxtLink>
|
|
<span v-if="g.village.player" class="text-ink-500"> {{ g.village.player.name }}</span>
|
|
<div class="mt-0.5 flex flex-wrap gap-x-2.5 gap-y-0.5 text-xs text-ink-700">
|
|
<span v-for="[unit, count] in unitRows(g.units)" :key="unit" class="inline-flex items-center gap-1 tabular-nums">
|
|
<IconUnit :unit="unit as UnitType" class="size-3.5" />{{ count }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<button
|
|
type="button"
|
|
class="btn btn-outline px-2 py-0.5 text-xs"
|
|
:disabled="busy"
|
|
@click="list.key === 'here' ? emit('sendHome', g.village.id) : emit('withdraw', g.village.id)"
|
|
>
|
|
{{ $t(`village.support.${list.action}`) }}
|
|
</button>
|
|
</li>
|
|
</ul>
|
|
<p v-else class="text-ink-500">{{ $t(`village.support.none_${list.key}`) }}</p>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</template>
|