spaceship/tests/test_lab_resources.gd

42 lines
1.2 KiB
GDScript3
Raw Normal View History

2026-08-13 22:04:21 +02:00
extends SceneTree
var game: Node
var lab_id: int
var elapsed := 0.0
func _initialize() -> void:
game = root.get_node("GameState")
game.buildings.clear()
game.vessel_levels.clear()
game.build_time_scale = 0.02
game.rocks = 500
game.research_points = 1
2026-08-13 22:04:21 +02:00
lab_id = game.add_building(GameState.BUILDING_SHIP_LAB, Vector2.ZERO)
if not game.queue_lab_research(lab_id, "int_damage"):
_fail("could not queue research")
func _process(delta: float) -> bool:
elapsed += delta
if elapsed < 0.2:
return false
var order: Dictionary = game.lab_research_order(lab_id)
if not order.is_empty() and not bool(order.started):
if game.rocks != 500:
return _fail("research drew from mothership bank")
game.deposit_to_building(lab_id, game.upgrade_cost("int_damage"))
return false
if game.upgrade_level("int_damage") == 1:
if game.building_stock(lab_id) != 0 or game.rocks != 500:
return _fail("local lab stock/payment was wrong")
print("lab research consumed local ore and completed over time")
print("TEST_LAB_RESOURCES: PASS")
quit(0)
return true
if elapsed > 3.0:
return _fail("research did not complete")
return false
func _fail(message: String) -> bool:
print("TEST_LAB_RESOURCES: FAIL (%s)" % message)
quit(1)
return true