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:
parent
a1f0dc445b
commit
d2dc037849
|
|
@ -22,7 +22,9 @@ export const BASE_TRICKLE = 5
|
|||
export const VILLAGER_UPKEEP = 1
|
||||
export const DEMOLISH_REFUND = 0.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 CATALOG: Record<BuildingType, CatalogEntry> = {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import {
|
|||
DEFAULT_PRIORITY,
|
||||
DEMOLISH_REFUND,
|
||||
MAX_SPACE,
|
||||
SPACE_PER_HQ_LEVEL,
|
||||
MAX_LEVEL,
|
||||
START_RESOURCES,
|
||||
UNITS,
|
||||
|
|
@ -66,6 +67,7 @@ interface MockVillage {
|
|||
name: string
|
||||
x: number
|
||||
y: number
|
||||
/** Base building space; the headquarters level adds to it. */
|
||||
space_max: number
|
||||
resources: Resources
|
||||
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. */
|
||||
function queuedLevel(v: MockVillage, b: MockBuilding) {
|
||||
|
|
@ -452,7 +456,7 @@ function view(v: MockVillage, now: number): VillageState {
|
|||
y: v.y,
|
||||
continent: continentOf(v.x, v.y),
|
||||
points: points(v),
|
||||
space: { used: spaceUsed(v), max: v.space_max },
|
||||
space: { used: spaceUsed(v), max: spaceMax(v) },
|
||||
resources: { ...v.resources },
|
||||
resources_at: iso(v.resources_at),
|
||||
rates: rates(v),
|
||||
|
|
|
|||
Loading…
Reference in New Issue