fix: market forms accept any whole amount (no step validation), the target placeholder shows x|y, names keep their gap, offers stack Accept under the count on phones, intervals read "1 d", a refused offer list stops loading, the merchant count turns red when none are free

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Fabian @ Blax Software 2026-10-31 11:15:54 +01:00
parent 8ae8e75163
commit 7384566f7f
10 changed files with 16 additions and 14 deletions

View File

@ -37,7 +37,7 @@ function most(r: TradeResource) {
v-model.number="amounts[r]"
type="number"
min="0"
step="100"
inputmode="numeric"
class="input w-20 px-1.5 py-0.5 text-right tabular-nums"
:aria-label="$t('market.amount_of', { resource: $t(`resources.${r}`) })"

View File

@ -24,7 +24,7 @@ const outside = computed(() => every.value < props.min || every.value > props.ma
<label :for="`${id}-h`" class="label mb-0 w-24">{{ $t('market.routes.every') }}</label>
<input :id="`${id}-h`" v-model.number="hours" type="number" min="0" inputmode="numeric" class="input w-14 px-1.5 py-0.5 text-right tabular-nums" :aria-label="$t('market.routes.hours')" />
<span>{{ $t('market.routes.h') }}</span>
<input v-model.number="minutes" type="number" min="0" max="59" step="5" inputmode="numeric" class="input w-14 px-1.5 py-0.5 text-right tabular-nums" :aria-label="$t('market.routes.minutes')" />
<input v-model.number="minutes" type="number" min="0" max="59" inputmode="numeric" class="input w-14 px-1.5 py-0.5 text-right tabular-nums" :aria-label="$t('market.routes.minutes')" />
<span>{{ $t('market.routes.min') }}</span>
</div>
<p class="text-xs" :class="outside ? 'text-blood-700' : 'text-ink-500'">

View File

@ -57,13 +57,13 @@ async function submit() {
<select id="offer-give" v-model="give" class="input w-auto py-0.5">
<option v-for="r in market.resources" :key="r" :value="r">{{ $t(`resources.${r}`) }}</option>
</select>
<input v-model.number="giveAmount" type="number" min="1" step="100" inputmode="numeric" class="input w-24 px-1.5 py-0.5 text-right tabular-nums" :aria-label="$t('market.mine.give_amount')" />
<input v-model.number="giveAmount" type="number" min="1" inputmode="numeric" class="input w-24 px-1.5 py-0.5 text-right tabular-nums" :aria-label="$t('market.mine.give_amount')" />
<label for="offer-want" class="font-semibold text-ink-700">{{ $t('market.mine.want') }}</label>
<select id="offer-want" v-model="want" class="input w-auto py-0.5">
<option v-for="r in market.resources" :key="r" :value="r">{{ $t(`resources.${r}`) }}</option>
</select>
<input v-model.number="wantAmount" type="number" min="1" step="100" inputmode="numeric" class="input w-24 px-1.5 py-0.5 text-right tabular-nums" :aria-label="$t('market.mine.want_amount')" />
<input v-model.number="wantAmount" type="number" min="1" inputmode="numeric" class="input w-24 px-1.5 py-0.5 text-right tabular-nums" :aria-label="$t('market.mine.want_amount')" />
<label for="offer-count" class="font-semibold text-ink-700">{{ $t('market.mine.count') }}</label>
<input id="offer-count" v-model.number="count" type="number" min="1" inputmode="numeric" class="input w-16 px-1.5 py-0.5 text-right tabular-nums" />
@ -78,7 +78,8 @@ async function submit() {
<IconUi name="cart" class="mr-1 inline size-4 align-[-3px]" />{{ $t('market.merchants_needed', { needed: merchants, merchants: market.free }) }}
</li>
<li :class="reserved > Math.floor(stock[give]) ? 'text-blood-700' : ''">
{{ $t('market.mine.reserved', { amount: reserved, resource: $t(`resources.${give}`) }) }}
{{ $t('market.mine.reserved') }}
<span class="inline-flex items-center gap-0.5 font-semibold tabular-nums"><IconResource :resource="give" class="size-4" />{{ reserved }}</span>
</li>
</ul>
<p v-if="problem && n(giveAmount) && n(wantAmount)" class="text-blood-700">{{ problem }}</p>

View File

@ -81,7 +81,7 @@ const mapLink = (r: TradeRoute) => ({ path: `/map/${props.worldId}`, query: { x:
<tr :class="r.paused ? 'bg-parchment-100 text-ink-500' : ''">
<td class="py-1">
<NuxtLink :to="mapLink(r)" class="font-semibold text-ink-900 hover:underline">{{ villageLabel(r.to) }}</NuxtLink>
<span class="text-xs text-ink-500"> {{ r.to.player?.name }}</span>
<span class="ml-1 text-xs text-ink-500">{{ r.to.player?.name }}</span>
<span class="mt-0.5 flex flex-wrap items-center gap-x-2 text-xs text-ink-700">
<MarketCargo :cargo="r.resources" />
<span class="inline-flex items-center gap-0.5 whitespace-nowrap"><IconUi name="repeat" class="size-3.5" />{{ $t('market.routes.every_n', { every: formatInterval(r.every, t) }) }}</span>

View File

@ -47,7 +47,7 @@ const other = (x: Trade): VillageRef => (x.kind === 'out' ? x.to : x.from)
<IconUi :name="x.kind === 'back' ? 'return' : 'cart'" class="mt-0.5 size-4 shrink-0" />
<div class="min-w-0">
<NuxtLink :to="{ path: `/map/${worldId}`, query: { x: other(x).x, y: other(x).y } }" class="font-semibold hover:underline">{{ title(x) }}</NuxtLink>
<span v-if="x.kind === 'in' && x.from.player" class="text-ink-500"> {{ $t('market.trades.by', { player: x.from.player.name }) }}</span>
<span v-if="x.kind === 'in' && x.from.player" class="ml-1 text-ink-500">{{ $t('market.trades.by', { player: x.from.player.name }) }}</span>
<div class="mt-0.5 flex flex-wrap items-center gap-x-2.5 gap-y-0.5 text-xs text-ink-700">
<MarketCargo v-if="x.cargo" :cargo="x.cargo" />
<span v-if="x.kind !== 'in'" class="inline-flex items-center gap-0.5 whitespace-nowrap tabular-nums">

View File

@ -24,7 +24,7 @@ async function load() {
const filters = [give.value, want.value]
const result = await props.offers(give.value, want.value)
// Drop answers for filters that changed meanwhile.
if (filters[0] === give.value && filters[1] === want.value) list.value = result
if (filters[0] === give.value && filters[1] === want.value) list.value = result ?? { server_time: '', offers: [] }
loading.value = false
}
watch([give, want], load, { immediate: true })
@ -110,7 +110,7 @@ const mapLink = (o: WorldOffer) => ({ path: `/map/${props.worldId}`, query: { x:
</td>
<td class="text-right">
<span v-if="o.own" class="badge badge-plain">{{ $t('market.offers.own') }}</span>
<span v-else class="inline-flex items-center justify-end gap-1">
<span v-else class="inline-flex flex-col items-end gap-0.5 @md:flex-row @md:items-center @md:gap-1">
<input
v-model.number="counts[o.id]"
type="number"

View File

@ -15,7 +15,7 @@ const mapLink = (v: VillageRef) => ({ path: `/map/${props.worldId}`, query: { x:
<th class="w-28">{{ $t(`reports.trade.${side}`) }}</th>
<td>
<NuxtLink :to="mapLink(report[side])" class="font-semibold hover:underline">{{ villageLabel(report[side]) }}</NuxtLink>
<span class="text-ink-500"> {{ report[side].player?.name ?? $t('common.barbarian') }}</span>
<span class="ml-1 text-ink-500">{{ report[side].player?.name ?? $t('common.barbarian') }}</span>
</td>
</tr>
<tr>

View File

@ -37,7 +37,7 @@ const initialTarget = computed(() => (route.query.x && route.query.y ? { x: Numb
<div class="space-y-3">
<div class="flex flex-wrap items-center justify-between gap-2">
<UiSubTabs v-model="tab" :tabs="tabs" />
<span v-if="state?.market" class="inline-flex items-center gap-1 text-sm whitespace-nowrap text-ink-700 tabular-nums" :title="$t('market.merchants_title', { carry: state.market.carry })">
<span v-if="state?.market" class="inline-flex items-center gap-1 text-sm whitespace-nowrap tabular-nums" :class="state.market.free ? 'text-ink-700' : 'font-semibold text-blood-700'" :title="$t('market.merchants_title', { carry: state.market.carry })">
<IconUi name="cart" class="size-4" />
{{ $t('market.merchants_free', { free: state.market.free, merchants: state.market.merchants }) }}
</span>

View File

@ -8,7 +8,7 @@ export function formatInterval(seconds: number, t: Translate) {
const days = Math.floor(m / 1440)
const hours = Math.floor((m % 1440) / 60)
const minutes = m % 60
if (days) return t('market.interval.dh', { d: days, h: hours })
if (days) return hours ? t('market.interval.dh', { d: days, h: hours }) : t('market.interval.d', { d: days })
if (hours && minutes) return t('market.interval.hm', { h: hours, m: minutes })
if (hours) return t('market.interval.h', { h: hours })
return t('market.interval.m', { m: minutes })

View File

@ -36,7 +36,7 @@ export default {
merchants_needed: 'Merchants needed: {needed} of {merchants} free',
merchants_per_run: 'Merchants per run: {needed} of {merchants}',
target: 'Target',
target_placeholder: 'x|y',
target_placeholder: "x{'|'}y",
village: 'Village',
distance: 'Distance',
fields: '{fields} fields',
@ -77,7 +77,7 @@ export default {
count: 'Times',
count_hint: 'one trade each',
ratio: 'You ask {ratio} for each 1 you give; at most {max} times as much either way.',
reserved: 'Held back while the offer is open: {amount} {resource}',
reserved: 'Held back while the offer is open:',
submit: 'Post offer',
open: 'Open offers',
merchants: 'Merchants',
@ -115,6 +115,7 @@ export default {
submit: 'Create route',
},
interval: {
d: '{d} d',
dh: '{d} d {h} h',
hm: '{h} h {m} min',
h: '{h} h',