feat: one construction table for upgrades and new buildings, demolition tab, dense workforce table
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d8d752c202
commit
0c02723b00
|
|
@ -5,13 +5,15 @@ defineProps<{
|
||||||
cost: Cost
|
cost: Cost
|
||||||
/** Projected stock; amounts the village lacks show in red. */
|
/** Projected stock; amounts the village lacks show in red. */
|
||||||
have?: Resources | null
|
have?: Resources | null
|
||||||
|
/** Keep the three amounts on one line, for table cells. */
|
||||||
|
nowrap?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const list = ['wood', 'clay', 'iron'] as const
|
const list = ['wood', 'clay', 'iron'] as const
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<span class="inline-flex flex-wrap items-center gap-x-2.5 gap-y-1 text-xs tabular-nums">
|
<span class="inline-flex items-center gap-x-2.5 gap-y-1 text-xs tabular-nums" :class="nowrap ? 'whitespace-nowrap' : 'flex-wrap'">
|
||||||
<span
|
<span
|
||||||
v-for="r in list"
|
v-for="r in list"
|
||||||
:key="r"
|
:key="r"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { BuildOption, Building, BuildingType, Cost, Resources } from '~/types/game'
|
import type { BuildOption, Building, BuildingType, Cost, Offer, Resources } from '~/types/game'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
options: BuildOption[]
|
options: BuildOption[]
|
||||||
|
|
@ -9,38 +9,103 @@ const props = defineProps<{
|
||||||
canAfford: (cost: Cost) => boolean
|
canAfford: (cost: Cost) => boolean
|
||||||
busy: boolean
|
busy: boolean
|
||||||
}>()
|
}>()
|
||||||
const emit = defineEmits<{ build: [type: BuildingType] }>()
|
const emit = defineEmits<{
|
||||||
|
build: [type: BuildingType]
|
||||||
|
upgrade: [buildingId: number]
|
||||||
|
demolish: [buildingId: number]
|
||||||
|
select: [buildingId: number]
|
||||||
|
}>()
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
// One row per type, like the Die Stämme headquarters: what is possible now on top,
|
// Like the Die Stämme headquarters: one table where every building upgrades in its own
|
||||||
// types still waiting for requirements in their own list below.
|
// row, and building one more of a type is the row below its instances. Demolition is
|
||||||
const available = computed(() => props.options.filter((o) => o.blocked !== 'requires'))
|
// the second tab; types still waiting for requirements are listed at the bottom.
|
||||||
const locked = computed(() => props.options.filter((o) => o.blocked === 'requires'))
|
const tab = ref<'construct' | 'demolish'>('construct')
|
||||||
|
|
||||||
const built = computed(() => {
|
const byType = computed(() => {
|
||||||
const counts: Partial<Record<BuildingType, number>> = {}
|
const map = new Map<BuildingType, Building[]>()
|
||||||
for (const b of props.buildings) counts[b.type] = (counts[b.type] ?? 0) + 1
|
for (const b of props.buildings) map.set(b.type, [...(map.get(b.type) ?? []), b])
|
||||||
return counts
|
return map
|
||||||
})
|
})
|
||||||
|
|
||||||
function status(o: BuildOption) {
|
type Row =
|
||||||
if (o.blocked) return t(`village.blocked.${o.blocked}`)
|
| { kind: 'upgrade'; key: string; type: BuildingType; name: string; building: Building; offer: Offer | null }
|
||||||
if (!props.canAfford(o.cost)) return t('village.blocked.resources')
|
| { kind: 'build'; key: string; type: BuildingType; name: string; option: BuildOption }
|
||||||
|
|
||||||
|
const rows = computed<Row[]>(() => {
|
||||||
|
const out: Row[] = []
|
||||||
|
for (const o of props.options) {
|
||||||
|
if (o.blocked === 'requires') continue
|
||||||
|
const instances = byType.value.get(o.type) ?? []
|
||||||
|
const numbered = instances.length > 1 || (instances.length > 0 && o.blocked !== 'max_per_village')
|
||||||
|
instances.forEach((b, i) => {
|
||||||
|
out.push({
|
||||||
|
kind: 'upgrade',
|
||||||
|
key: `b${b.id}`,
|
||||||
|
type: b.type,
|
||||||
|
name: numbered ? t('village.build.nth', { name: t(`buildings.${b.type}`), n: i + 1 }) : t(`buildings.${b.type}`),
|
||||||
|
building: b,
|
||||||
|
offer: b.upgrade,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
// A unique type that already stands has nothing more to build.
|
||||||
|
if (o.blocked === 'max_per_village' && instances.length) continue
|
||||||
|
out.push({
|
||||||
|
kind: 'build',
|
||||||
|
key: `new-${o.type}`,
|
||||||
|
type: o.type,
|
||||||
|
name: instances.length ? t('village.build.nth', { name: t(`buildings.${o.type}`), n: instances.length + 1 }) : t(`buildings.${o.type}`),
|
||||||
|
option: o,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
})
|
||||||
|
|
||||||
|
const locked = computed(() => props.options.filter((o) => o.blocked === 'requires'))
|
||||||
|
|
||||||
|
/** Why a row can't be built now, or '' when its button shows. */
|
||||||
|
function reason(offer: Offer | null) {
|
||||||
|
if (!offer) return t('village.blocked.max_level')
|
||||||
|
if (offer.blocked) return t(`village.blocked.${offer.blocked}`)
|
||||||
|
if (!props.canAfford(offer.cost)) return t('village.blocked.resources')
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const demolishable = computed(() =>
|
||||||
|
props.buildings.map((b) => ({
|
||||||
|
b,
|
||||||
|
name: (byType.value.get(b.type)?.length ?? 0) > 1
|
||||||
|
? t('village.build.nth', { name: t(`buildings.${b.type}`), n: byType.value.get(b.type)!.indexOf(b) + 1 })
|
||||||
|
: t(`buildings.${b.type}`),
|
||||||
|
})),
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<section class="panel overflow-hidden">
|
<section class="panel overflow-hidden">
|
||||||
<div class="panel-head">
|
<div class="panel-head">
|
||||||
<h2 class="panel-title">{{ $t('village.build.title') }}</h2>
|
<div class="flex items-center gap-1" role="tablist">
|
||||||
|
<button
|
||||||
|
v-for="name in ['construct', 'demolish'] as const"
|
||||||
|
:key="name"
|
||||||
|
type="button"
|
||||||
|
role="tab"
|
||||||
|
:aria-selected="tab === name"
|
||||||
|
class="rounded-sm border px-3 py-1 font-display text-base font-semibold"
|
||||||
|
:class="tab === name ? 'border-wood-700 bg-parchment-50 text-wood-900' : 'border-transparent text-ink-500 hover:text-wood-900'"
|
||||||
|
style="font-variant: small-caps"
|
||||||
|
@click="tab = name"
|
||||||
|
>
|
||||||
|
{{ $t(`village.build.tab_${name}`) }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<span class="badge badge-plain">
|
<span class="badge badge-plain">
|
||||||
{{ $t('village.build.free_space', { free: space.max - space.used }) }}
|
{{ $t('village.build.free_space', { free: space.max - space.used }) }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="overflow-x-auto">
|
<div v-if="tab === 'construct'" class="overflow-x-auto">
|
||||||
<table class="w-full min-w-[34rem] border-collapse text-sm">
|
<table class="w-full min-w-[36rem] border-collapse text-sm">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="border-b-2 border-wood-700 bg-parchment-100 text-left text-xs font-semibold text-ink-700">
|
<tr class="border-b-2 border-wood-700 bg-parchment-100 text-left text-xs font-semibold text-ink-700">
|
||||||
<th class="px-3 py-1.5">{{ $t('village.build.building') }}</th>
|
<th class="px-3 py-1.5">{{ $t('village.build.building') }}</th>
|
||||||
|
|
@ -51,41 +116,66 @@ function status(o: BuildOption) {
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr
|
<tr v-for="row in rows" :key="row.key" class="border-b border-parchment-300 last:border-b-0 even:bg-parchment-100">
|
||||||
v-for="o in available"
|
<td class="px-3 py-1">
|
||||||
:key="o.type"
|
|
||||||
class="border-b border-parchment-300 last:border-b-0 even:bg-parchment-100"
|
|
||||||
:class="o.blocked ? 'text-ink-500' : ''"
|
|
||||||
>
|
|
||||||
<td class="px-3 py-1.5">
|
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<IconBuildingTile :type="o.type" class="size-7" />
|
<IconBuildingTile :type="row.type" class="size-7" :class="row.kind === 'build' ? 'opacity-70' : ''" />
|
||||||
<div class="min-w-0 leading-tight">
|
<div class="min-w-0 leading-tight">
|
||||||
<p class="truncate font-semibold">{{ $t(`buildings.${o.type}`) }}</p>
|
<button
|
||||||
<p v-if="built[o.type]" class="text-xs text-ink-500">{{ $t('village.build.built', { count: built[o.type] }) }}</p>
|
v-if="row.kind === 'upgrade'"
|
||||||
|
type="button"
|
||||||
|
class="block max-w-full truncate text-left font-semibold hover:text-blood-700 hover:underline"
|
||||||
|
:title="$t('village.buildings.show')"
|
||||||
|
@click="emit('select', row.building.id)"
|
||||||
|
>
|
||||||
|
{{ row.name }}
|
||||||
|
</button>
|
||||||
|
<p v-else class="truncate font-semibold">{{ row.name }}</p>
|
||||||
|
<p class="text-xs text-ink-500">
|
||||||
|
{{ row.kind === 'upgrade' ? $t('village.buildings.level_n', { level: row.building.level }) : $t('village.build.not_built') }}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="px-2 py-1.5"><UiCost :cost="o.cost" :have="resources" /></td>
|
<template v-if="row.kind === 'upgrade'">
|
||||||
<td class="px-2 py-1.5 text-right tabular-nums">{{ o.space || '–' }}</td>
|
<td class="px-2 py-1"><UiCost v-if="row.offer" :cost="row.offer.cost" :have="resources" nowrap /></td>
|
||||||
<td class="px-2 py-1.5 text-right tabular-nums whitespace-nowrap">{{ formatDuration(o.seconds) }}</td>
|
<td class="px-2 py-1 text-right text-ink-400">–</td>
|
||||||
<td class="px-3 py-1.5 text-right">
|
<td class="px-2 py-1 text-right tabular-nums whitespace-nowrap">{{ row.offer ? formatDuration(row.offer.seconds) : '' }}</td>
|
||||||
|
<td class="px-3 py-1 text-right">
|
||||||
<button
|
<button
|
||||||
v-if="!status(o)"
|
v-if="!reason(row.offer)"
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-primary px-2.5 py-1"
|
class="btn btn-primary min-w-[5.5rem] px-2.5 py-1"
|
||||||
:disabled="busy"
|
:disabled="busy"
|
||||||
@click="emit('build', o.type)"
|
@click="emit('upgrade', row.building.id)"
|
||||||
|
>
|
||||||
|
<IconUi name="up" class="size-3.5" />
|
||||||
|
{{ $t('village.build.level_button', { level: row.offer!.target_level }) }}
|
||||||
|
</button>
|
||||||
|
<span v-else class="text-xs font-semibold text-blood-700">{{ reason(row.offer) }}</span>
|
||||||
|
</td>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<td class="px-2 py-1"><UiCost :cost="row.option.cost" :have="resources" nowrap /></td>
|
||||||
|
<td class="px-2 py-1 text-right tabular-nums">{{ row.option.space || '–' }}</td>
|
||||||
|
<td class="px-2 py-1 text-right tabular-nums whitespace-nowrap">{{ formatDuration(row.option.seconds) }}</td>
|
||||||
|
<td class="px-3 py-1 text-right">
|
||||||
|
<button
|
||||||
|
v-if="!reason(row.option)"
|
||||||
|
type="button"
|
||||||
|
class="btn btn-outline min-w-[5.5rem] border-blood-700 px-2.5 py-1 text-blood-700"
|
||||||
|
:disabled="busy"
|
||||||
|
@click="emit('build', row.type)"
|
||||||
>
|
>
|
||||||
<IconUi name="hammer" class="size-3.5" />
|
<IconUi name="hammer" class="size-3.5" />
|
||||||
{{ $t('village.build.submit') }}
|
{{ $t('village.build.submit') }}
|
||||||
</button>
|
</button>
|
||||||
<span v-else class="text-xs font-semibold text-blood-700">{{ status(o) }}</span>
|
<span v-else class="text-xs font-semibold text-blood-700">{{ reason(row.option) }}</span>
|
||||||
</td>
|
</td>
|
||||||
|
</template>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
|
||||||
|
|
||||||
<template v-if="locked.length">
|
<template v-if="locked.length">
|
||||||
<h3 class="border-y-2 border-wood-700 bg-parchment-200 px-3 py-1.5 font-display text-sm font-semibold text-wood-900" style="font-variant: small-caps">
|
<h3 class="border-y-2 border-wood-700 bg-parchment-200 px-3 py-1.5 font-display text-sm font-semibold text-wood-900" style="font-variant: small-caps">
|
||||||
|
|
@ -94,13 +184,13 @@ function status(o: BuildOption) {
|
||||||
<table class="w-full border-collapse text-sm">
|
<table class="w-full border-collapse text-sm">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="o in locked" :key="o.type" class="border-b border-parchment-300 text-ink-500 last:border-b-0">
|
<tr v-for="o in locked" :key="o.type" class="border-b border-parchment-300 text-ink-500 last:border-b-0">
|
||||||
<td class="w-1/3 px-3 py-1.5">
|
<td class="w-1/3 px-3 py-1">
|
||||||
<div class="flex items-center gap-2 opacity-70">
|
<div class="flex items-center gap-2 opacity-70">
|
||||||
<IconBuildingTile :type="o.type" class="size-7" />
|
<IconBuildingTile :type="o.type" class="size-7" />
|
||||||
<span class="font-semibold">{{ $t(`buildings.${o.type}`) }}</span>
|
<span class="font-semibold">{{ $t(`buildings.${o.type}`) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="px-2 py-1.5">
|
<td class="px-2 py-1">
|
||||||
<span class="mr-2 text-xs">{{ $t('village.build.requires') }}</span>
|
<span class="mr-2 text-xs">{{ $t('village.build.requires') }}</span>
|
||||||
<span v-for="r in o.requires" :key="r.type" class="mr-3 inline-flex items-center gap-1 whitespace-nowrap">
|
<span v-for="r in o.requires" :key="r.type" class="mr-3 inline-flex items-center gap-1 whitespace-nowrap">
|
||||||
<IconBuildingTile :type="r.type" class="size-5" />
|
<IconBuildingTile :type="r.type" class="size-5" />
|
||||||
|
|
@ -111,5 +201,50 @@ function status(o: BuildOption) {
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</template>
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else class="overflow-x-auto">
|
||||||
|
<table class="w-full min-w-[34rem] border-collapse text-sm">
|
||||||
|
<thead>
|
||||||
|
<tr class="border-b-2 border-wood-700 bg-parchment-100 text-left text-xs font-semibold text-ink-700">
|
||||||
|
<th class="px-3 py-1.5">{{ $t('village.build.building') }}</th>
|
||||||
|
<th class="px-2 py-1.5">{{ $t('village.build.refund') }}</th>
|
||||||
|
<th class="px-2 py-1.5 text-right">{{ $t('village.build.time') }}</th>
|
||||||
|
<th class="px-3 py-1.5 text-right">{{ $t('village.build.tab_demolish') }}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="{ b, name } in demolishable" :key="b.id" class="border-b border-parchment-300 last:border-b-0 even:bg-parchment-100">
|
||||||
|
<td class="px-3 py-1">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<IconBuildingTile :type="b.type" class="size-7" />
|
||||||
|
<div class="min-w-0 leading-tight">
|
||||||
|
<p class="truncate font-semibold">{{ name }}</p>
|
||||||
|
<p class="text-xs text-ink-500">{{ $t('village.buildings.level_n', { level: b.level }) }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="px-2 py-1"><UiCost v-if="b.demolish" :cost="b.demolish.refund" nowrap /></td>
|
||||||
|
<td class="px-2 py-1 text-right tabular-nums whitespace-nowrap">{{ b.demolish ? formatDuration(b.demolish.seconds) : '' }}</td>
|
||||||
|
<td class="px-3 py-1 text-right">
|
||||||
|
<button
|
||||||
|
v-if="b.demolish"
|
||||||
|
type="button"
|
||||||
|
class="btn btn-outline min-w-[5.5rem] border-blood-700 px-2.5 py-1 text-blood-700"
|
||||||
|
:disabled="busy"
|
||||||
|
@click="emit('demolish', b.id)"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
b.demolish.target_level < 0
|
||||||
|
? $t('village.build.remove')
|
||||||
|
: $t('village.build.level_button', { level: b.demolish.target_level })
|
||||||
|
}}
|
||||||
|
</button>
|
||||||
|
<span v-else class="text-xs font-semibold text-ink-500">{{ $t('village.build.core') }}</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -1,71 +1,80 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Building, Cost, Resources } from '~/types/game'
|
import type { Building, BuildingType } from '~/types/game'
|
||||||
|
|
||||||
defineProps<{
|
const props = defineProps<{
|
||||||
buildings: Building[]
|
buildings: Building[]
|
||||||
resources: Resources
|
|
||||||
canAfford: (cost: Cost) => boolean
|
|
||||||
busy: boolean
|
busy: boolean
|
||||||
}>()
|
}>()
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
select: [buildingId: number]
|
select: [buildingId: number]
|
||||||
upgrade: [buildingId: number]
|
|
||||||
demolish: [buildingId: number]
|
|
||||||
priority: [buildingId: number, priority: number]
|
priority: [buildingId: number, priority: number]
|
||||||
}>()
|
}>()
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
const demolishTitle = (b: Building) =>
|
// Who works where: building and upgrading live in the construction table above.
|
||||||
b.demolish ? `${t('village.buildings.refund')} ${formatCost(b.demolish.refund)}, ${formatDuration(b.demolish.seconds)}` : ''
|
const named = computed(() => {
|
||||||
|
const seen = new Map<BuildingType, number>()
|
||||||
|
const totals = new Map<BuildingType, number>()
|
||||||
|
for (const b of props.buildings) totals.set(b.type, (totals.get(b.type) ?? 0) + 1)
|
||||||
|
return props.buildings.map((b) => {
|
||||||
|
const n = (seen.get(b.type) ?? 0) + 1
|
||||||
|
seen.set(b.type, n)
|
||||||
|
return {
|
||||||
|
b,
|
||||||
|
name: (totals.get(b.type) ?? 0) > 1 ? t('village.build.nth', { name: t(`buildings.${b.type}`), n }) : t(`buildings.${b.type}`),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<section class="panel">
|
<section class="panel overflow-hidden">
|
||||||
<div class="panel-head">
|
<div class="panel-head">
|
||||||
<h2 class="panel-title">{{ $t('village.buildings.title') }}</h2>
|
<h2 class="panel-title">{{ $t('village.buildings.title') }}</h2>
|
||||||
<span class="badge badge-plain">{{ buildings.length }}</span>
|
<span class="badge badge-plain">{{ buildings.length }}</span>
|
||||||
</div>
|
</div>
|
||||||
<ul class="divide-y divide-parchment-200">
|
<div class="overflow-x-auto">
|
||||||
<li
|
<table class="w-full min-w-[34rem] border-collapse text-sm">
|
||||||
v-for="b in buildings"
|
<thead>
|
||||||
:key="b.id"
|
<tr class="border-b-2 border-wood-700 bg-parchment-100 text-left text-xs font-semibold text-ink-700">
|
||||||
class="grid gap-3 px-4 py-3 md:grid-cols-[minmax(0,13rem)_minmax(0,1fr)_19rem] md:items-center"
|
<th class="px-3 py-1.5">{{ $t('village.buildings.type') }}</th>
|
||||||
>
|
<th class="px-2 py-1.5 text-right">{{ $t('village.buildings.level') }}</th>
|
||||||
<div class="flex min-w-0 items-center gap-3">
|
<th class="w-40 px-2 py-1.5">{{ $t('village.buildings.workers') }}</th>
|
||||||
<IconBuildingTile :type="b.type" class="size-11" />
|
<th class="px-2 py-1.5">{{ $t('village.buildings.output') }}</th>
|
||||||
<div class="min-w-0">
|
<th class="px-3 py-1.5 text-right">{{ $t('village.buildings.priority') }}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="{ b, name } in named" :key="b.id" class="border-b border-parchment-300 last:border-b-0 even:bg-parchment-100">
|
||||||
|
<td class="px-3 py-1">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<IconBuildingTile :type="b.type" class="size-7" />
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="block max-w-full truncate text-left font-medium hover:text-blood-700 hover:underline"
|
class="truncate text-left font-semibold hover:text-blood-700 hover:underline"
|
||||||
:title="$t('village.buildings.show')"
|
:title="$t('village.buildings.show')"
|
||||||
@click="emit('select', b.id)"
|
@click="emit('select', b.id)"
|
||||||
>
|
>
|
||||||
{{ $t(`buildings.${b.type}`) }}
|
{{ name }}
|
||||||
</button>
|
</button>
|
||||||
<p class="text-xs text-ink-500">
|
|
||||||
{{ $t('village.buildings.level_n', { level: b.level }) }}
|
|
||||||
<template v-if="b.space"> · {{ $t('village.build.space', { space: b.space }) }}</template>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="px-2 py-1 text-right font-semibold tabular-nums">{{ b.level }}</td>
|
||||||
|
<td class="px-2 py-1">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<span class="w-12 shrink-0 text-xs tabular-nums">{{ b.workers.assigned }}/{{ b.workers.required }}</span>
|
||||||
|
<UiBar :value="b.staffing" :tone="b.staffing < 1 ? 'rose' : 'emerald'" />
|
||||||
</div>
|
</div>
|
||||||
|
</td>
|
||||||
<div class="grid grid-cols-3 gap-3 text-sm">
|
<td class="px-2 py-1">
|
||||||
<div class="min-w-0">
|
<span v-if="b.production" class="flex items-center gap-1 tabular-nums whitespace-nowrap">
|
||||||
<p class="text-xs text-ink-500">{{ $t('village.buildings.workers') }}</p>
|
|
||||||
<p class="tabular-nums">{{ b.workers.assigned }}/{{ b.workers.required }}</p>
|
|
||||||
<UiBar class="mt-1" :value="b.staffing" :tone="b.staffing < 1 ? 'rose' : 'emerald'" />
|
|
||||||
</div>
|
|
||||||
<div class="min-w-0">
|
|
||||||
<p class="text-xs text-ink-500">{{ $t('village.buildings.output') }}</p>
|
|
||||||
<p v-if="b.production" class="flex items-center gap-1 tabular-nums">
|
|
||||||
<IconResource :resource="b.production.resource" class="size-4" />
|
<IconResource :resource="b.production.resource" class="size-4" />
|
||||||
{{ $t('village.resources.per_hour', { rate: formatRate(b.production.per_hour) }) }}
|
{{ $t('village.resources.per_hour', { rate: formatRate(b.production.per_hour) }) }}
|
||||||
</p>
|
</span>
|
||||||
<p v-else class="text-ink-400">–</p>
|
<span v-else class="text-ink-400">–</span>
|
||||||
</div>
|
</td>
|
||||||
<div class="min-w-0">
|
<td class="px-3 py-1 text-right">
|
||||||
<p class="text-xs text-ink-500">{{ $t('village.buildings.priority') }}</p>
|
<div class="inline-flex items-center rounded-sm border border-wood-600 bg-parchment-50">
|
||||||
<div class="mt-0.5 inline-flex items-center rounded-sm border border-wood-600 bg-parchment-50">
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-ghost rounded-r-none p-1"
|
class="btn btn-ghost rounded-r-none p-1"
|
||||||
|
|
@ -86,40 +95,10 @@ const demolishTitle = (b: Building) =>
|
||||||
<IconUi name="plus" class="size-3.5" />
|
<IconUi name="plus" class="size-3.5" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex flex-wrap items-center gap-x-3 gap-y-2 md:justify-end">
|
|
||||||
<div v-if="b.upgrade" class="flex flex-col items-start gap-1 md:items-end">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="btn btn-primary"
|
|
||||||
:disabled="busy || !canAfford(b.upgrade.cost)"
|
|
||||||
@click="emit('upgrade', b.id)"
|
|
||||||
>
|
|
||||||
<IconUi name="up" class="size-3.5" />
|
|
||||||
{{ $t('village.buildings.upgrade', { level: b.upgrade.target_level }) }}
|
|
||||||
</button>
|
|
||||||
<span class="flex items-center gap-2 text-xs text-ink-500">
|
|
||||||
<UiCost :cost="b.upgrade.cost" :have="resources" />
|
|
||||||
<span class="flex items-center gap-1 tabular-nums">
|
|
||||||
<IconUi name="clock" class="size-3" />
|
|
||||||
{{ formatDuration(b.upgrade.seconds) }}
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
v-if="b.demolish"
|
|
||||||
type="button"
|
|
||||||
class="btn btn-danger"
|
|
||||||
:title="demolishTitle(b)"
|
|
||||||
:disabled="busy"
|
|
||||||
@click="emit('demolish', b.id)"
|
|
||||||
>
|
|
||||||
{{ $t('village.buildings.demolish') }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,9 @@ function showInVillage(id: number) {
|
||||||
:can-afford="v.canAfford"
|
:can-afford="v.canAfford"
|
||||||
:busy="busy"
|
:busy="busy"
|
||||||
@build="v.build"
|
@build="v.build"
|
||||||
|
@upgrade="v.upgrade"
|
||||||
|
@demolish="v.demolish"
|
||||||
|
@select="showInVillage"
|
||||||
/>
|
/>
|
||||||
<div class="space-y-6">
|
<div class="space-y-6">
|
||||||
<VillageBuildQueue
|
<VillageBuildQueue
|
||||||
|
|
@ -109,16 +112,7 @@ function showInVillage(id: number) {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<VillageBuildingTable
|
<VillageBuildingTable :buildings="village.buildings" :busy="busy" @select="showInVillage" @priority="v.setPriority" />
|
||||||
:buildings="village.buildings"
|
|
||||||
:resources="resources"
|
|
||||||
:can-afford="v.canAfford"
|
|
||||||
:busy="busy"
|
|
||||||
@select="showInVillage"
|
|
||||||
@upgrade="v.upgrade"
|
|
||||||
@demolish="v.demolish"
|
|
||||||
@priority="v.setPriority"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="px-4 py-16 text-center">
|
<div v-else class="px-4 py-16 text-center">
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ export interface Building {
|
||||||
/** Next level after everything already queued; null at max level. */
|
/** Next level after everything already queued; null at max level. */
|
||||||
upgrade: Offer | null
|
upgrade: Offer | null
|
||||||
/** null when the building cannot go lower (core buildings at level 0). */
|
/** null when the building cannot go lower (core buildings at level 0). */
|
||||||
demolish: { refund: Cost; seconds: number } | null
|
demolish: { target_level: number; refund: Cost; seconds: number } | null
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Whether it is affordable is left to the client, which compares the cost to projected resources. */
|
/** Whether it is affordable is left to the client, which compares the cost to projected resources. */
|
||||||
|
|
|
||||||
|
|
@ -23,14 +23,12 @@ export default {
|
||||||
food_per_hour: '{value} food/h',
|
food_per_hour: '{value} food/h',
|
||||||
},
|
},
|
||||||
buildings: {
|
buildings: {
|
||||||
title: 'Buildings',
|
title: 'Workforce',
|
||||||
type: 'Building',
|
type: 'Building',
|
||||||
level: 'Level',
|
level: 'Level',
|
||||||
workers: 'Workers',
|
workers: 'Workers',
|
||||||
staffing: 'Staffing',
|
|
||||||
output: 'Output',
|
output: 'Output',
|
||||||
priority: 'Priority',
|
priority: 'Priority',
|
||||||
actions: 'Actions',
|
|
||||||
level_n: 'Level {level}',
|
level_n: 'Level {level}',
|
||||||
priority_down: 'Lower priority',
|
priority_down: 'Lower priority',
|
||||||
priority_up: 'Raise priority',
|
priority_up: 'Raise priority',
|
||||||
|
|
@ -48,13 +46,19 @@ export default {
|
||||||
space_value: '{used} / {max}',
|
space_value: '{used} / {max}',
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
title: 'Construct',
|
tab_construct: 'Construct',
|
||||||
|
tab_demolish: 'Demolition',
|
||||||
|
nth: '{name} {n}',
|
||||||
|
not_built: 'Not built yet',
|
||||||
|
level_button: 'Level {level}',
|
||||||
|
refund: 'Refund',
|
||||||
|
remove: 'Remove',
|
||||||
|
core: 'Stays',
|
||||||
building: 'Building',
|
building: 'Building',
|
||||||
cost: 'Cost',
|
cost: 'Cost',
|
||||||
space_col: 'Space',
|
space_col: 'Space',
|
||||||
time: 'Duration',
|
time: 'Duration',
|
||||||
construct: 'Build',
|
construct: 'Build',
|
||||||
built: '{count} built',
|
|
||||||
not_available: 'Not yet available',
|
not_available: 'Not yet available',
|
||||||
requires: 'Requires',
|
requires: 'Requires',
|
||||||
requirement: '{type} (level {level})',
|
requirement: '{type} (level {level})',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue