feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import type { SimulatedBattle, Units } from '~/types/game'
|
|
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
|
worldId: number
|
|
|
|
|
/** Own units at home, for "own troops". */
|
|
|
|
|
troops: Units
|
|
|
|
|
}>()
|
|
|
|
|
const errorText = useErrorText()
|
|
|
|
|
|
|
|
|
|
// The Die Stämme simulator: both sides' units, the wall and the modifiers, and the
|
|
|
|
|
// server runs the world's real battle rules on them. Nothing in the game changes.
|
|
|
|
|
const attack = reactive<Record<string, number | undefined>>({})
|
|
|
|
|
const defense = reactive<Record<string, number | undefined>>({})
|
|
|
|
|
const wall = ref(0)
|
|
|
|
|
const morale = ref(100)
|
|
|
|
|
const luck = ref(0)
|
|
|
|
|
const night = ref(false)
|
|
|
|
|
const building = ref(0)
|
|
|
|
|
const result = ref<SimulatedBattle | null>(null)
|
|
|
|
|
const error = ref<string | null>(null)
|
|
|
|
|
const busy = ref(false)
|
|
|
|
|
|
|
|
|
|
const DEFENDERS = [...UNIT_ORDER, 'militia'] as const
|
|
|
|
|
const counts = (units: Record<string, number | undefined>) =>
|
|
|
|
|
Object.fromEntries(Object.entries(units).filter(([, n]) => Number(n) > 0).map(([u, n]) => [u, Math.floor(Number(n))]))
|
|
|
|
|
|
|
|
|
|
function ownTroops() {
|
|
|
|
|
for (const unit of UNIT_ORDER) attack[unit] = props.troops[unit] || undefined
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function run() {
|
|
|
|
|
busy.value = true
|
|
|
|
|
error.value = null
|
|
|
|
|
try {
|
|
|
|
|
result.value = await ws.send<SimulatedBattle>('rally.simulate', {
|
|
|
|
|
world_id: props.worldId,
|
|
|
|
|
attack: counts(attack),
|
|
|
|
|
defense: counts(defense),
|
|
|
|
|
wall: wall.value,
|
|
|
|
|
morale: morale.value,
|
|
|
|
|
luck: luck.value,
|
|
|
|
|
night: night.value,
|
|
|
|
|
building: building.value,
|
|
|
|
|
})
|
|
|
|
|
} catch (e) {
|
|
|
|
|
error.value = errorText(e)
|
|
|
|
|
} finally {
|
|
|
|
|
busy.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<details class="panel group">
|
|
|
|
|
<summary class="panel-head cursor-pointer list-none">
|
|
|
|
|
<h2 class="panel-title">{{ $t('village.simulator.title') }}</h2>
|
|
|
|
|
<IconUi name="plus" class="size-4 text-ink-500 group-open:hidden" />
|
|
|
|
|
<IconUi name="minus" class="hidden size-4 text-ink-500 group-open:block" />
|
|
|
|
|
</summary>
|
fix: responsive building pages: the send form and simulator size by their column, the build queue sits with the headquarters on the right, action buttons never wrap or clip, the menu shows icons only below 1024 px
Checked every world page at 1920, 1465, 1280, 1024, 900, 768, 600 and 390 px for clipped, spilling and page-wide overflow.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 12:52:30 +00:00
|
|
|
<form class="@container panel-body space-y-4" @submit.prevent="run">
|
|
|
|
|
<div class="grid gap-x-6 gap-y-2 @md:grid-cols-[auto_6rem_6rem]">
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
<span />
|
|
|
|
|
<span class="text-xs font-semibold text-ink-500 uppercase">{{ $t('reports.battle.attacker') }}</span>
|
|
|
|
|
<span class="text-xs font-semibold text-ink-500 uppercase">{{ $t('reports.battle.defender') }}</span>
|
|
|
|
|
<template v-for="unit in DEFENDERS" :key="unit">
|
|
|
|
|
<span class="flex items-center gap-2 text-sm">
|
|
|
|
|
<IconUnit :unit="unit" class="size-5 text-wood-800" />
|
|
|
|
|
{{ $t(`units.${unit}`) }}
|
|
|
|
|
</span>
|
|
|
|
|
<input
|
|
|
|
|
v-if="unit !== 'militia'"
|
|
|
|
|
v-model.number="attack[unit]"
|
|
|
|
|
type="number"
|
|
|
|
|
min="0"
|
|
|
|
|
inputmode="numeric"
|
|
|
|
|
class="input px-1.5 py-0.5 text-right tabular-nums"
|
|
|
|
|
:aria-label="`${$t('reports.battle.attacker')}: ${$t(`units.${unit}`)}`"
|
|
|
|
|
/>
|
|
|
|
|
<span v-else />
|
|
|
|
|
<input
|
|
|
|
|
v-model.number="defense[unit]"
|
|
|
|
|
type="number"
|
|
|
|
|
min="0"
|
|
|
|
|
inputmode="numeric"
|
|
|
|
|
class="input px-1.5 py-0.5 text-right tabular-nums"
|
|
|
|
|
:aria-label="`${$t('reports.battle.defender')}: ${$t(`units.${unit}`)}`"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
</div>
|
|
|
|
|
|
fix: responsive building pages: the send form and simulator size by their column, the build queue sits with the headquarters on the right, action buttons never wrap or clip, the menu shows icons only below 1024 px
Checked every world page at 1920, 1465, 1280, 1024, 900, 768, 600 and 390 px for clipped, spilling and page-wide overflow.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-30 12:52:30 +00:00
|
|
|
<div class="grid grid-cols-2 gap-3 border-t-2 border-parchment-300 pt-3 @xl:grid-cols-5">
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
<label class="text-sm">
|
|
|
|
|
<span class="label">{{ $t('buildings.wall') }}</span>
|
|
|
|
|
<input v-model.number="wall" type="number" min="0" max="20" class="input px-1.5 py-0.5 tabular-nums" />
|
|
|
|
|
</label>
|
|
|
|
|
<label class="text-sm">
|
|
|
|
|
<span class="label">{{ $t('reports.battle.morale') }} %</span>
|
|
|
|
|
<input v-model.number="morale" type="number" min="30" max="100" class="input px-1.5 py-0.5 tabular-nums" />
|
|
|
|
|
</label>
|
|
|
|
|
<label class="text-sm">
|
|
|
|
|
<span class="label">{{ $t('village.simulator.luck') }} %</span>
|
|
|
|
|
<input v-model.number="luck" type="number" min="-25" max="25" class="input px-1.5 py-0.5 tabular-nums" />
|
|
|
|
|
</label>
|
|
|
|
|
<label class="text-sm">
|
|
|
|
|
<span class="label">{{ $t('village.simulator.building') }}</span>
|
|
|
|
|
<input v-model.number="building" type="number" min="0" max="30" class="input px-1.5 py-0.5 tabular-nums" />
|
|
|
|
|
</label>
|
|
|
|
|
<label class="flex items-center gap-2 self-end pb-1 text-sm">
|
|
|
|
|
<input v-model="night" type="checkbox" />
|
|
|
|
|
{{ $t('village.simulator.night') }}
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="flex flex-wrap gap-2">
|
|
|
|
|
<button type="submit" class="btn btn-primary" :disabled="busy">{{ $t('village.simulator.run') }}</button>
|
|
|
|
|
<button type="button" class="btn btn-outline" @click="ownTroops">{{ $t('village.simulator.own_troops') }}</button>
|
|
|
|
|
</div>
|
|
|
|
|
<p v-if="error" class="alert" role="alert">{{ error }}</p>
|
|
|
|
|
|
|
|
|
|
<div v-if="result" class="space-y-3 border-t-2 border-parchment-300 pt-3 text-sm">
|
|
|
|
|
<p class="font-display text-lg font-semibold" :class="result.won ? 'text-moss-700' : 'text-blood-700'">
|
|
|
|
|
{{ result.won ? $t('reports.battle.attacker_won') : $t('reports.battle.defender_won') }}
|
|
|
|
|
</p>
|
|
|
|
|
<p class="text-ink-500 tabular-nums">{{ $t('village.simulator.power', result.power) }}</p>
|
|
|
|
|
<div v-for="side in (['attacker', 'defender'] as const)" :key="side">
|
|
|
|
|
<p class="mb-1 font-semibold">{{ $t(`reports.battle.${side}`) }}</p>
|
2026-10-31 09:57:07 +00:00
|
|
|
<ReportUnits v-if="unitRows(result[side].units).length" :units="result[side].units" :lost="result[side].lost" :shot="result.volley?.[side]" />
|
feat: rally point, troop movements, support, reports, scouts, battle simulator and village rename
Send attacks and support from the rally point with a live travel-time preview, see own
commands and spotted incoming attacks with countdowns and call-back, send support home
or withdraw it, read battle and support reports with an unread badge, run the battle
simulator, rename villages, and send troops straight from the map. The watchtower gets
a diorama model; the mock server answers every new intent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 23:16:06 +00:00
|
|
|
<p v-else class="text-ink-500">{{ $t('reports.battle.no_troops') }}</p>
|
|
|
|
|
</div>
|
|
|
|
|
<p v-if="result.wall && result.wall.after < result.wall.before">{{ $t('reports.battle.wall', result.wall) }}</p>
|
|
|
|
|
<p v-if="result.building">{{ $t('village.simulator.building_after', result.building) }}</p>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</details>
|
|
|
|
|
</template>
|