The engine

A shared engine, one genre.

Every Tycoon Tycoon game is a thin layer on top of src/engine/. New game = new theme, new upgrade tree, same primitives.

Modules

Economy

economy.ts

Money formatting, demand curves, compounding, upgrade-cost scaling.

formatMoney()demandAtPrice()compound()upgradeCost()

Inventory

inventory.ts

Stock + capacity, restock, consume, optional spoilage.

restock()consume()spoil()

Production

production.ts

Workers × baseRate × multiplier; queues for jobs.

throughput()enqueue()dequeue()

Customers

customers.ts

Arrival rate × marketing × satisfaction; Bernoulli arrivals.

effectiveArrival()didArrive()adjustSatisfaction()

Sales

sales.ts

Combine a customer, a price, and stock into a transaction.

attemptSale()

Progression

progression.ts

XP curves, levels, available unlocks given player state.

xpForLevel()levelFromXp()availableUnlocks()

Tick

tick.ts

A single React hook drives the whole game clock at N Hz.

useGameTick()

Save

save.ts

Versioned localStorage save/load. Bumping schema invalidates.

saveGame()loadGame()clearSave()

UI primitives

Shared React components every tycoon plugs in:

MoneyDisplayUpgradeCardStatBarTickerTapeBigButtonGrowthChart

Adding game #2

  1. 1. Create src/games/<slug>/state.ts — declare initial state + upgrade tree.
  2. 2. Create src/games/<slug>/Game.tsx — call useGameTick, wire to engine.
  3. 3. Add a route at src/routes/play.<slug>.tsx.
  4. 4. Flip the game in src/data/games.ts from Concept to Live with the play path.

Search the codebase for TODO next-game: for the exact plug-in points.