Files
Battle-for-Tismo/docs/simple_economy/03-construction.md
T
adrien d5305da449 Gave the world a simple economy: one pool per nation and a global market
The simple economy is now the default and the old simulation is frozen as the hard model, selectable per game. A nation keeps one resource pool available in every region, fed by public production works rather than private per-region stores, and construction and training begin at once, paced by the region's spare power instead of gathering materials over days.

Money is euro only: a per-inhabitant daily tax funds a treasury spent in a global market, where buy and sell lots trade against the world stock and move its price. The hard economy keeps its per-nation currencies, central banks and exchange rates.

Simple games skip the price-settling warmup and economic migration; the snapshot carries the economy model, the market and the pool figures the client draws. Added the matching test suites and the design briefs under docs/simple_economy.
2026-09-25 14:58:49 +02:00

5.5 KiB

03 — Construction: immediate start, energy-driven speed

Depends on: 01-, 02-.

Goal

In the simple economy, building starts immediately and its construction speed is proportional to the energy available in the region, with modifiers. Every region must start with one power plant.

Current behaviour (hard economy)

  • requestBuild / requestTrain (shared/game_state/orders.js) pay the money cost, reserve a material budget, push a queue entry in the "materials" phase, and gather steel/high-tech over days via _gatherBuildEntry before "construction" begins.
  • Construction time is gated and scaled off GDP: ECONOMY.productionCapacity(this.getPlayerGdp(civ)) and ECONOMY.buildingHours(gdp, cost) in shared/data/economy.js, times constructionApprovalMultiplier(city) and constructionSpeedMultiplier(civ).
  • Tile improvements become construction sites (shared/game_state/sites.js): _openConstructionSite, _tickConstructionSites, phases materials then construction, buying energy day by day (_buySiteEnergy).
  • Starting cities/buildings are laid out in scenario.js (_seedStartingBuildings) and the generated world in shared/game_state/world.js.

Target behaviour

  • No materials phase in simple mode. An order enters the construction/ training phase immediately. If a material bill exists, draw it from the player's pool at order time (02-), or make simple-mode builds cost no materials. Recommendation: draw from the pool up front, so ordering still consumes resources and cannot be spammed, but there is no multi-day gather and no stall.
  • Construction capacity comes from regional energy, not GDP. Define a region energy figure — e.g. regionAvailableEnergy(city) = the connected region's power production that is not already committed — and make the build speed proportional to it. Keep the existing shape: totalHours = base * speedMultiplier, where base is a cost/energy ratio and the multiplier folds in approval and the existing technology/modifier bonus (constructionSpeedMultiplier, EFFECT_CONSTRUCTION_SPEED).
    • Put the tuning constants (energyPerConstructionHour, a minimum speed floor, and how energy maps to hours) in the simple-economy data module.
    • Define what happens when a region has no power: the work should be slow or stalled, not free. A floor avoids a divide-by-zero and a hard lock.
  • Every region starts with one power plant. Seed one working plant per city region in the simple scenario so regions open with energy and the speed rule has a non-zero basis.
    • Decide the plant type and placement. Recommendation: one of the fuel-free/renewable plants (e.g. solar_power_plant or wind_turbines) on a valid land tile owned by the region, chosen deterministically, so no fuel resource is implied. Ensure the tile passes the existing resource-building placement rules and is connected.
  • Public upgrades. Production-building upgrades (industry.js) are public works in simple mode and follow the same immediate, energy-driven rule.
  • Remove the GDP capacity gate (productionCapacity) from simple-mode construction and training. GDP may still be computed for display only.

Files

  • shared/game_state/orders.js — requestBuild, requestTrain, requestBuildImprovement, _pendingBuildingLevels.
  • shared/game_state/sites.js — _openConstructionSite, _kickoffSite, _tickConstructionSites, _gatherSiteMaterials, _gatherBuildEntry, _buySiteEnergy, _siteForecastBudget. In simple mode a site should open already in "construction" and skip the gather/energy-buy phases.
  • shared/game_state/industry.js — _startBuildingUpgrade, _buyBuilding Materials, _tickBuildingDecisions.
  • shared/game_state/economy.js — constructionSpeedMultiplier, and a new energy-based equivalent; getPlayerGdp stays for display.
  • shared/game_state/simple_economy.js — the overrides.
  • shared/game_state/scenario.js / world.js — the starting plant per region.
  • shared/data/economy.js or new simple data module — construction constants.
  • tests/construction_site_test.js, tests/industry_test.js — extend for simple mode; or a new tests/simple_construction_test.js.

Acceptance criteria

  • In simple mode, ordering a building raises it on the hourly tick with no "materials" phase and no _nearbySuppliers/trade-graph lookups.
  • Construction time scales with the region's available energy, and a power-less region builds clearly slower than a powered one (never faster, and never instantaneous at zero energy).
  • Every starting region has at least one working power plant in simple mode.
  • Hard economy construction is untouched.

Notes / decisions

  • What "available energy" means. Options: (a) the region grid's uncommitted power, (b) the region's gross plant output, (c) a per-region energy balance already computed in the daily resource tick. Define one and use it on both the server and (for display) the client. Do not read a value that only exists mid-tick elsewhere.
  • Concurrency. Hard mode lets one queue line run at a time. Decide whether simple mode keeps one line per city or lets every queued item build in parallel off the same energy pool. Recommendation: keep one line, scaled by energy, to preserve the queue UI.
  • Money. 05-money-and-taxes.md says money is not spent internally in the simple economy; if that is accepted, the _spendBudget calls here must be dropped in simple mode.