test(@projects/@magic-civilization): 🐛 set city.owner in happiness _make_city (fixes pop=1 → real pop)

city.owner drives _pi (the parallel-city-slot player row). _make_city never set
owner, so _pi stayed -1 and found()/set_population addressed an invalid row —
city population silently stayed at the default 1, breaking every happiness
assertion (e.g. balanced/1city/pop3 gave -4 instead of -6; citizen contributions
collapsed to -1/0). Set owner = 0 so the slot resolves. Production code is fine
(real cities always have an owner).

GUT: test_happiness_turn 24 → 4 failing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Natalie 2026-06-24 04:50:07 -04:00
parent b9e6b3d12d
commit 7d13970a3a

View file

@ -40,6 +40,10 @@ func _make_player(growth_tier: String = "balanced") -> RefCounted:
func _make_city(population: int, buildings: Array[String]) -> RefCounted:
var city: RefCounted = CityScript.new("test_city_%d" % randi(), [] as Array[String])
# owner drives _pi (the parallel-city-slot player row); without it _pi stays
# -1 and found()/set_population address an invalid row, so population never
# leaves the default 1 — which silently broke every happiness assertion.
city.owner = 0
city.found("Testhold", 5, 5, true, 1)
city.set_population(population)
for bld: String in buildings: