Queue lab research from local stock
This commit is contained in:
parent
798deb48a1
commit
e9acca569e
7 changed files with 137 additions and 27 deletions
41
tests/test_lab_resources.gd
Normal file
41
tests/test_lab_resources.gd
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
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
|
||||
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
|
||||
Loading…
Reference in a new issue