feat: add player resource node harvesting

This commit is contained in:
2026-07-04 19:47:31 +02:00
parent f5e7326d49
commit 326df51cbe
6 changed files with 117 additions and 18 deletions
+50
View File
@@ -0,0 +1,50 @@
extends SceneTree
var main_scene: Node
var failures: Array[String] = []
func _initialize() -> void:
call_deferred("_run")
func _run() -> void:
main_scene = load("res://main.tscn").instantiate()
root.add_child(main_scene)
await process_frame
await physics_frame
var simulation_manager := main_scene.get_node("SimulationManager")
var player := main_scene.get_node("Player")
var bush := main_scene.get_node("ResourceNodes/BerryBush_01") as ResourceNode
var tree := main_scene.get_node("ResourceNodes/Tree_01") as ResourceNode
simulation_manager.set_process(false)
bush.amount_remaining = 1.0
_check(bush.reserve(999), "Player contention setup should reserve the bush")
player.global_position = bush.interaction_point.global_position
var food_before: float = simulation_manager.village.food
player.try_interact()
_check(is_equal_approx(bush.amount_remaining, 0.0), "Player should deplete the nearby bush")
_check(is_equal_approx(simulation_manager.village.food, food_before + 1.0), "Village should receive exactly the bush's remaining food")
_check(bush.reserved_by == -1, "Depletion should release the NPC reservation")
player.global_position = tree.interaction_point.global_position
var wood_before: float = simulation_manager.village.wood
var tree_before := tree.amount_remaining
player.try_interact()
_check(is_equal_approx(tree.amount_remaining, tree_before - tree.yield_per_action), "Player should extract the tree's configured yield")
_check(is_equal_approx(simulation_manager.village.wood, wood_before + tree.yield_per_action), "Village should receive exactly the extracted wood")
if failures.is_empty():
print("[TEST] ResourceNode player parity passed")
quit(0)
return
for failure in failures:
push_error("[TEST] " + failure)
quit(1)
func _check(condition: bool, message: String) -> void:
if not condition:
failures.append(message)