feat: Lazarett: the hospital stands in the village (tent, timber infirmary, stone infirmary), its page lists the wounded with when they stand again, its tag shows beds taken, the units box and recruit screen count the wounded, defence reports name who was carried in

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Fabian @ Blax Software 2026-10-30 13:54:57 +01:00
parent 8a83f8fe6d
commit eb799666cf
17 changed files with 242 additions and 5 deletions

View File

@ -76,6 +76,12 @@ defineProps<{ type: BuildingType }>()
<path d="M3 20V8h3v3h3V8h3v3h3V8h3v3h3V8v12z" />
<path d="M3 15.5h18M9 15.5V20M15 15.5V20M6 11v4.5M12 11v4.5M18 11v4.5" />
</g>
<g v-else-if="type === 'hospital'">
<path d="M3 19V7M3 15h18v4" />
<path d="M5 12h4v3H5z" />
<path d="M10 15v-3h8a3 3 0 0 1 3 3" />
<path d="M15 4v5M12.5 6.5h5" />
</g>
<g v-else-if="type === 'watchtower'">
<path d="M8 21l1.5-11h5L16 21" />
<path d="M6.5 10h11l-1.5-3h-8z" />

View File

@ -1,5 +1,5 @@
<script setup lang="ts">
import type { BattleReport, VillageRef } from '~/types/game'
import type { BattleReport, UnitType, VillageRef } from '~/types/game'
const props = defineProps<{ report: BattleReport; worldId: number }>()
const { t } = useI18n()
@ -12,6 +12,7 @@ const mapLink = (v: VillageRef) => ({ path: `/map/${props.worldId}`, query: { x:
const looted = computed(() => props.report.loot.wood + props.report.loot.clay + props.report.loot.iron)
/** Marker position on the luck bar, 0..100 from −25% to +25%. */
const luckAt = computed(() => Math.max(0, Math.min(100, ((props.report.luck + 25) / 50) * 100)))
const woundedBack = computed(() => (props.report.wounded ? formatArrival(Date.parse(props.report.wounded.heals_at), Date.now(), t) : ''))
</script>
<!-- A battle report laid out like Die Stämme's: who won, luck and morale, both sides' units, siege damage, haul. -->
@ -107,6 +108,14 @@ const luckAt = computed(() => Math.max(0, Math.min(100, ((props.report.luck + 25
<span class="text-ink-500 tabular-nums">{{ $t('reports.battle.haul_of', { loot: looted, capacity: report.capacity }) }}</span>
</div>
<div v-if="report.wounded" class="flex flex-wrap items-center gap-x-4 gap-y-1">
<span class="font-semibold">{{ $t('reports.battle.wounded') }}</span>
<span v-for="[unit, count] in unitRows(report.wounded.units)" :key="unit" class="inline-flex items-center gap-1 tabular-nums">
<IconUnit :unit="unit as UnitType" class="size-4 text-wood-800" />{{ count }}
</span>
<span class="text-ink-500">{{ $t('reports.battle.wounded_back', { when: woundedBack }) }}</span>
</div>
<div v-if="report.bounty" class="flex flex-wrap items-center gap-x-4 gap-y-1">
<span class="font-semibold">{{ $t('reports.battle.bounty') }}</span>
<span v-for="r in (['wood', 'clay', 'iron'] as const)" :key="r" class="inline-flex items-center gap-1 tabular-nums">

View File

@ -0,0 +1,44 @@
<script setup lang="ts">
import type { Hospital, UnitType } from '~/types/game'
defineProps<{ hospital: Hospital; secondsUntil: (iso: string) => number }>()
</script>
<!-- The Lazarett: beds taken against beds, the rule, and the wounded of each battle with when they stand again. -->
<template>
<section class="panel">
<div class="panel-head">
<span class="panel-title">{{ $t('village.hospital.title') }}</span>
<span class="badge badge-plain tabular-nums" :title="$t('village.hospital.beds')">
{{ $t('village.hospital.beds_of', { occupied: hospital.occupied, beds: hospital.beds }) }}
</span>
</div>
<div class="panel-body space-y-2 text-sm">
<p class="text-ink-700">
{{ $t('village.hospital.rule', { share: Math.round(hospital.share * 100), time: formatDuration(hospital.heal_seconds) }) }}
{{ $t('village.hospital.short') }}
</p>
<table v-if="hospital.wounded.length" class="grid-table">
<thead>
<tr>
<th>{{ $t('village.hospital.units') }}</th>
<th class="text-right">{{ $t('village.hospital.back_in') }}</th>
</tr>
</thead>
<tbody>
<tr v-for="w in hospital.wounded" :key="w.id">
<td>
<span class="flex flex-wrap items-center gap-x-3 gap-y-0.5">
<span v-for="[unit, count] in unitRows(w.units)" :key="unit" class="inline-flex items-center gap-1 tabular-nums" :title="$t(`units.${unit}`)">
<IconUnit :unit="unit as UnitType" class="size-4 text-wood-800" />{{ count }}
</span>
</span>
</td>
<td class="text-right font-semibold whitespace-nowrap tabular-nums">{{ formatDuration(secondsUntil(w.heals_at)) }}</td>
</tr>
</tbody>
</table>
<p v-else class="text-ink-500">{{ $t('village.hospital.none') }}</p>
</div>
</section>
</template>

View File

@ -12,6 +12,12 @@ const { t } = useI18n()
const production = computed(() => (['wood', 'clay', 'iron', 'food'] as const).map((r) => ({ r, rate: props.village.rates[r] })))
const troops = computed(() => (Object.entries(props.village.troops) as [UnitType, number][]).filter(([, n]) => n > 0))
/** The wounded in the hospital and when the first of them stand again. */
const wounded = computed(() => {
const list = props.village.hospital.wounded
if (!list.length) return null
return { count: props.village.hospital.occupied, next: list[0]!.heals_at }
})
const idle = computed(() => props.village.population.villagers - props.village.population.workers - props.village.levy.militia)
const spaceShare = computed(() => props.village.space.used / props.village.space.max)
const incoming = computed(() => props.village.movements.filter((m) => m.direction === 'in' && m.type === 'attack'))
@ -113,6 +119,7 @@ function order(o: BuildOrder) {
</ul>
<p v-else class="text-ink-500">{{ $t('village.troops.none') }}</p>
<p v-if="village.population.training" class="text-xs text-ink-500">{{ $t('village.troops.training', { count: village.population.training }) }}</p>
<p v-if="wounded" class="text-xs text-ink-500">{{ $t('village.troops.wounded_back', { count: wounded.count, time: formatDuration(secondsUntil(wounded.next)) }) }}</p>
<p v-if="commands" class="text-xs text-ink-500">{{ $t('village.side.commands') }}: {{ commands }}</p>
<div class="side-actions">
<NuxtLink :to="`${base}/recruit`" class="btn btn-outline">{{ $t('village.side.recruit') }}</NuxtLink>

View File

@ -1,10 +1,11 @@
<script setup lang="ts">
import type { Levy, UnitType } from '~/types/game'
import type { Hospital, Levy, UnitType } from '~/types/game'
const props = defineProps<{
troops: Partial<Record<UnitType, number>>
training: number
levy: Levy
hospital: Hospital
/** Villagers a new levy can draft. */
villagers: number
secondsUntil: (iso: string) => number
@ -35,7 +36,7 @@ function submitLevy() {
</span>
</div>
<div class="panel-body">
<ul v-if="home.length || levy.militia" class="divide-y divide-parchment-300">
<ul v-if="home.length || levy.militia || hospital.occupied" class="divide-y divide-parchment-300">
<li v-for="[unit, count] in home" :key="unit" class="flex items-center gap-2 py-1 text-sm">
<IconUnit :unit="unit" class="size-5 text-wood-800" />
<span class="flex-1">{{ $t(`units.${unit}`) }}</span>
@ -46,6 +47,14 @@ function submitLevy() {
<span class="flex-1">{{ $t('village.levy.militia') }}</span>
<span class="font-semibold tabular-nums">{{ levy.militia }}</span>
</li>
<li v-if="hospital.occupied" class="flex items-center gap-2 py-1 text-sm">
<IconBuilding type="hospital" class="size-5 text-wood-800" />
<span class="flex-1">
{{ $t('village.troops.wounded') }}
<span class="text-xs text-ink-500 tabular-nums">({{ formatDuration(secondsUntil(hospital.wounded[0]!.heals_at)) }})</span>
</span>
<span class="font-semibold tabular-nums">{{ hospital.occupied }}</span>
</li>
</ul>
<p v-else class="py-2 text-center text-sm text-ink-500">{{ $t('village.troops.none') }}</p>

View File

@ -645,6 +645,42 @@ function barn(cx: number, cy: number, w: number, d: number, h: number, rise: num
return faces
}
/** A cot along x: a low frame on four legs, a straw mattress, a rumpled blanket and a bolster. */
function cot(x: number, y: number, s: number, blanket = C.canvasDark): Face[] {
return [
...[-1, 1].flatMap((fx) => [-1, 1].flatMap((fy) => post(x + fx * s * 0.21, y + fy * s * 0.08, s * 0.1, s * 0.015))),
...box(x, y, s * 0.5, s * 0.2, s * 0.1, s * 0.035, C.wood),
...box(x + s * 0.05, y, s * 0.38, s * 0.19, s * 0.135, s * 0.04, blanket),
...box(x - s * 0.19, y, s * 0.09, s * 0.15, s * 0.135, s * 0.035, C.canvas),
]
}
/** Bandages drying on a line between two posts along y, some still stained. */
function bandages(x: number, y: number, s: number): Face[] {
const h = s * 0.55
const a = s * 0.32
const strip = (u: number, color: string, len = 0.22): Face => plane([[x, y + u - s * 0.04, h], [x, y + u + s * 0.04, h], [x, y + u + s * 0.04, h - s * len], [x, y + u - s * 0.04, h - s * len]], color)
return [
...post(x, y - a, h + s * 0.04, s * 0.022),
...post(x, y + a, h + s * 0.04, s * 0.022),
...beam([x, y - a], [x, y + a], h, s * 0.012, s * 0.012, C.dark),
strip(-a * 0.6, C.canvas),
strip(-a * 0.15, C.blood, 0.18),
strip(a * 0.3, C.canvas, 0.26),
strip(a * 0.7, C.canvasDark, 0.16),
]
}
/** A lean-to roof on two posts against a wall facing +y: from z0 at the wall (y0) down to z1 at y1. */
function leanTo(x0: number, x1: number, y0: number, y1: number, z0: number, z1: number, s: number, color: string): Face[] {
return [...post(x0, y1, z1, s * 0.03), ...post(x1, y1, z1, s * 0.03), plane([[x0, y0, z0], [x1, y0, z0], [x1, y1, z1], [x0, y1, z1]], color)]
}
/** A bed of herbs in rows, for salves and teas. */
function herbs(x: number, y: number, w: number, d: number): Face[] {
return field(x, y, w, d, C.leaf, 4)
}
/** The village banner on a tall pole, flying from its top. */
function flag(x: number, y: number, h: number, size: number): Face[] {
return [...post(x, y, h, size * 0.03), plane([[x, y, h], [x - size * 0.1, y + size * 0.85, h - size * 0.08], [x, y, h - size * 0.4]], C.banner)]
@ -1153,6 +1189,60 @@ const models: Record<BuildingType, (s: number, t: number) => Model> = {
}
},
// The Lazarett, where the wounded lie: a field tent with cots in the open first, then a
// timber infirmary with cots under a lean-to and a herb bed, then a stone one with a
// bell gable and a fenced herb garden. Bandages dry on a line, some still stained.
hospital(s, t) {
if (t === 1) {
return {
faces: [
...tent(-s * 0.2, -s * 0.25, s * 1.25, s * 0.75, s * 0.62, 'x', C.canvas, true),
...cot(-s * 0.45, s * 0.55, s),
...cot(s * 0.15, s * 0.6, s, C.cloth),
...bandages(s * 0.8, -s * 0.15, s),
...barrel(s * 0.72, s * 0.62, s),
...fire(s * 0.6, -s * 0.72, s),
...blood(s * 0.42, s * 0.25, s * 0.1, 31),
],
height: s * 0.8,
}
}
if (t === 2) {
return {
faces: [
...house(-s * 0.15, -s * 0.3, s * 1.45, s * 0.8, s * 0.5, s * 0.45, C.wood, C.thatch, 'x'),
...leanTo(-s * 0.8, s * 0.45, s * 0.1, s * 0.45, s * 0.42, s * 0.3, s, C.thatch),
...cot(-s * 0.5, s * 0.7, s),
...cot(s * 0.1, s * 0.72, s, C.cloth),
...bandages(s * 0.85, -s * 0.2, s),
...herbs(s * 0.65, s * 0.62, s * 0.4, s * 0.32),
...barrel(s * 0.85, -s * 0.72, s),
...blood(s * 0.5, s * 0.25, s * 0.1, 32),
],
height: s * 1.1,
}
}
const bell: Face[] = [
...box(-s * 0.55, -s * 0.25, s * 0.2, s * 0.2, s * 0.95, s * 0.35, C.stone),
...pyramid(rect(-s * 0.55, -s * 0.25, s * 0.28, s * 0.28), s * 1.3, s * 0.25, C.slate),
]
return {
faces: [
...house(-s * 0.15, -s * 0.25, s * 1.6, s * 0.95, s * 0.65, s * 0.5, C.stone, C.slate, 'x'),
...bell,
...leanTo(-s * 0.85, s * 0.55, s * 0.24, s * 0.55, s * 0.55, s * 0.4, s, C.shingle),
...cot(-s * 0.6, s * 0.78, s),
...cot(-s * 0.05, s * 0.8, s, C.cloth),
...bandages(s * 0.9, -s * 0.3, s),
...herbs(s * 0.68, s * 0.65, s * 0.45, s * 0.38),
...fence([[s * 0.43, s * 0.88], [s * 0.93, s * 0.88], [s * 0.93, s * 0.42]], s * 0.2, s * 0.02),
...barrel(s * 0.95, -s * 0.8, s),
...barrel(s * 0.78, -s * 0.85, s),
],
height: s * 1.55,
}
},
// The academy (Adelshof): a stone manor with towers.
academy(s, t) {
const tower = (x: number, y: number, h: number): Face[] => [

View File

@ -41,6 +41,7 @@ export const CATALOG: Record<BuildingType, CatalogEntry> = {
barracks: { space: 6, max_per_village: null, cost: { wood: 200, clay: 170, iron: 90 }, seconds: 30, workers: 3, production: null },
stable: { space: 6, max_per_village: null, cost: { wood: 270, clay: 240, iron: 260 }, seconds: 40, workers: 3, production: null },
workshop: { space: 6, max_per_village: null, cost: { wood: 300, clay: 240, iron: 260 }, seconds: 50, workers: 4, production: null },
hospital: { space: 4, max_per_village: null, cost: { wood: 160, clay: 200, iron: 120 }, seconds: 30, workers: 2, production: null },
academy: { space: 9, max_per_village: 1, cost: { wood: 1500, clay: 2500, iron: 1000 }, seconds: 60, workers: 5, production: null },
}

View File

@ -87,6 +87,13 @@ interface MockOrder {
finishes_at: number | null
}
/** The wounded of one battle; the mock's battles wound nobody, so only seeded state has them. */
interface MockWounded {
id: number
units: Partial<Record<UnitType, number>>
heals_at: number
}
interface MockVillage {
id: number
world_id: number
@ -102,6 +109,7 @@ interface MockVillage {
orders: MockOrder[]
/** Missing in states stored before recruiting existed. */
troops?: Partial<Record<UnitType, number>>
wounded?: MockWounded[]
recruits?: MockRecruit[]
militia?: number
levy_until?: number | null
@ -612,6 +620,7 @@ function view(state: MockState, v: MockVillage, now: number): VillageState {
levy: { militia: militia(v), until: v.levy_until ? iso(v.levy_until) : null, seconds: LEVY_SECONDS },
starvation: starvation(v),
troops: Object.fromEntries(Object.entries(v.troops ?? {}).filter(([, n]) => n)),
hospital: hospital(v),
military: military(v, now),
movements: movements(state, v, now),
support: support(state, v),
@ -791,6 +800,18 @@ function villageAt(state: MockState, worldId: number, x: number, y: number): Vil
const field = (n: unknown) => Math.trunc(Number(n) || 0)
const fieldDistance = (a: { x: number; y: number }, b: { x: number; y: number }) => Math.hypot(a.x - b.x, a.y - b.y)
const travelMode = (mode: unknown) => TRAVEL_MODES.find((m) => m.mode === mode)
/** Beds as the backend's level 1 times the level, per hospital; wounded still lying there. */
function hospital(v: MockVillage) {
const wounded = (v.wounded ?? []).filter((w) => w.heals_at > Date.now())
return {
beds: v.buildings.filter((b) => b.type === 'hospital').reduce((n, b) => n + 20 * b.level, 0),
occupied: wounded.reduce((n, w) => n + Object.values(w.units).reduce((a, c) => a + (c ?? 0), 0), 0),
share: 0.5,
heal_seconds: 14400,
wounded: wounded.map((w) => ({ id: w.id, units: w.units, heals_at: iso(w.heals_at) })),
}
}
const hasRallyPoint = (v: MockVillage) => v.buildings.some((b) => b.type === 'rally_point')
/** The slowest unit sets the pace. */

View File

@ -27,6 +27,8 @@ watch(building, (b) => {
@priority="v.setPriority"
/>
</template>
<!-- The wounded lie in all hospitals together. -->
<VillageHospitalPanel v-if="building.type === 'hospital'" :hospital="village.hospital" :seconds-until="v.secondsUntil" />
<!-- Every building of this type, and one more: the headquarters list for just this type. -->
<VillageBuildForm
:options="village.buildable.filter((o) => o.type === building!.type)"

View File

@ -61,6 +61,7 @@ const { t } = useI18n()
:troops="village.troops"
:training="village.population.training"
:levy="village.levy"
:hospital="village.hospital"
:villagers="village.population.villagers"
:seconds-until="v.secondsUntil"
:busy="v.busy.value"

View File

@ -20,6 +20,7 @@ export type BuildingType =
| 'stable'
| 'workshop'
| 'academy'
| 'hospital'
export type UnitType =
| 'spear'
@ -145,6 +146,19 @@ export interface Specialisation {
roles: { role: VillageRole; buildings: BuildingType[]; bonuses: Partial<Record<'production' | 'recruit_speed' | 'defense', number>> }[]
}
/**
* The Lazarett: beds as far as the hospitals are staffed (0 without one), beds taken, the
* share of the own fallen that comes back, and the wounded of each battle. The wounded eat
* like soldiers and stand at home again at `heals_at`.
*/
export interface Hospital {
beds: number
occupied: number
share: number
heal_seconds: number
wounded: { id: number; units: Units; heals_at: string }[]
}
export interface VillageState {
id: number
world_id: number
@ -173,6 +187,7 @@ export interface VillageState {
starvation: Starvation
/** Own units standing in the village. */
troops: Partial<Record<UnitType, number>>
hospital: Hospital
/** One entry per building that trains units, in building order. */
military: MilitaryBuilding[]
/** Own groups leaving from or coming home to this village, and spotted groups coming here; by arrival. */
@ -291,6 +306,8 @@ export interface BattleReport {
/** Raiders from a barbarian camp attacked; a beaten band leaves a bounty in the village. */
raid?: boolean
bounty?: Cost | null
/** Defence reports only: the own fallen taken into the hospital, and when they stand again. */
wounded?: { units: Units; heals_at: string } | null
/** Only when scouts went along. Resources and buildings only when some got through. */
scouting?: {
sent: number
@ -529,7 +546,7 @@ export interface Building {
/** One line of what a building does: production at full staffing (per hour), percentages as whole numbers. */
export interface BuildingEffect {
key: 'production' | 'capacity' | 'hides' | 'detection' | 'wall_defense' | 'wall_bonus' | 'build_speed' | 'builders' | 'space' | 'recruit_speed'
key: 'production' | 'capacity' | 'hides' | 'beds' | 'detection' | 'wall_defense' | 'wall_bonus' | 'build_speed' | 'builders' | 'space' | 'recruit_speed'
value: number
resource?: Resource
}

View File

@ -141,6 +141,16 @@ export function buildingTag(
case 'hiding_place':
return { icon: { kind: 'ui', name: 'eye' }, text: String(effect('hides')), tone: 'plain', title: t('village.tags.hides', { amount: effect('hides') }) }
case 'hospital': {
const { beds, occupied } = village.hospital
return {
icon: { kind: 'ui', name: 'users' },
text: t('village.tags.beds', { occupied, beds }),
tone: beds > 0 && occupied >= beds ? 'warn' : 'plain',
title: t('village.tags.beds_title', { occupied, beds }),
}
}
case 'watchtower':
return { icon: { kind: 'ui', name: 'eye' }, text: t('village.tags.fields', { fields: effect('detection') }), tone: 'plain', title: t('village.tags.detection', { fields: effect('detection') }) }

View File

@ -11,7 +11,7 @@ const SPACE: Partial<Record<BuildingType, number>> = {
export function demoVillage(): VillageState {
const levels: [BuildingType, number][] = [
['headquarters', 14], ['storage', 11], ['storage', 7], ['farm', 10], ['farm', 6], ['timber_camp', 9], ['timber_camp', 7],
['clay_pit', 8], ['clay_pit', 6], ['iron_mine', 8], ['hiding_place', 3], ['wall', 9], ['rally_point', 1], ['barracks', 7], ['stable', 4], ['workshop', 2],
['clay_pit', 8], ['clay_pit', 6], ['iron_mine', 8], ['hiding_place', 3], ['wall', 9], ['rally_point', 1], ['barracks', 7], ['stable', 4], ['workshop', 2], ['hospital', 6],
]
const buildings = levels.map(([type, level], i): Building => ({
id: i + 1, type, level, space: SPACE[type] ?? 4, priority: 5,

View File

@ -16,6 +16,7 @@ export const BUILDING_COLORS: Record<BuildingType, { fill: string; line: string
stable: { fill: '#d8c49a', line: '#5a3d24' },
workshop: { fill: '#cbbfa8', line: '#3e2b1a' },
academy: { fill: '#e6d29a', line: '#6e5a1f' },
hospital: { fill: '#dcd3c0', line: '#5a221b' },
}
export const buildingTileStyle = (type: BuildingType) => ({

View File

@ -51,6 +51,7 @@ export default {
stable: 'Stable',
workshop: 'Workshop',
academy: 'Academy',
hospital: 'Hospital',
},
units: {
spear: 'Spear fighter',

View File

@ -53,6 +53,8 @@ export default {
haul_of: '{loot} of {capacity}',
loyalty: 'Loyalty dropped from {before} to {after}.',
conquered: 'The village has been conquered.',
wounded: 'Carried into the hospital',
wounded_back: 'they stand again {when}',
},
support: {
arrived: 'The support has arrived and now defends {to}.',

View File

@ -42,12 +42,14 @@ export default {
stable: "Trains scouts and cavalry. A higher level trains faster.",
workshop: "Builds rams and catapults. A higher level builds faster.",
academy: "Trains noblemen and mints the coins that pay for them.",
hospital: "Half of your own soldiers who fall defending the village are carried in here wounded, as far as there are beds, and stand again after a few hours. They eat meanwhile.",
},
effects: {
now: "Now",
production: "Production at full staffing",
capacity: "Storage per resource",
hides: "Hidden per resource",
beds: "Beds at full staffing",
detection: "Spots groups further out",
fields: "{n} fields",
wall_defense: "Defence for every defender",
@ -80,6 +82,8 @@ export default {
hides: 'Hides {amount} of each resource from raiders',
fields: '{fields} fields',
detection: 'Spots incoming troops {fields} fields further out',
beds: '{occupied}/{beds}',
beds_title: '{occupied} of {beds} beds taken by the wounded',
},
lost: "{by} took {name} ({x}{'|'}{y}). The report tells how.",
lost_unknown: "{name} ({x}{'|'}{y}) is no longer yours.",
@ -195,6 +199,18 @@ export default {
none: 'No troops in the village.',
recruit: 'Recruit',
hint: 'Build barracks to recruit units.',
wounded: 'Wounded',
wounded_back: '{count} wounded stand again in {time}',
},
hospital: {
title: 'Wounded',
beds: 'Beds taken',
beds_of: '{occupied} of {beds}',
rule: '{share}% of your own soldiers who fall defending this village are carried in, as far as beds are free. They stand again {time} after the battle and eat meanwhile.',
short: 'Understaffed hospitals have fewer beds.',
none: 'Nobody lies wounded.',
units: 'Wounded',
back_in: 'Stand again in',
},
food: {
runs_out_in: 'Your village eats more than it harvests. Food runs out in',