Supply lab research with transporters
This commit is contained in:
parent
20ba0011fa
commit
3fc04f816a
3 changed files with 56 additions and 1 deletions
46
tests/test_lab_transporter_delivery.gd
Normal file
46
tests/test_lab_transporter_delivery.gd
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
extends SceneTree
|
||||
|
||||
var state: Node
|
||||
var lab_id: int
|
||||
var elapsed: float = 0.0
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
state = root.get_node("GameState")
|
||||
state.buildings.clear()
|
||||
state.extractors.clear()
|
||||
state.transporters.clear()
|
||||
state.reset_progression()
|
||||
state.rocks = 100
|
||||
state.build_time_scale = 0.02
|
||||
state.add_building(state.BUILDING_MOTHERSHIP, Vector2.ZERO)
|
||||
var hub_id: int = state.add_building(state.BUILDING_TRANSPORT_HUB, Vector2(50, 0))
|
||||
lab_id = state.add_building(state.BUILDING_SHIP_LAB, Vector2(100, 0))
|
||||
state.transporters.append({"hub_id": hub_id, "state": state.TRANSPORTER_IDLE,
|
||||
"target_id": 0, "extractor_index": -1, "carrying": 0, "progress": 1.0,
|
||||
"from": Vector2(50, 0), "to": Vector2(50, 0)})
|
||||
if not state.queue_lab_research(lab_id, "int_damage"):
|
||||
return _fail("could not queue lab research")
|
||||
if state.outstanding_cost(lab_id) != state.upgrade_cost("int_damage"):
|
||||
return _fail("queued research did not expose its ore demand")
|
||||
|
||||
|
||||
func _process(delta: float) -> bool:
|
||||
elapsed += delta
|
||||
if state.upgrade_level("int_damage") == 1:
|
||||
if state.lab_research_order(lab_id).is_empty():
|
||||
print("transporter supplied queued lab research end to end")
|
||||
print("TEST_LAB_TRANSPORTER_DELIVERY: PASS")
|
||||
quit(0)
|
||||
return true
|
||||
if elapsed > 5.0:
|
||||
return _fail("lab still waiting: demand=%d transporter=%s stock=%d" % [
|
||||
state.outstanding_cost(lab_id), state.transporters[0].state,
|
||||
state.building_stock(lab_id)])
|
||||
return false
|
||||
|
||||
|
||||
func _fail(message: String) -> bool:
|
||||
print("TEST_LAB_TRANSPORTER_DELIVERY: FAIL (%s)" % message)
|
||||
quit(1)
|
||||
return true
|
||||
Loading…
Reference in a new issue