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:
|
||||
var manager: Node = load("res://simulation/SimulationManager.gd").new()
|
||||
manager.debug_logs = false
|
||||
@@ -14,18 +16,20 @@ func _run() -> void:
|
||||
var pantry: StorageStateRecord = manager.get_pantry()
|
||||
pantry.withdraw(SimulationIds.RESOURCE_FOOD, 1000.0)
|
||||
manager._sync_village_food()
|
||||
var resource := ResourceStateRecord.from_dictionary({
|
||||
"schema_version": ResourceStateRecord.SCHEMA_VERSION,
|
||||
"node_id": "food_loop_bush",
|
||||
"action_id": String(SimulationIds.ACTION_GATHER_FOOD),
|
||||
"resource_id": String(SimulationIds.RESOURCE_FOOD),
|
||||
"amount_remaining": 10.0,
|
||||
"yield_per_action": 2.0,
|
||||
"reserved_by": -1,
|
||||
"enabled": true,
|
||||
"can_npcs_use": true,
|
||||
"can_player_use": true
|
||||
})
|
||||
var resource := ResourceStateRecord.from_dictionary(
|
||||
{
|
||||
"schema_version": ResourceStateRecord.SCHEMA_VERSION,
|
||||
"node_id": "food_loop_bush",
|
||||
"action_id": String(SimulationIds.ACTION_GATHER_FOOD),
|
||||
"resource_id": String(SimulationIds.RESOURCE_FOOD),
|
||||
"amount_remaining": 10.0,
|
||||
"yield_per_action": 2.0,
|
||||
"reserved_by": -1,
|
||||
"enabled": true,
|
||||
"can_npcs_use": true,
|
||||
"can_player_use": true
|
||||
}
|
||||
)
|
||||
manager.resource_states[resource.get_node_id()] = resource
|
||||
|
||||
var npc: SimNPC = manager.npcs[0]
|
||||
@@ -38,10 +42,9 @@ func _run() -> void:
|
||||
manager.simulate_tick()
|
||||
|
||||
_check(
|
||||
is_equal_approx(resource.get_amount_remaining(), 8.0)
|
||||
and is_equal_approx(
|
||||
npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD),
|
||||
2.0
|
||||
(
|
||||
is_equal_approx(resource.get_amount_remaining(), 8.0)
|
||||
and is_equal_approx(npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD), 2.0)
|
||||
),
|
||||
"Gathering should move food from the source into NPC inventory"
|
||||
)
|
||||
@@ -58,10 +61,9 @@ func _run() -> void:
|
||||
manager.notify_npc_arrived(npc.id)
|
||||
manager.simulate_tick()
|
||||
_check(
|
||||
is_equal_approx(pantry.get_amount(SimulationIds.RESOURCE_FOOD), 2.0)
|
||||
and is_equal_approx(
|
||||
npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD),
|
||||
0.0
|
||||
(
|
||||
is_equal_approx(pantry.get_amount(SimulationIds.RESOURCE_FOOD), 2.0)
|
||||
and is_equal_approx(npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD), 0.0)
|
||||
),
|
||||
"Deposit should transfer carried food into the pantry"
|
||||
)
|
||||
@@ -75,28 +77,23 @@ func _run() -> void:
|
||||
manager.notify_npc_arrived(npc.id)
|
||||
manager.simulate_tick()
|
||||
_check(
|
||||
is_equal_approx(pantry.get_amount(SimulationIds.RESOURCE_FOOD), 1.0)
|
||||
and is_equal_approx(
|
||||
npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD),
|
||||
1.0
|
||||
(
|
||||
is_equal_approx(pantry.get_amount(SimulationIds.RESOURCE_FOOD), 1.0)
|
||||
and is_equal_approx(npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD), 1.0)
|
||||
),
|
||||
"Withdraw should transfer pantry food into NPC inventory"
|
||||
)
|
||||
|
||||
manager.simulate_tick()
|
||||
_check(
|
||||
npc.current_task == SimulationIds.ACTION_EAT,
|
||||
"NPC carrying food should select eat"
|
||||
)
|
||||
_check(npc.current_task == SimulationIds.ACTION_EAT, "NPC carrying food should select eat")
|
||||
manager.notify_npc_arrived(npc.id)
|
||||
var hunger_before_eating := npc.hunger
|
||||
manager.simulate_tick()
|
||||
manager.simulate_tick()
|
||||
_check(
|
||||
npc.hunger < hunger_before_eating
|
||||
and is_equal_approx(
|
||||
npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD),
|
||||
0.0
|
||||
(
|
||||
npc.hunger < hunger_before_eating
|
||||
and is_equal_approx(npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD), 0.0)
|
||||
),
|
||||
"Eating should consume carried food and reduce hunger"
|
||||
)
|
||||
@@ -121,8 +118,10 @@ func _run() -> void:
|
||||
"Economic events should restore with the simulation"
|
||||
)
|
||||
_check(
|
||||
restored.economic_events.size() == manager.economic_events.size()
|
||||
and restored.next_event_id == manager.next_event_id,
|
||||
(
|
||||
restored.economic_events.size() == manager.economic_events.size()
|
||||
and restored.next_event_id == manager.next_event_id
|
||||
),
|
||||
"Economic event history and its next ID should round-trip"
|
||||
)
|
||||
|
||||
@@ -134,10 +133,12 @@ func _run() -> void:
|
||||
push_error("[TEST] " + failure)
|
||||
quit(1)
|
||||
|
||||
|
||||
func _check(condition: bool, message: String) -> void:
|
||||
if not condition:
|
||||
failures.append(message)
|
||||
|
||||
|
||||
func _check_economic_event_chain(manager: Node) -> void:
|
||||
var expected_types: Array[StringName] = [
|
||||
SimulationIds.EVENT_RESOURCE_EXTRACTED,
|
||||
@@ -154,28 +155,19 @@ func _check_economic_event_chain(manager: Node) -> void:
|
||||
for index in expected_types.size():
|
||||
var event: EconomicEventRecord = manager.economic_events[index]
|
||||
_check(
|
||||
int(event.data["event_id"]) == index
|
||||
and StringName(event.data["event_type"]) == expected_types[index]
|
||||
and StringName(event.data["item_id"])
|
||||
== SimulationIds.RESOURCE_FOOD,
|
||||
(
|
||||
int(event.data["event_id"]) == index
|
||||
and StringName(event.data["event_type"]) == expected_types[index]
|
||||
and StringName(event.data["item_id"]) == SimulationIds.RESOURCE_FOOD
|
||||
),
|
||||
"Economic event order, identity, and item should be deterministic"
|
||||
)
|
||||
_check(
|
||||
is_equal_approx(
|
||||
float(manager.economic_events[0].data["amount"]),
|
||||
2.0
|
||||
)
|
||||
and is_equal_approx(
|
||||
float(manager.economic_events[1].data["amount"]),
|
||||
2.0
|
||||
)
|
||||
and is_equal_approx(
|
||||
float(manager.economic_events[2].data["amount"]),
|
||||
1.0
|
||||
)
|
||||
and is_equal_approx(
|
||||
float(manager.economic_events[3].data["amount"]),
|
||||
1.0
|
||||
(
|
||||
is_equal_approx(float(manager.economic_events[0].data["amount"]), 2.0)
|
||||
and is_equal_approx(float(manager.economic_events[1].data["amount"]), 2.0)
|
||||
and is_equal_approx(float(manager.economic_events[2].data["amount"]), 1.0)
|
||||
and is_equal_approx(float(manager.economic_events[3].data["amount"]), 1.0)
|
||||
),
|
||||
"Economic events should record exact transferred quantities"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user