chore: mock building space grows with the headquarters, like the backend

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Fabian @ Blax Software 2026-10-28 22:17:33 +01:00
parent a1f0dc445b
commit d2dc037849
2 changed files with 9 additions and 3 deletions

View File

@ -22,7 +22,9 @@ export const BASE_TRICKLE = 5
export const VILLAGER_UPKEEP = 1 export const VILLAGER_UPKEEP = 1
export const DEMOLISH_REFUND = 0.5 export const DEMOLISH_REFUND = 0.5
export const DEFAULT_PRIORITY = 5 export const DEFAULT_PRIORITY = 5
export const MAX_SPACE = 50 /** Building space at headquarters level 0, and what each level adds. */
export const MAX_SPACE = 40
export const SPACE_PER_HQ_LEVEL = 20
export const START_RESOURCES: Resources = { wood: 500, clay: 500, iron: 500, food: 100 } export const START_RESOURCES: Resources = { wood: 500, clay: 500, iron: 500, food: 100 }
export const CATALOG: Record<BuildingType, CatalogEntry> = { export const CATALOG: Record<BuildingType, CatalogEntry> = {

View File

@ -31,6 +31,7 @@ import {
DEFAULT_PRIORITY, DEFAULT_PRIORITY,
DEMOLISH_REFUND, DEMOLISH_REFUND,
MAX_SPACE, MAX_SPACE,
SPACE_PER_HQ_LEVEL,
MAX_LEVEL, MAX_LEVEL,
START_RESOURCES, START_RESOURCES,
UNITS, UNITS,
@ -66,6 +67,7 @@ interface MockVillage {
name: string name: string
x: number x: number
y: number y: number
/** Base building space; the headquarters level adds to it. */
space_max: number space_max: number
resources: Resources resources: Resources
resources_at: number resources_at: number
@ -251,7 +253,9 @@ function spaceUsed(v: MockVillage) {
) )
} }
const spaceFits = (v: MockVillage, type: BuildingType) => spaceUsed(v) + CATALOG[type].space <= v.space_max const spaceMax = (v: MockVillage) =>
Math.min(v.space_max, MAX_SPACE) + SPACE_PER_HQ_LEVEL * (v.buildings.find((b) => b.type === 'headquarters')?.level ?? 0)
const spaceFits = (v: MockVillage, type: BuildingType) => spaceUsed(v) + CATALOG[type].space <= spaceMax(v)
/** Level after everything already queued for this building; -1 if it is being removed. */ /** Level after everything already queued for this building; -1 if it is being removed. */
function queuedLevel(v: MockVillage, b: MockBuilding) { function queuedLevel(v: MockVillage, b: MockBuilding) {
@ -452,7 +456,7 @@ function view(v: MockVillage, now: number): VillageState {
y: v.y, y: v.y,
continent: continentOf(v.x, v.y), continent: continentOf(v.x, v.y),
points: points(v), points: points(v),
space: { used: spaceUsed(v), max: v.space_max }, space: { used: spaceUsed(v), max: spaceMax(v) },
resources: { ...v.resources }, resources: { ...v.resources },
resources_at: iso(v.resources_at), resources_at: iso(v.resources_at),
rates: rates(v), rates: rates(v),