Files
Battle-for-Tismo/data/government.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

39 lines
1.4 KiB
GDScript

class_name Government
extends Resource
## A form of government a civilisation can adopt. Concrete instances live under
## res://data/governments and are edited in the inspector.
##
## Unlike buildings, a government has no levels: adopting one replaces the
## previous one and applies its effects in full. Switching costs budget, priced
## like a building from a flat base plus a fraction of the owner's GDP, so it
## stays meaningful as the economy grows.
@export var name : String
@export_multiline var description : String
## Flat part of the cost to adopt this government, in budget currency.
@export var base_cost : float = 0.0
## Fraction of the owner's GDP added to the adoption cost.
@export var cost_gdp_fraction : float = 0.0
## Bonuses this government grants while in power. Effects are evaluated at
## level 1, the only level a government has. See BuildingEffect for the stats.
@export var effects : Array[BuildingEffect] = []
## Budget cost to switch to this government at the given national GDP.
func change_cost(gdp: float) -> float:
return base_cost + cost_gdp_fraction * maxf(gdp, 0.0)
## Total contribution to `stat` from every effect this government carries. All
## effects are evaluated at level 1, the only level a government has.
func effect_value(stat: String) -> float:
var total := 0.0
for effect in effects:
if effect.stat == stat:
total += effect.value_at(1)
return total