2026-10-29 09:33:26 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import type { Conquest, Resources } from '~/types/game'
|
|
|
|
|
|
|
|
|
|
const props = defineProps<{ conquest: Conquest; resources: Resources; busy: boolean }>()
|
|
|
|
|
const emit = defineEmits<{ mint: [count: number] }>()
|
|
|
|
|
|
|
|
|
|
const count = ref(1)
|
|
|
|
|
/** How many coins the stock pays for now. */
|
|
|
|
|
const affordable = computed(() =>
|
|
|
|
|
Math.floor(Math.min(...(['wood', 'clay', 'iron'] as const).map((r) => (props.conquest.coin_cost[r] ? props.resources[r] / props.conquest.coin_cost[r] : Infinity)))),
|
|
|
|
|
)
|
2026-10-31 09:55:45 +00:00
|
|
|
/** Coins pay for another village: noblemen at loyalty 0 take one. */
|
|
|
|
|
const room = computed(() => props.conquest.slots > props.conquest.used)
|
2026-10-29 09:33:26 +00:00
|
|
|
</script>
|
|
|
|
|
|
2026-10-31 09:55:45 +00:00
|
|
|
<!-- Minting coins at the academy: coins pay for every village beyond the first; noblemen take no slot. -->
|
2026-10-29 09:33:26 +00:00
|
|
|
<template>
|
|
|
|
|
<section class="panel">
|
|
|
|
|
<div class="panel-head">
|
|
|
|
|
<span class="panel-title">{{ $t('village.conquest.title') }}</span>
|
2026-10-31 09:55:45 +00:00
|
|
|
<span class="badge badge-plain tabular-nums">{{ $t('village.conquest.badge', { used: conquest.used, slots: conquest.slots }) }}</span>
|
2026-10-29 09:33:26 +00:00
|
|
|
</div>
|
2026-10-29 13:09:03 +00:00
|
|
|
<div class="panel-body space-y-2 text-sm">
|
2026-10-29 09:33:26 +00:00
|
|
|
<p class="text-ink-700">{{ $t('village.conquest.about') }}</p>
|
|
|
|
|
<table class="grid-table">
|
|
|
|
|
<tbody>
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="whitespace-nowrap">{{ $t('village.conquest.coins') }}</td>
|
|
|
|
|
<td class="text-right font-semibold tabular-nums">{{ conquest.coins }}</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
2026-10-31 10:02:38 +00:00
|
|
|
<td class="whitespace-nowrap">{{ $t('village.conquest.held') }}</td>
|
|
|
|
|
<td class="text-right tabular-nums">{{ conquest.used }}</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="whitespace-nowrap">{{ $t('village.conquest.paid') }}</td>
|
|
|
|
|
<td class="text-right tabular-nums">{{ conquest.slots }}</td>
|
2026-10-31 09:55:45 +00:00
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="whitespace-nowrap">{{ $t('village.conquest.next_village') }}</td>
|
|
|
|
|
<td class="text-right whitespace-nowrap tabular-nums">{{ $t('village.conquest.coins_total', { count: conquest.next_slot_coins }) }}</td>
|
2026-10-29 09:33:26 +00:00
|
|
|
</tr>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
2026-10-31 09:55:45 +00:00
|
|
|
<p v-if="room" class="text-xs font-semibold text-moss-700">{{ $t('village.conquest.room') }}</p>
|
|
|
|
|
<p v-else class="border border-gold-600 bg-gold-400 px-2 py-0.5 text-xs text-ink-900">{{ $t('village.conquest.full') }}</p>
|
2026-10-29 09:33:26 +00:00
|
|
|
<p class="flex flex-wrap items-center justify-between gap-x-2 gap-y-1">
|
|
|
|
|
<span>{{ $t('village.conquest.coin_cost') }}</span>
|
|
|
|
|
<UiCost :cost="conquest.coin_cost" :have="resources" />
|
|
|
|
|
</p>
|
|
|
|
|
<form class="flex items-center justify-end gap-1.5" @submit.prevent="emit('mint', count)">
|
|
|
|
|
<input v-model.number="count" type="number" min="1" :max="Math.max(1, affordable)" class="input w-16 text-right" :aria-label="$t('village.conquest.count')" />
|
|
|
|
|
<span class="text-xs text-ink-500 tabular-nums">({{ affordable }})</span>
|
|
|
|
|
<button type="submit" class="btn btn-primary" :disabled="busy || count < 1 || count > affordable">{{ $t('village.conquest.mint') }}</button>
|
|
|
|
|
</form>
|
|
|
|
|
<p v-if="conquest.max_distance" class="text-xs text-ink-500">{{ $t('village.conquest.range', { fields: conquest.max_distance }) }}</p>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
</template>
|