feat: add location-based food storage loop
This commit is contained in:
@@ -10,6 +10,7 @@ func _run() -> void:
|
||||
await _test_resource_state_round_trip()
|
||||
_test_legacy_npc_migration()
|
||||
_test_legacy_resource_migration()
|
||||
_test_legacy_world_storage_migration()
|
||||
_test_schema_rejection()
|
||||
|
||||
if failures.is_empty():
|
||||
@@ -182,6 +183,26 @@ func _test_legacy_npc_migration() -> void:
|
||||
"Legacy NPC migration should not invent an active travel target"
|
||||
)
|
||||
|
||||
func _test_legacy_world_storage_migration() -> void:
|
||||
var manager := _create_manager(55)
|
||||
var legacy_data: Dictionary = manager.create_state_record().to_dictionary()
|
||||
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")
|
||||
if migrated != null:
|
||||
_check(
|
||||
migrated.storages.size() == 1
|
||||
and is_equal_approx(
|
||||
migrated.storages[0].get_amount(
|
||||
SimulationIds.RESOURCE_FOOD
|
||||
),
|
||||
manager.village.food
|
||||
),
|
||||
"World migration should preserve legacy village food in pantry"
|
||||
)
|
||||
manager.free()
|
||||
|
||||
func _create_manager(seed_value: int) -> Node:
|
||||
var manager: Node = load("res://simulation/SimulationManager.gd").new()
|
||||
manager.simulation_seed = seed_value
|
||||
|
||||
Reference in New Issue
Block a user