50 lines
1.6 KiB
Vue
50 lines
1.6 KiB
Vue
<script setup lang="ts">
|
||
import type { BuildOrder } from '~/types/game'
|
||
|
||
defineProps<{
|
||
queue: BuildOrder[]
|
||
builders: number
|
||
secondsUntil: (iso: string) => number
|
||
busy: boolean
|
||
}>()
|
||
const emit = defineEmits<{ cancel: [orderId: number] }>()
|
||
const { t } = useI18n()
|
||
|
||
function describe(o: BuildOrder) {
|
||
const type = t(`buildings.${o.type}`)
|
||
if (o.action === 'build') return t('village.queue.build', { type })
|
||
if (o.action === 'upgrade') return t('village.queue.upgrade', { type, level: o.target_level })
|
||
if (o.target_level < 0) return t('village.queue.remove', { type })
|
||
return t('village.queue.demolish', { type, level: o.target_level })
|
||
}
|
||
</script>
|
||
|
||
<template>
|
||
<section>
|
||
<h2>{{ $t('village.queue.title') }} <small>{{ $t('village.queue.builders', { count: builders }) }}</small></h2>
|
||
<p v-if="!queue.length">{{ $t('village.queue.empty') }}</p>
|
||
<table v-else>
|
||
<thead>
|
||
<tr>
|
||
<th>#</th>
|
||
<th>{{ $t('village.queue.order') }}</th>
|
||
<th>{{ $t('village.queue.builder') }}</th>
|
||
<th>{{ $t('village.queue.remaining') }}</th>
|
||
<th />
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr v-for="o in queue" :key="o.id">
|
||
<td>{{ o.position }}</td>
|
||
<td>{{ describe(o) }}</td>
|
||
<td>{{ o.builder ?? '–' }}</td>
|
||
<td>{{ o.finishes_at ? formatDuration(secondsUntil(o.finishes_at)) : $t('village.queue.waiting') }}</td>
|
||
<td>
|
||
<button type="button" :disabled="busy" @click="emit('cancel', o.id)">{{ $t('village.queue.cancel') }}</button>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</section>
|
||
</template>
|