Files
Battle-for-Tismo/data/economy_config.gd
T
adrien c49899a2fd Initial commit
Server-authoritative Godot 4.6 strategy game.

Includes the headless WebSocket game server, the browser client, and
Nix packaging (server and web-export derivations plus a NixOS module)
for deployment.
2026-09-15 14:48:34 +02:00

70 lines
2.7 KiB
GDScript

class_name EconomyConfig
extends Resource
## Tunable economic figures. The live values live in res://data/economy.tres
## and can be edited from the Godot inspector without touching any script.
## GDP produced per person on an ordinary owned tile.
@export var base_gdp_per_capita : int = 10000
## Number of people on an ordinary fully-populated tile. Each terrain type
## scales this by its population_multiplier (1.0 = ordinary land).
@export var base_population : int = 100000
## Owned tiles with a city on them produce this multiple of the base GDP per
## capita.
@export var city_tile_gdp_multiplier : float = 2.0
## Owned tiles with a capital city on them produce this multiple of the base
## GDP per capita instead of city_tile_gdp_multiplier.
@export var capital_tile_gdp_multiplier : float = 2.5
## Owned tiles immediately around one of your cities get this GDP per capita
## bonus (0.3 means +30%).
@export_range(0.0, 10.0) var city_surrounding_gdp_bonus : float = 0.3
## How much GDP is worth one production point. A nation's production capacity
## (production points per game hour) is its GDP divided by this value, and a
## unit's cost is measured in production points.
@export var gdp_per_production_point : int = 100000000
## Fraction of a nation's GDP added to its state budget every game hour
## (0.001 means +0.1% of GDP per hour). The economy runs once per in-game day,
## so each tick applies this rate over the whole day.
@export_range(0.0, 1.0) var budget_gdp_rate : float = 0.001
## State budget every civilization starts the game with.
@export var starting_budget : int = 0
## Base annual population growth applied to every populated tile (0.005 means
## +0.5% per in-game year). The economy runs once per in-game day, so growth is
## applied in one-day steps rather than jumping once a year.
@export_range(0.0, 1.0) var base_population_growth_rate : float = 0.005
## Growth factor over a step of `hours` in-game hours. Pass hours_per_year and
## the length of the step to scale annual growth to that step.
func population_growth_factor(hours_per_year: float, hours: float = 1.0) -> float:
if base_population_growth_rate <= 0.0 or hours_per_year <= 0.0 or hours <= 0.0:
return 0.0
return pow(1.0 + base_population_growth_rate, hours / hours_per_year) - 1.0
func production_capacity(gdp: float) -> float:
if gdp_per_production_point <= 0:
return 0.0
return gdp / float(gdp_per_production_point)
func training_hours(gdp: float, cost: int) -> float:
var capacity := production_capacity(gdp)
if capacity <= 0.0:
return 0.0
return float(cost) / capacity
## Budget added over a step of `hours` in-game hours at the hourly rate.
func budget_income(gdp: float, hours: float = 1.0) -> float:
return gdp * budget_gdp_rate * hours