style: apply gdformat formatting across the entire project
Auto-format all GDScript files using gdformat from gdtoolkit. This is a baseline formatting pass to ensure consistent style: - Normalizes indentation and spacing - Wraps long lines to 100 characters - Removes trailing whitespace - Standardizes blank lines between functions 68 files reformatted, 8 files left unchanged (3rd-party addon files with parse errors excluded).
This commit is contained in:
@@ -2,9 +2,11 @@ extends SceneTree
|
||||
|
||||
var failures: Array[String] = []
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
call_deferred("_run")
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
await _test_deterministic_continuation()
|
||||
await _test_resource_state_round_trip()
|
||||
@@ -23,6 +25,7 @@ func _run() -> void:
|
||||
push_error("[TEST] " + failure)
|
||||
quit(1)
|
||||
|
||||
|
||||
func _test_deterministic_continuation() -> void:
|
||||
var uninterrupted := _create_manager(91234)
|
||||
_advance_scenario(uninterrupted, 24)
|
||||
@@ -63,10 +66,9 @@ func _test_deterministic_continuation() -> void:
|
||||
before_save.free()
|
||||
restored.free()
|
||||
|
||||
|
||||
func _test_resource_state_round_trip() -> void:
|
||||
var resource: ResourceNode = load(
|
||||
"res://world/resource_nodes/ResourceNode.tscn"
|
||||
).instantiate()
|
||||
var resource: ResourceNode = load("res://world/resource_nodes/ResourceNode.tscn").instantiate()
|
||||
resource.node_id = &"SerializationTestBerry"
|
||||
resource.initial_amount = 9.0
|
||||
resource.yield_per_action = 2.0
|
||||
@@ -78,9 +80,7 @@ func _test_resource_state_round_trip() -> void:
|
||||
manager.register_resource_node(resource),
|
||||
"Resource presentation should bind to simulation authority"
|
||||
)
|
||||
var resource_state: ResourceStateRecord = manager.get_resource_state(
|
||||
resource.node_id
|
||||
)
|
||||
var resource_state: ResourceStateRecord = manager.get_resource_state(resource.node_id)
|
||||
_check(resource_state.reserve(42), "Resource should accept the test reservation")
|
||||
resource_state.extract()
|
||||
var saved_json: String = manager.serialize_state()
|
||||
@@ -103,15 +103,10 @@ func _test_resource_state_round_trip() -> void:
|
||||
is_equal_approx(resource_state.get_amount_remaining(), 7.0),
|
||||
"Resource amount should round-trip"
|
||||
)
|
||||
_check(
|
||||
resource_state.get_reserved_by() == 42,
|
||||
"Resource reservation should round-trip"
|
||||
)
|
||||
_check(resource_state.get_reserved_by() == 42, "Resource reservation should round-trip")
|
||||
_check(resource_state.is_enabled(), "Resource enabled state should round-trip")
|
||||
|
||||
var rebound: ResourceNode = load(
|
||||
"res://world/resource_nodes/ResourceNode.tscn"
|
||||
).instantiate()
|
||||
var rebound: ResourceNode = load("res://world/resource_nodes/ResourceNode.tscn").instantiate()
|
||||
rebound.node_id = &"SerializationTestBerry"
|
||||
rebound.initial_amount = 999.0
|
||||
root.add_child(rebound)
|
||||
@@ -128,28 +123,28 @@ func _test_resource_state_round_trip() -> void:
|
||||
manager.free()
|
||||
rebound.free()
|
||||
|
||||
|
||||
func _test_schema_rejection() -> void:
|
||||
var unsupported := JSON.stringify({
|
||||
"schema": SimulationStateRecord.SCHEMA_NAME,
|
||||
"schema_version": 999
|
||||
})
|
||||
var unsupported := JSON.stringify(
|
||||
{"schema": SimulationStateRecord.SCHEMA_NAME, "schema_version": 999}
|
||||
)
|
||||
_check(
|
||||
SimulationStateRecord.from_json(unsupported) == null,
|
||||
"Unsupported schema versions should be rejected"
|
||||
)
|
||||
_check(
|
||||
SimulationStateRecord.from_json("[]") == null,
|
||||
"Non-record JSON should be rejected"
|
||||
)
|
||||
_check(SimulationStateRecord.from_json("[]") == null, "Non-record JSON should be rejected")
|
||||
|
||||
|
||||
func _test_legacy_resource_migration() -> void:
|
||||
var migrated := ResourceStateRecord.from_dictionary({
|
||||
"schema_version": 1,
|
||||
"node_id": "legacy_tree",
|
||||
"amount_remaining": 6.0,
|
||||
"reserved_by": 12,
|
||||
"enabled": true
|
||||
})
|
||||
var migrated := ResourceStateRecord.from_dictionary(
|
||||
{
|
||||
"schema_version": 1,
|
||||
"node_id": "legacy_tree",
|
||||
"amount_remaining": 6.0,
|
||||
"reserved_by": 12,
|
||||
"enabled": true
|
||||
}
|
||||
)
|
||||
_check(migrated != null, "ResourceStateRecord v1 should migrate explicitly")
|
||||
if migrated == null:
|
||||
return
|
||||
@@ -158,19 +153,13 @@ func _test_legacy_resource_migration() -> void:
|
||||
"Migrated resource state should use the current nested schema"
|
||||
)
|
||||
_check(
|
||||
is_equal_approx(migrated.get_amount_remaining(), 6.0)
|
||||
and migrated.get_reserved_by() == 12,
|
||||
is_equal_approx(migrated.get_amount_remaining(), 6.0) and migrated.get_reserved_by() == 12,
|
||||
"Resource migration should preserve mutable authority"
|
||||
)
|
||||
|
||||
|
||||
func _test_legacy_npc_migration() -> void:
|
||||
var npc := SimNPC.new(
|
||||
88,
|
||||
"LegacyNPC",
|
||||
SimulationIds.PROFESSION_FARMER,
|
||||
5.0,
|
||||
5.0
|
||||
)
|
||||
var npc := SimNPC.new(88, "LegacyNPC", SimulationIds.PROFESSION_FARMER, 5.0, 5.0)
|
||||
var legacy_data := NPCStateRecord.capture(npc).to_dictionary()
|
||||
legacy_data["schema_version"] = NPCStateRecord.LEGACY_SCHEMA_VERSION
|
||||
legacy_data.erase("travel_target_position")
|
||||
@@ -184,6 +173,7 @@ 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()
|
||||
@@ -193,35 +183,34 @@ func _test_legacy_world_storage_migration() -> void:
|
||||
_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
|
||||
(
|
||||
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 _test_previous_world_event_migration() -> void:
|
||||
var manager := _create_manager(56)
|
||||
var previous_data: Dictionary = manager.create_state_record().to_dictionary()
|
||||
previous_data["schema_version"] = (
|
||||
SimulationStateRecord.PREVIOUS_SCHEMA_VERSION
|
||||
)
|
||||
previous_data["schema_version"] = (SimulationStateRecord.PREVIOUS_SCHEMA_VERSION)
|
||||
previous_data.erase("economic_events")
|
||||
previous_data["simulation"].erase("next_event_id")
|
||||
var migrated := SimulationStateRecord.from_dictionary(previous_data)
|
||||
_check(migrated != null, "World schema v2 should add an empty event stream")
|
||||
if migrated != null:
|
||||
_check(
|
||||
migrated.economic_events.is_empty()
|
||||
and int(migrated.simulation["next_event_id"]) == 0,
|
||||
migrated.economic_events.is_empty() and int(migrated.simulation["next_event_id"]) == 0,
|
||||
"World v2 migration should initialize deterministic event identity"
|
||||
)
|
||||
manager.free()
|
||||
|
||||
|
||||
func _create_manager(seed_value: int) -> Node:
|
||||
var manager: Node = load("res://simulation/SimulationManager.gd").new()
|
||||
manager.simulation_seed = seed_value
|
||||
@@ -230,6 +219,7 @@ func _create_manager(seed_value: int) -> Node:
|
||||
manager.set_process(false)
|
||||
return manager
|
||||
|
||||
|
||||
func _advance_scenario(manager: Node, steps: int) -> void:
|
||||
for step in steps:
|
||||
manager.simulate_tick()
|
||||
@@ -238,6 +228,7 @@ func _advance_scenario(manager: Node, steps: int) -> void:
|
||||
if npc.task_state == SimNPC.TASK_STATE_TRAVELING:
|
||||
manager.notify_npc_arrived(npc.id)
|
||||
|
||||
|
||||
func _check(condition: bool, message: String) -> void:
|
||||
if not condition:
|
||||
failures.append(message)
|
||||
|
||||
Reference in New Issue
Block a user