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.tsMoney formatting, demand curves, compounding, upgrade-cost scaling.
formatMoney()demandAtPrice()compound()upgradeCost()Inventory
inventory.tsStock + capacity, restock, consume, optional spoilage.
restock()consume()spoil()Production
production.tsWorkers × baseRate × multiplier; queues for jobs.
throughput()enqueue()dequeue()Customers
customers.tsArrival rate × marketing × satisfaction; Bernoulli arrivals.
effectiveArrival()didArrive()adjustSatisfaction()Sales
sales.tsCombine a customer, a price, and stock into a transaction.
attemptSale()Progression
progression.tsXP curves, levels, available unlocks given player state.
xpForLevel()levelFromXp()availableUnlocks()Tick
tick.tsA single React hook drives the whole game clock at N Hz.
useGameTick()Save
save.tsVersioned localStorage save/load. Bumping schema invalidates.
saveGame()loadGame()clearSave()UI primitives
Shared React components every tycoon plugs in:
MoneyDisplayUpgradeCardStatBarTickerTapeBigButtonGrowthChartAdding game #2
- 1. Create
src/games/<slug>/state.ts— declare initial state + upgrade tree. - 2. Create
src/games/<slug>/Game.tsx— calluseGameTick, wire to engine. - 3. Add a route at
src/routes/play.<slug>.tsx. - 4. Flip the game in
src/data/games.tsfromConcepttoLivewith the play path.
Search the codebase for TODO next-game: for the exact plug-in points.