refactor: clarify simulation ownership

This commit is contained in:
Rijad Zuzo
2026-07-10 11:02:11 +02:00
parent 0f7b12080e
commit ce8f71082b
29 changed files with 793 additions and 587 deletions
+15 -7
View File
@@ -185,17 +185,25 @@ func _test_legacy_world_storage_migration() -> void:
legacy_data["schema_version"] = SimulationStateRecord.LEGACY_SCHEMA_VERSION
legacy_data.erase("storages")
var migrated := SimulationStateRecord.from_dictionary(legacy_data)
_check(migrated != null, "World schema v1 should migrate pantry storage")
_check(migrated != null, "World schema v1 should migrate authored storage")
if migrated != null:
var migrated_storages := {}
for storage in migrated.storages:
migrated_storages[storage.get_storage_id()] = storage
var pantry: StorageStateRecord = migrated_storages.get(
SimulationIds.STORAGE_VILLAGE_PANTRY
)
var woodpile: StorageStateRecord = migrated_storages.get(
SimulationIds.STORAGE_VILLAGE_WOODPILE
)
_check(
(
migrated.storages.size() == 1
and is_equal_approx(
migrated.storages[0].get_amount(SimulationIds.RESOURCE_FOOD),
manager.village.food
)
pantry != null
and woodpile != null
and is_equal_approx(pantry.get_amount(SimulationIds.RESOURCE_FOOD), manager.village.food)
and is_equal_approx(woodpile.get_amount(SimulationIds.RESOURCE_WOOD), manager.village.wood)
),
"World migration should preserve legacy village food in pantry"
"World migration should preserve legacy village resources in their storage"
)
manager.free()