feat: add deterministic goat routine

This commit is contained in:
Rijad Zuzo
2026-07-26 23:52:56 +02:00
parent f79c2bb630
commit e3aa3440a2
61 changed files with 1393 additions and 1057 deletions
@@ -20,6 +20,7 @@ func _run() -> void:
_test_previous_world_retention_migration()
_test_previous_world_opportunity_migration()
_test_previous_world_animal_migration()
_test_previous_world_routine_migration()
_test_relationship_schema_rejection()
_test_opportunity_schema_rejection()
_test_animal_schema_rejection()
@@ -498,6 +499,41 @@ func _test_previous_world_animal_migration() -> void:
manager.free()
func _test_previous_world_routine_migration() -> void:
var manager := _create_manager(65)
var v10_data: Dictionary = manager.create_state_record().to_dictionary()
v10_data["schema_version"] = SimulationStateRecord.ROUTINE_LEGACY_SCHEMA_VERSION
v10_data["animals"] = [
{
"schema_version": AnimalStateRecord.LEGACY_SCHEMA_VERSION,
"animal_id": "legacy_goat",
"display_name": "Legacy",
"species_id": String(SimulationIds.SPECIES_GOAT),
"position": [-4.0, 0.0, -11.5],
"hunger": 40.0,
"last_fed_tick": AnimalStateRecord.NEVER_FED_TICK,
"reserved_by": -1,
"enabled": true,
"can_npcs_feed": true,
"can_player_feed": true,
}
]
var migrated := SimulationStateRecord.from_dictionary(v10_data)
_check(migrated != null, "World schema v10 should preserve and upgrade animal records")
if migrated != null:
var animal := migrated.animals[0]
_check(
(
animal.get_animal_id() == &"legacy_goat"
and animal.get_routine_site_id().is_empty()
and not animal.has_active_travel_target()
and animal.get_next_routine_tick() == 0
),
"World v10 migration should add deterministic idle routine defaults"
)
manager.free()
func _test_animal_schema_rejection() -> void:
var manager := _create_manager(64)
var missing_animals: Dictionary = manager.create_state_record().to_dictionary()
@@ -521,6 +557,11 @@ func _test_animal_schema_rejection() -> void:
"enabled": true,
"can_npcs_feed": true,
"can_player_feed": true,
"routine_site_id": "",
"travel_target_site_id": "",
"travel_target_position": [0.0, 0.0, 0.0],
"has_travel_target": false,
"next_routine_tick": 0,
}
)
)