feat: add physical animal care delivery
This commit is contained in:
@@ -11,6 +11,7 @@ func _run() -> void:
|
||||
await _test_deterministic_continuation()
|
||||
await _test_resource_state_round_trip()
|
||||
_test_legacy_npc_migration()
|
||||
_test_npc_inventory_schema_rejection()
|
||||
_test_legacy_resource_migration()
|
||||
_test_legacy_world_storage_migration()
|
||||
_test_previous_world_event_migration()
|
||||
@@ -275,6 +276,43 @@ func _test_legacy_npc_migration() -> void:
|
||||
)
|
||||
|
||||
|
||||
func _test_npc_inventory_schema_rejection() -> void:
|
||||
var npc := SimNPC.new(89, "InventoryNPC", SimulationIds.PROFESSION_FARMER, 5.0, 5.0)
|
||||
var valid_inventory := NPCStateRecord.capture(npc).to_dictionary()
|
||||
var food_id := String(SimulationIds.RESOURCE_FOOD)
|
||||
var invalid_cases := [
|
||||
[{food_id: -1.0}, "negative amounts"],
|
||||
[{food_id: NAN}, "NaN amounts"],
|
||||
[{food_id: INF}, "infinite amounts"],
|
||||
[{food_id: "1.0"}, "string amounts"],
|
||||
[{food_id: true}, "boolean amounts"],
|
||||
[{food_id: null}, "null amounts"],
|
||||
[{"": 1.0}, "empty item IDs"],
|
||||
[{1: 1.0, "1": 2.0}, "item IDs that collide after string normalization"],
|
||||
]
|
||||
for invalid_case in invalid_cases:
|
||||
var invalid_inventory := valid_inventory.duplicate(true)
|
||||
invalid_inventory["inventory"] = invalid_case[0]
|
||||
_check(
|
||||
NPCStateRecord.from_dictionary(invalid_inventory) == null,
|
||||
"NPC records should reject inventory %s" % invalid_case[1]
|
||||
)
|
||||
var normalizable_inventory := valid_inventory.duplicate(true)
|
||||
normalizable_inventory["inventory"] = {SimulationIds.RESOURCE_FOOD: 2}
|
||||
var normalized := NPCStateRecord.from_dictionary(normalizable_inventory)
|
||||
_check(normalized != null, "NPC records should accept normalizable inventory values")
|
||||
if normalized != null:
|
||||
var normalized_inventory: Dictionary = normalized.data["inventory"]
|
||||
_check(
|
||||
(
|
||||
normalized_inventory.has(String(SimulationIds.RESOURCE_FOOD))
|
||||
and typeof(normalized_inventory.keys()[0]) == TYPE_STRING
|
||||
and typeof(normalized_inventory.values()[0]) == TYPE_FLOAT
|
||||
),
|
||||
"NPC records should normalize inventory IDs to strings and amounts to floats"
|
||||
)
|
||||
|
||||
|
||||
func _test_legacy_world_storage_migration() -> void:
|
||||
var manager := _create_manager(55)
|
||||
var legacy_data: Dictionary = manager.create_state_record().to_dictionary()
|
||||
|
||||
Reference in New Issue
Block a user