spaceship/tests/_staff.gd

29 lines
1.3 KiB
GDScript3
Raw Normal View History

extends RefCounted
# #216 made hub and workshop crews built things: ordered at a ship crafter,
# flown out from the mothership hangar, and worn out by the work they do.
#
# A test that is about what a crew DOES should not have to build and fly one
# in first, so this puts them straight at their post. The assignment is still
# made, so the structure counts them as its own and reports them the way it
# would if they had arrived on their own - only the journey is skipped.
#
# test_transporter_supply.gd owns the journey itself, and does not use this.
# Tops the structure UP to `count`, rather than adding that many: a hub asked
# for three when it already holds two needs one more, and the order is clamped
# to what it can hold anyway.
static func staff(game_state: Node, building_id: int, count: int) -> void:
game_state.set_station_desired(building_id, count)
while game_state.station_crew(building_id) < game_state.station_desired(building_id):
game_state._station_arrived(building_id)
# Every hub and workshop already standing, filled to what it can hold. For
# tests that just need logistics to work at all.
static func staff_all(game_state: Node) -> void:
for building in game_state.buildings:
if game_state.station_vessel_type(building) == "":
continue
staff(game_state, int(building.id), game_state.station_capacity(building))